I have a specific requirement to update a woocommerce order note date, please reference below image to see what i would like to change.
The problem im facing is the below code will crash my server causing internal error on localhost staging environment. The note is saved but the date is incorrect. Woocommerce saves the order notes as comments and the date is actually in the comment database table, im unable to get the below code to function, im hoping a professional can help me point out where im going wrong and how i can achieve a functional code to implement in a plugin.
Thank you in advance, been pulling my hair out and need guidance here.
add_action( 'woocommerce_process_shop_order_meta', 'woocommerce_process_shop_order', 10, 2 );
function woocommerce_process_shop_order ( $order_id ) {
//Get this order id dynamically
$order = wc_get_order( $order_id );
// The text for the note
$note = __("Custom Order Note Here");
$note_date = date('d.m.Y',strtotime("-1 days"));
// Add the note
$order->add_order_note( $note );
$order->wp_insert_comment($note_date);
// Save the data
$order->save();
}
// Save the data $order->save();
not mean save the order note? Any help is greatly appreciated