Create a New WooCommerce Order Status without a Plugin
The free WordPress eCommerce plugin, WooCommerce, includes a few different “order statuses“.
These are important as they inform your clients and customers in what stage their particular order is at. These order statuses help prevent unnecessary phone calls and/or emails from said customers inquiring about the status of their order. Granted you will always have that one person who will contact you regardless. At least these will help keep the majority from reaching out to you saving you and your online business much time.
Built-in WooCommerce Order Statuses
Here is the default order status list built into WooCommerce:
- Completed
- Processing
- Pending payment
- On hold
- Refunded
- Cancelled
- Failed
Some online stores may want to provide their customers with more specific order fulfillment statuses. For example, an online manufacturer may want to provide their customers with the ability to see that they are “Awaiting parts“, in the “Building” process, “Shipped“, and so on and so forth.
Within this article we will show you how to easily add these custom order statuses to your WordPress website without the use of a plugin.
Adding a Custom WooCommerce Order Status
The code below should be added to your functions.php
file within your WordPress websites’ main child theme.
This code will create a new order status called “Shipped” within your WooCommerce online store. Use this code as a template to create any others you need.
/**
* WooCommerce New Order Statuses
**/
add_action( 'init', 'register_brethren_order_statuses' );
function register_brethren_order_statuses()
{
register_post_status( 'wc-shipped', array(
'label' => 'Shipped',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>' )
) );
// Continue...
}
// Add Status to WooCommerce Status List
add_filter( 'wc_order_statuses', 'add_brethren_order_statuses' );
function add_brethren_order_statuses( $order_statuses )
{
$new_order_statuses = array();
// Add New Status After Processing
foreach ( $order_statuses as $key => $status )
{
$new_order_statuses[ $key ] = $status;
if ( 'wc-processing' === $key )
{
$new_order_statuses['wc-shipped'] = 'Shipped';
// Continue...
}
}
return $new_order_statuses;
}
We hope this article and the above code has helped you create any necessary custom order statuses for your WooCommerce powered store. If this was helpful, please like us on Facebook, share this on your social media or buy us a cup of coffee.