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 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上