Home » WooCommerce: Create a Custom Order Status

WooCommerce: Create a Custom Order Status

by Tutor Aspire

All WooCommerce orders go to either “processing”, “completed”, “on-hold” and other default order statuses based on the payment method and product type.

Sometimes these statuses are not enough. For example, you might need to mark certain orders in a different way for tracking, filtering, exporting purposes. Or you might want to disable default emails by bypassing the default order status changes.

Either way, creating a custom order status is quite easy. And today we’ll see which PHP snippet you need in order to make this work!

WooCommerce: create a custom order status

PHP Snippet: Create a Custom WooCommerce Order Status

/**
 * @snippet       Custom WooCommerce Order Status
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://tutoraspire.com
 */

add_filter( 'woocommerce_register_shop_order_post_statuses', 'tutoraspire_register_custom_order_status' );

function tutoraspire_register_custom_order_status( $order_statuses ) {
   // Status must start with "wc-"!
   $order_statuses['wc-custom-status'] = array(
      'label' => 'Custom Status',
      'public' => false,
      'exclude_from_search' => false,
      'show_in_admin_all_list' => true,
      'show_in_admin_status_list' => true,
      'label_count' => _n_noop( 'Custom Status (%s)', 'Custom Status (%s)', 'woocommerce' ),
);
   return $order_statuses;
}

add_filter( 'wc_order_statuses', 'tutoraspire_show_custom_order_status_single_order_dropdown' );

function tutoraspire_show_custom_order_status_single_order_dropdown( $order_statuses ) {
   $order_statuses['wc-custom-status'] = 'Custom Status';
   return $order_statuses;
}

You may also like