doudang4568 2019-07-17 11:53
浏览 119
已采纳

在WooCommerce中添加来自其他脚本的客户备注

I have a script that changes the status of orders based on our ERP system.

In addition to that, we need to add customer notes. I found the way to do it:

$order->add_order_note($note);
$order->save();

Unfortunately this won't work outside the order edit screen, I tried to run it from my custom plugin. (source)

If I do it via $order->update_status($status, $note); it only updates the status.

Is there a way to add a note outside the edit screen? (Including e-mailing the customer)

  • 写回答

2条回答 默认 最新

  • dongshiru5913 2019-07-17 21:58
    关注

    If the note is for the customer (and has to be visible for him) you need to use instead the WC_Order method set_customer_note() (or both):

    $order->set_customer_note($note);
    // $order->add_order_note($note);
    $order->save();
    

    Or:

    $order->set_customer_note($note);
    $order->update_status($status, $note);
    

    This need to be done before saving the order data or updating the order status.


    To re-send the email notification to the customer (if needed) you can use from the current order ID:

    $emails = WC()->mailer()->get_emails();
    
    $emails['WC_Email_Customer_Completed_Order']->trigger( $order_id );
    // OR: $emails['WC_Email_Customer_Processing_Order']->trigger( $order_id );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)