在 WooCommerce 中批准订单时向客户添加订单备注

Add an order note to customers when they approve their orders in WooCommerce

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

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

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

        // 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()