How do i add a custom order note programmatically in Woocommerce admin order details page

To show custom order note programmatically in Woocommerce admin order details page you need to use ‘woocommerce_thankyou’ action hook. Here is the complete code:

function add_custom_order_notes( $order_id ) {
	
	$order = wc_get_order(  $order_id );
	
	// Text for the note
	$note = __("This is my test note", 'text-domain');

	// Add note
	$order->add_order_note( $note );
}; 

add_action( 'woocommerce_thankyou', 'add_custom_order_notes', 10, 1 ); 

Leave a Reply

Your email address will not be published. Required fields are marked *