【问题标题】:Add an order note to customers when they approve their orders in WooCommerce当客户在 WooCommerce 中批准订单时向他们添加订单备注
【发布时间】:2020-11-14 01:36:47
【问题描述】:

在 WooCommerce 中,Allow customer to change order status in WooCommerce 回答了我之前的问题,允许客户在“我的帐户”页面中批准(完成)订单,但我不知道如何自动添加备注,所以当客户批准订单时(订单状态更改为已完成),我想自动为客户添加备注。

当客户批准订单并且状态更改为“已完成”时,是否可以添加备注?

【问题讨论】:

  • @LoicTheAztec 管理订单页面上的注释,蓝色背景注释“给客户的注释”。因此客户可以通过查看订单来查看它们

标签: php wordpress methods woocommerce orders


【解决方案1】:

如果您想要客户的订单备注,请替换以下代码行:

        // Change order status to "completed"
        $order->update_status( 'completed', __('Approved by the customer', 'woocommerce') ) ;

作者:

        // Add an order note for the customer (blue background note in admin orders)
        $order->add_order_note( __('You have approved this order on', 'woocommerce') . ' ' . date_i18n( 'F j, Y' ), true );

        // Change order status to "completed"
        $order->update_status( 'completed', __('Approved by the customer', 'woocommerce') ) ;

WooCommerce 文档: WC_Order method add_order_note()

【讨论】:

  • 感谢您的回答,我正在测试,但该代码正在添加客户订单注释,例如结帐页面中的附加注释?我的意思是在管理订单页面中向客户添加注释,就像这个文档Order Note
  • @JulioEnsutias 我已经用解释更新了我的答案……
  • 是的,但是方法 update_status() 添加带有“紫色”背景的注释,我想要添加带有“蓝色”背景的注释(给客户的注释),这样我就可以使用调用函数显示该注释get_customer_order_notes() ,是否可以更改注释类型?
  • 好的,我已经抓住了……找到了……我已经更新了我的答案。
猜你喜欢
  • 2022-01-20
  • 1970-01-01
  • 1970-01-01
  • 2020-09-14
  • 2018-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多