What is a WooCommerce Order Status?

The WooCommerce Order Status is a term that represents the state of an order in this famous WordPress plugin that powers millions of websites.

In a few words, the order statuses exist to inform your customer when they will receive what they paid for.

And for store administrators, this information helps to manage the products stock and guide the order fulfillment process.

In the image below, the order statuses that come by default in a new installation and their relationships.

Core order statuses in WooCommerce

Default order statuses in WooCommerce

As we can see, each status tells us relevant information about the order, like a successful payment, maybe a canceled one, if it needs some user action, or even it is completed and no more attention is required.

After the customer has successfully paid the order, the fulfillment process starts, and the order statuses are used to identify the current step of the order fulfillment workflow.

Existing order status in WooCommerce

These are the core WooCommerce Order Statuses available by default and their descriptions:

  • Pending payment – A user placed an order and this is the initial order status, and it is awaiting payment.
  • Failed – Indicates that the payment failed for a reason (returned by the gateway).
  • Processing – Status name after a successful payment. The stock is reduced and the order is ready to be fulfilled. If the product is virtual and downloadable, this status is skipped and the resulting status is ‘Completed’.
  • Completed – After you fulfilled the order, you must change it manually to ‘Completed’.
  • On hold – The payment is not fully confirmed in the gateway. Sometimes the gateway need further analysis to approve the payment. In this case, the stock is reduced.
  • Canceled – Indicates that the admin or the customer canceled the order . Subsequently, the stock amount is restored. 
  • Refunded – When the store admin refunds the customer by using the gateway dashboard or the WC order admin.
  • Authentication required – It is a request for Multi-factor authentication in the payment. Customer action is needed to authorize the transaction.

How does it work?

Every time a customer buy a product or service in your WooCommerce store, a new order is created with an initial status of pending payment.

When a user pays an order, the order status will change from pending to processing. Meanwhile, the order status  change triggers an email to the store admin, informing to prepare the products delivery.

After the delivery, the fulfillment process has finished. Consequently, the store admin can update the status to ‘Complete’ manually in the WooCommerce Orders Admin Dashboard.

Custom Order Status for WooCommerce

What if you want to change a status name or add a new one to better suit your order fulfillment workflow?

And what about the most missed ‘shipped’ order status, which indicates that you’ve sent the products to the customer? It would be very useful if the customer could receive a notification with a tracking information.

In these situations, you may find yourself stuck. To move on, you must write some code or install a plugin to handle this for you.

WPPDEV WooCommerce Order Status Manager

Using the WPPDEV WooCommerce Order Status Manager plugin, you will able to:

  • Change the name of any status;
  • Add new status;
  • Create e-mail alerts when an order changes status;
  • Change the color and add an icon to each status to visually manage your orders;
  • Generate a graph of status changes to understand your workflow.
Plugin's Dashboard to manage order status

Plugin’s Dashboard to manage order status

Download WooCommerce Order Status plugin for free.

Woocommerce Change order status programmatically

If you’re a DIY guy or gal, you can achieve basic management using some code in your theme’s functions.php file.

Add new order status

Firstly you need to register a new post status to make it available for use in woo order status, using the code snipped below.

In the code, change the variables $slug and $name to the status name and slug you want. In the example, we are registering the shipping status.


function register_woo_order_status() {
  $slug = 'wc-shipping';
  $name = 'Shipping';
  $config = [
    'public' => true,
    'exclude_from_search' => false,
    'show_in_admin_all_list' => true,
    'show_in_admin_status_list' => true,
    'label' => $name,
  ];
  register_post_status( $slug, $config );
}
add_action( 'init', 'register_woo_order_status' );

Secondly, we can inject the post status it in the WooCommerce using a specific filter hook:


function add_wc_order_statuses( $order_statuses ) {
  $slug = 'wc-shipping';
  $name = 'Shipping';
  $order_statuses[ $slug ] = $name;
  return $order_statuses;
}
add_action( 'wc_order_statuses', 'add_wc_order_statuses' );

How to Remove a Status

Remove an order status using the same filter hook ‘wc_order_statuses’, and unsetting the undesired status.

In this case, It is not recommended to remove a core status because it will break the plugin. But you can remove a custom one if there are no orders with this status. Change the existing orders using the status to another one before removing.


function add_wc_order_statuses( $order_statuses ) {
  $slug = 'wc-shipping';
  if( isset( $order_statuses[ $slug ] ) ) {
    unset( $order_statuses[ $slug ] );
  }
  return $order_statuses;
}
add_action( 'wc_order_statuses', 'add_wc_order_statuses' );

WooCommerce Order Status Control

Once the order is placed, status are controlled automatically depending on the events that the WooCommerce receives.

When a customer pays using a gateway, it notifies the WooCommerce to update the order status. PayPal and Stripe are some examples of gateways that can notify your store after some configuration.

However, there are times you may want to change it. Each e-commerce store is different and you want to customize it.

WooCommerce Change Order Status Programmatically

You may want to change the incoming orders status to a new order status named “Awaiting Shipping”. To achieve this, you need to hook into ‘woocommerce_thankyou’ action using the code below:


function change_wc_order_status( $order_id ) {
  if ( ! empty(  $order_id ) ) {
    $slug = 'wc-awaiting-shipping'; //the existing wc order status you want to change to
    $order = wc_get_order( $order_id );
    if( 'processing'== $order->get_status() ) {
      $order->update_status( $slug );
    }
  }
}
add_action( 'woocommerce_thankyou', 'change_wc_order_status' );

Conclusion

The WooCommerce Order Status is an essential part of the plugin, which represents the state of an order. Some actions can change the order state, like the payment processed by the gateway, or a manual update to reflect the end of the fulfillment workflow.

In addition, the WooCommerce plugin comes with a set of default statuses, which do not suit every store fulfilling process. You can easily change it using the codes above, or even using a plugin that does this for you.