How to Set Custom WooCommerce Order Status for New Orders?

In general terms, every WooCommerce order goes through defined phases. The default order status either shows ‘processing’, ‘completed’, or ‘on hold’ based on payment methods or product types. However, these default statuses are not always enough! So, here is when you need to learn how to Set Custom WooCommerce Order Status for New Orders. 

This function is useful when you want to mark orders for tracking, filtering, or exporting. Also, you might wish to disable certain messages by changing the default order status.

Fortunately, you can easily change current order status even if the order is processed. Further, you will find some PHP snippets to make this functionality work! Enjoy the reading.

WooCommerce-Set-Custom-Order-Status-for-New-Orders

PHP Snippet: Set Custom Order Status for New Orders during checkout process

// ---------------------
// 1. Register Order Status
 
add_filter( 'woocommerce_register_shop_order_post_statuses', 'phpsof_register_custom_order_status' );
 
function phpsof_register_custom_order_status( $order_statuses ){
    
   // Status must start with "wc-"
   $order_statuses['wc-custom-status'] = array(                                 
   'label'                     => _x( 'Custom Status', 'Order status', 'woocommerce' ),
   'public'                    => false,                                 
   'exclude_from_search'       => false,                                 
   'show_in_admin_all_list'    => true,                                 
   'show_in_admin_status_list' => true,                                 
   'label_count'               => _n_noop( 'Custom Status <span class="count">(%s)</span>', 'Custom Status <span class="count">(%s)</span>', 'woocommerce' ),                              
   );      
   return $order_statuses;
}
 
// ---------------------
// 2. Show Order Status in the Dropdown @ Single Order and "Bulk Actions" @ Orders
 
add_filter( 'wc_order_statuses', 'phpsof_show_custom_order_status' );
 
function phpsof_show_custom_order_status( $order_statuses ) {      
   $order_statuses['wc-custom-status'] = _x( 'Custom Status', 'Order status', 'woocommerce' );       
   return $order_statuses;
}
 
add_filter( 'bulk_actions-edit-shop_order', 'phpsof_get_custom_order_status_bulk' );
 
function phpsof_get_custom_order_status_bulk( $bulk_actions ) {
   // Note: "mark_" must be there instead of "wc"
   $bulk_actions['mark_custom-status'] = 'Change status to custom status';
   return $bulk_actions;
}
 
// ---------------------
// 3. Set Custom Order Status @ WooCommerce Checkout Process
 
add_action( 'woocommerce_thankyou', 'phpsof_thankyou_change_order_status' );
 
function phpsof_thankyou_change_order_status( $order_id ){
   if( ! $order_id ) return;
   $order = wc_get_order( $order_id );
 
   // Status without the "wc-" prefix
   $order->update_status( 'custom-status' );
}

Where do you add this snippet?

So, this is how you enable the Custom WooCommerce Order Status for New Orders function at admin panel. This is how you can change the current order status. Also, it is easier to activate this function with this code. To apply this code, just add this PHP snippet at your child theme function.php file’s bottom. It should be placed before “?>”, if you have it there. Apart from this, CSS goes in your child theme style.css file. 

Is this snippet still valid?

So, this is how you enable custom WooCommerce order status function. Thereafter, you will come to knowledge about order transition in a better way. I have applied this code on the Storefront theme and WordPress friendly hosting PHP 7.3. Let me know if everything works as expected. Share it further if you find this snippet useful for you and it had saved your time.

Also Read, How to Send Email on Custom Order Status in WooCommerce?

A Guide to WooCommerce Min Purchase Amount for Specific Product

Important links: WooCommerce – https://woocommerce.com/