This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

This holiday season, maximize your sales through enhanced website performance and 24/7 caring support. SAVE 30% NOW

How To Create WooCommerce Custom Order Status

Updated on  11th April

3 Min Read
custom WooCommerce order status
Reading Time: 3 minutes

In this article, I will demonstrate how you could add custom WooCommerce order status actions. The intent here is to show how you could modify order data, add information to orders, export order data externally, or run any general action that requires order details.

Another important thing in this context is that these statuses trigger further actions. You need to provide WooCommerce code for these actions. In many instances, this code is custom written as a response for particular statuses.

Custom WooCommerce Order Status

  • Payment Pending
  • Processing
  • On Hold
  • Completed
  • Cancelled
  • Refunded
  • Failed

WooCommerce Order status

WooCommerce has changed the order structure to support partial and automatic refunds from the WooCommerce admin. Order statuses are now saved as a custom post status, just like the draft, scheduled, or published for posts.

Adding a custom post status now requires a bit more code than it did before. However, the process is more streamlined now from the developer’s perspective.

Addition of Custom WooCommerce Order Status

Some shops require customized order statuses such as Awaiting shipment, Building. These statuses are essential for their unique business requirements. Fortunately, adding these statutes is easy and require just a tiny bit of custom code.

Custom Order Status Shipment Arrival

I added the post status using the WordPress register_post_status() function. Notice that the first thing in this function is the slug for the order status, prefixed by “wc-” for WooCommerce.

I then created an array, that contains the data that defines the custom post status. The label is what will be displayed, so I can change it to the exact name of the order status.

The add_awaiting_shipment_to_order_statuses() function is going to add this new custom post status into the list of available order statuses within the WooCommerce Orders and Edit Orders pages. These statuses are then available for use on these pages.

The foreach loop here goes through the list of current order statuses until it finds the one I want. In this case, I am going to insert Shipment Arrival after Processing order status. That is what the if() part is doing here – I say, “If the order status is ‘processing’, add in Shipment Arrival here, then continue going through order statuses.”

woocommerce order status plugin

Conclusion

In this tutorial, I discussed how to change the order structure of WooCommerce so that I could use custom order status on my WooCommerce store. If you need help with the idea or would like to add to the discussion, do leave a comment below.

Share your opinion in the comment section. COMMENT NOW

Owais Alam

is the WordPress Community Manager at Cloudways - A Managed WooCommerce Hosting Platform and a seasoned PHP developer. He loves to develop all sorts of websites on WordPress and is in love with WooCommerce in particular. You can email him at owais.alam@cloudways.com

Start Growing with Cloudways Today.

Our Clients Love us because we never compromise on these

Get Our Newsletter
Be the first to get the latest updates and tutorials.

THERE’S MORE TO READ.