Create Custom Order Status in WooCommerce

To create custom order statuses in WooCommerce, you’ll need to use a combination of PHP and WordPress hooks. Here’s a step-by-step guide on how to achieve this:

Solutions:

Navigate to the theme folder you’re currently using. Typically, it’s located in wp-content/themes/your-theme/. Inside your theme folder, look for the functions.php file. If it doesn’t exist, you can create it.

Open the functions.php file using a text editor and add the following code:

/**
* Snippet Name:    To Create custom WooCommerce order status.
* Snippet Author:   https://wpproblog.com
*/

// To Create Custom Order Status in WooCommerce
add_filter( 'woocommerce_register_shop_order_post_statuses', 'wpproblog_register_custom_order_status' );

function wpproblog_register_custom_order_status( $order_statuses ){
   $order_statuses['wc-custom-status'] = array(
   'label'                     => __( 'Custom Status', 'Order status', 'woocommerce' ),
   'public'                    => true,
   '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;
}

add_filter( 'wc_order_statuses', 'wpproblog_show_custom_order_status' );

function wpproblog_show_custom_order_status( $order_statuses ) {
   $order_statuses['wc-custom-status'] = _x( 'Custom Status', 'Order status', 'woocommerce' );
   return $order_statuses;
}

Save the changes to the functions.php file.

Now, when you go to the WordPress admin area and navigate to WooCommerce > Orders, you should see the new custom status in the order status dropdown.

To apply the custom order status to an existing order or create a new order with the custom status, open an order in the WordPress admin area and select the custom status from the order status dropdown.

Output:

If you’re unsure about modifying the functions.php file, consider consulting with a developer or utilizing a plugin specifically designed for managing scripts and enqueued assets in WordPress.