Create WooCommerce Order Status

This is how we can create a new order status in WooCommerce by using the ‘wc_order_statuses’ filter. This is a comman practive in almost every big WooCommerce store. In the post I will show you how to, let’s go.

WooCommerce Order Status

First of all, you should add this code to your functions.php, or use a snippet plugin, like Code Snippet, which is what I do.

// register the new order status "em separação"
function register_em_separacao_order_status() {
    register_post_status( 'wc-separacao', array(
        'label'                     => 'Em Separação',
        'public'                    => true,
        'show_in_admin_status_list' => true,
        'show_in_admin_all_list'    => true,
        'exclude_from_search'       => false,
	'order'                     => 0,
        'label_count'               => _n_noop( 'Em Separação <span class="count">(%s)</span>', 'Em Separação <span class="count">(%s)</span>' )
    ) );
// add the function to init action so we can register the post status
add_action( 'init', 'register_em_separacao_order_status' );

// this function will put the newly created status in the order status array
// it receives the $order_statuses as param
function add_em_separacao_to_order_statuses( $order_statuses ) {
    $new_order_statuses = array();
    foreach ( $order_statuses as $key => $status ) {
        $new_order_statuses[ $key ] = $status;
        if ( 'wc-processing' === $key ) {
            // key/name = label 
            $new_order_statuses['wc-separacao'] = 'Em Separação';
    return $new_order_statuses;
// add our function to the wc_order_statuses filter and we are done!
add_filter( 'wc_order_statuses', 'add_em_separacao_to_order_statuses' );

On the first function, register_em_separacao_order_status, we create a new post status according to our needs and hook it into the init action.

On the second function, add_em_separacao_to_order_statuses, we receive the $order_statuses param that holds all the common WooCommerce order statuses. We need to return this array with order statuses at the end, but with our newly created status. So, we create a new array, insert our status just after wc-processing and return the new array.

That’s it. You’ve just learned how to Create WooCommerce Order Status.

In the next post we will learn how to create bulk actions for our newly created status and use it on the orders page to bulk check all the orders we want.


Leave a Reply

Your email address will not be published.