woocommerce change order status programmatically – How to change order status automatically in WooCommerce?

woocommerce change order status programmatically – How to change order status automatically in WooCommerce?

woocommerce change order status programmatically and Rename Woo-commerce Order Status Programmatically Possible values: processing, on-hold, cancelled, completed.

woocommerce change order status programmatically

The following are the list of available woocommerce order status like as bellow

  • wc-cancelled For Cancelled
  • wc-completed For Completed
  • wc-failed For Failed
  • wc-on-hold For On hold
  • wc-pending For Pending payment
  • wc-processing For Processing
  • wc-refunded For Refunded

Woocommerce: Programmatically Updating Order Status

If you ever required to change the order status from php here is how to do it. you can check here wc_order

$orderId = 245;
$orderDetail = new WC_Order( $order_id );
$orderDetail->update_status("wc-completed", 'Completed', TRUE);

Modify order status from order ID

add_action('init',function(){
	$order = new WC_Order(210);
        $order->update_status('wc-processing'); 
});

Example – Rename Woo-commerce Order Status Programmatically

function aviweb_renaming_order_status( $order_statuses ) {
    foreach ( $order_statuses as $key => $status ) {
	if ( 'wc-processing' === $key ) {
		$order_statuses['wc-processing'] = _x( 'In progress', 'Order status', 'woocommerce' );
	}
	if ( 'wc-completed' === $key ) {
		$order_statuses['wc-completed'] = _x( 'Delivered', 'Order status', 'woocommerce' );
	}
     }
     return $order_statuses;
}
add_filter( 'wc_order_statuses', 'aviweb_renaming_order_status' );

I hope you get an idea about woocommerce change order status programmatically.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment