WooCommerce Add Order Note Programmatically

Today we will talk about how to Add an Order Note Programmatically on WooCommerce. Sometimes, we need to add a note for an order. To create an order note, it is necessary to have access to the order ID first in order to proceed.

Below is an example:

$orderId = 20;
   $orderObject = wc_get_order( $orderId ); // get Order object by order id
 $orderNote = __("This is order note's text…"); // add note text
$orderObject->add_order_note( $orderNote, $is_customer_note = 0, $added_by_user = false);

Qaisar Satti

Hi, I'm Qaisar Satti! I've been a developer for over 20 years, and now I love sharing what I've learned through tutorials and guides. Whether you're working with Magento, PrestaShop, or WooCommerce, my goal is to make your development journey a bit easier and more fun. When I'm not coding or writing, you can find me exploring new tech trends and hanging out with the amazing developer community. Thanks for stopping by, and happy coding!