I’ve been looking around to find a way to change our woocommerce orders status based on the order notes. We have a card processor that adds order notes when an order is approved, but it puts the order on hold because the card is only authorized not charged. We charge the card later once the order has been shipped, but we need the order to go into "processing" so we can export the order into our system so we can actually process the order (we don’t process through woocommerce).
I found this code however, I’m wondering if this can be modified to pull what is in the order notes since our processor adds whether or not the card has been approved.
function mysite_woocommerce_payment_complete( $order_id ) {
error_log( "Payment has been received for order $order_id" );
}
add_action( 'woocommerce_payment_complete', 'mysite_woocommerce_payment_complete', 10, 1 );
2
Answers
Here is a Example which switch on hold order status with processing. you can use it or if need to add some more condition, please mention here or update it accordingly. Thanks
You can use
wc_get_order_notes($args)
function to get the order notes in the specific order. It returns an array of order notes. Then you can loop through the array to find the order note you need. Then use anif
statement to verify the content of the order note and update the status.