Create custom order statuses on WooCommerce

Creating custom order statuses on WooCommerce

WooCommerce still does not let you create your own order statuses from the admin: you need a plugin, or a few lines of code. The plugin is the right option if you want an automatic email for each new status. Code is enough for a simple marker in your order list.

In short

  • WooCommerce has 7 built-in statuses, with no screen to add more.
  • A custom status keeps the customer informed, for example “In production” for a maker.
  • With a plugin (YITH Custom Order Status, Order Status Manager): colors, actions and emails without code.
  • With code: two filters, compatible with HPOS order storage.
  • Code alone sends no email: for that, the plugin is simpler.

The built-in statuses, and their limit

WooCommerce knows seven statuses: Pending payment, Processing, On hold, Completed, Canceled, Refunded and Failed. They describe the payment, not the way you work.

A maker who builds to order, for example, spends days between “Processing” and “Completed”. Meanwhile, the customer has no idea where their order stands. An “In production” status, visible in their account and announced by email, settles the question.

A custom In preparation status inserted between the native Processing and Completed statuses, which triggers an email to the customer

Method 1: a plugin

YITH WooCommerce Custom Order Status (premium) is the plugin we use. It lets you:

  • create as many statuses as you need, each with its own name, color and an icon or label;
  • replace a built-in WooCommerce status;
  • send a customizable email each time an order moves to a status.

For each status, you also decide how it behaves:

  • allow the order to be canceled or not;
  • allow payment;
  • treat the order as paid;
  • give access to downloadable files;
  • count the order in reports;
  • put the items back in stock;
  • show an action button in the order list.

WooCommerce also sells its own extension, Order Status Manager, which creates, edits and deletes statuses, adds buttons to move to the next status and sends emails based on status changes.

Method 2: a few lines of code

If a marker in the order list is enough for you, with no email, two filters do the job. Add this code with the Code Snippets plugin or in the functions.php file of your child theme:

add_filter( 'woocommerce_register_shop_order_post_statuses', 'wycan_enregistrer_statut' );

function wycan_enregistrer_statut( $statuts ) {
    $statuts['wc-en-preparation'] = array(
        'label'                     => 'Being prepared',
        'public'                    => false,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Being prepared <span class="count">(%s)</span>', 'Being prepared <span class="count">(%s)</span>' ),
    );
    return $statuts;
}

add_filter( 'wc_order_statuses', 'wycan_ajouter_statut_a_la_liste' );

function wycan_ajouter_statut_a_la_liste( $statuts ) {
    $resultat = array();
    foreach ( $statuts as $cle => $libelle ) {
        $resultat[ $cle ] = $libelle;
        if ( 'wc-processing' === $cle ) {
            $resultat['wc-en-preparation'] = 'Being prepared';
        }
    }
    return $resultat;
}

The first filter registers the status with WooCommerce, the second adds it just after “Processing” in the order’s drop-down list. The status works whether your orders are stored the old way or in the HPOS tables, because it goes through WooCommerce’s own filters.

Three precautions:

  • A short identifier: including wc-, it must not exceed 20 characters, the size of the column that stores it.
  • A paid order: if this status applies to orders already paid, declare it as such so that WooCommerce treats it like “Processing” or “Completed”:
add_filter( 'woocommerce_order_is_paid_statuses', function ( $statuts ) {
    $statuts[] = 'en-preparation';
    return $statuts;
} );
  • No automatic email: sending one means creating a full WooCommerce email class. If you need it, the plugin is quicker and safer.

A real example

A jewellery maker receives an order. She moves the order to “In production”: her customer receives an email, and the status shows in their account. Once the piece has shipped, she moves the order to “Completed”. No more messages asking where the order is, and a customer who feels looked after.

Need custom order tracking?

Statuses, emails, preparation steps, a tracking board for your workshop: we build this kind of tool to fit the way you work.

Discover our custom plugins or tell us about your need

Contents
Read next

More articles that may help you

Illustration au trait : un casque audio, une onde sonore, un stockage de fichiers et le symbole d’un flux RSS

Self-hosted podcast: moving a podcast to WordPress and Cloudflare R2

Read the article →
Illustration au trait : une patinoire vue de dessus, des sapins et un écran d’état avec deux pastilles

Ice rink and skating trail: a municipality’s custom WordPress plugin

Read the article →
WooCommerce e-invoicing: how to make your shop compliant

WooCommerce e-invoicing: how to bring your shop into compliance

Read the article →

A project, a question?

Free quote · Refundable deposit · Balance only if satisfied · No commitment