If you’re running a WooCommerce store, you’ve probably noticed that the default order status options are a bit limited. By default, WooCommerce only offers four order statuses: Pending, Processing, On Hold, and Completed.
While these statuses are suitable for most stores, you might find that you need more options to better manage your orders.
Fortunately, WooCommerce makes it easy to customize your order statuses. In this article, we’ll show you how to add custom order statuses in WooCommerce and how to set them up so they work the way you want them to.
Before You Start
Before we dive into the tutorial, there are a few things you need to know about customizing order statuses in WooCommerce. First, you should know that adding custom order statuses is a fairly advanced topic.
If you’re not comfortable working with code, then we recommend working with a developer or hiring one from our directory.
Second, it’s important to understand that custom order statuses are not the same as post statuses. By default, WordPress uses post statuses to manage the lifecycle of content on your site (e.g., published, draft, etc.).
WooCommerce uses a similar system for managing orders.
However, post statuses and order statuses are not interchangeable. You can’t use a post status for an order or vice versa. If you try to do so, things will break.
With that said, let’s take a look at how to add custom order statuses in WooCommerce.
Adding Custom Order Statuses in WooCommerce
WooCommerce makes it easy to add custom order statuses. To do so, simply add the following code snippet to your site’s functions.php file:
function register_new_order_statuses() {
register_post_status( 'wc-awesome', array(
'label' => _x( 'Awesome', 'Order status', 'textdomain' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true, ) ); }
This code registers a new order status called “Awesome.” Of course, you can change this label to anything you want.
Note: You can register multiple custom order statuses by adding additional register_post_status() calls for each one.
Now that you’ve registered your custom order status, it’s time to set it up so it works the way you want it to.
When configuring a custom order status in WooCommerce, there are two important settings to consider: label and public.
The “label” setting determines how the custom status is displayed throughout the WooCommerce interface, for example, the default “Pending” status label is displayed as “Pending Payment” in various places throughout the interface.
The “public” setting controls whether or not the custom status is displayed on the front-end of your site. By default, this setting is set to “true” which means the custom status will be displayed on the front-end of your store.
Once you have added and configured a custom order status label in WooCommerce, you can automate the process using actions and filters. WordPress actions allow you to programmatically trigger certain events based on certain conditions. For example, you can automatically assign all new orders with a $0 total amount (i.e. free shipping) as pending payment. To do this, you would add code like this to your site’s functions.php file:
function wc_zero_total() {
if ( ! $order->get_total() ) {
$order->update_status( 'wc-awesome' );
}
}
add_action('woocommerce_place_order', 'wc_zero_total');
In summary, you can configure custom order status in WooCommerce by setting the label and public settings, and automate the process by using actions and filters.