Thank You Page Auto Updating Order Status to Processing
-
I’m placing this here incase it helps out another developer. I was running into an issue when a user would load or refresh their Order Details view, the products order status would reset from whatever it was to Processing. This was mostly problematic when an order was updated to Completed, but a few days later, when the user loaded the Order Details view, the order status would update back to Processing.
In short, I updated the following file:
wc-place-order-without-payment/wc-place-order-without-payment.phpOld:
add_action( 'woocommerce_thankyou', 'wpowp_update_order_status_pending' ); function wpowp_update_order_status_pending( $order_id ) { $order = new WC_Order( $order_id ); $order->update_status( 'processing' ); }
New:
add_action( 'woocommerce_thankyou', 'wpowp_update_order_status_pending' ); function wpowp_update_order_status_pending( $order_id ) { $order = new WC_Order( $order_id ); if ($order->get_status() == 'pending') { $order->update_status( 'processing' ); } }
Simply checking the order status before updating it to processing.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Thank You Page Auto Updating Order Status to Processing’ is closed to new replies.