Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

In WooCommerce, Allow customer to change order status in WooCommerce answer to my previous question, allows the customer to approve (complete) orders in "My Account" page, but I don't know how to add a note automatically, so when the Customer approves an order (order status is changed to completed), I want to automatically add a note for customer.

Is it possible to add a Note when customer approve an order and status is changed to "completed"?

like image 217
Julio Ensutias Avatar asked Dec 20 '25 04:12

Julio Ensutias


1 Answers

If you want an order note for the customer, replace the following code line:

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

by:

        // 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 Documentation: WC_Order method add_order_note()

like image 180
LoicTheAztec Avatar answered Dec 21 '25 18:12

LoicTheAztec



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!