WordPress Hosting Coupon Code |3 Months | 100% OFF Avail NOW!

How to Add/Set Custom Order Status in WooCommerce Stores

WPblog — February 16, 2018 2 Minutes Read

Orders at a WooCommerce go through several stages from the initial placement to final fulfillment. In order to simplify order tracking, WooCommerce offers several order statuses to make sense of the flow of orders. At the moment, WooCommerce offers the following seven statuses:

  • Completed
  • Processing
  • Pending payment
  • On hold
  • Refunded
  • Cancelled
  • Failed

All these statuses trigger actions that define the store’s business logic for a particular status. You could provide custom code for each status to carry out actions that conform to the store’s policies.

The good thing is that you could define custom order statuses as well and then add custom code so that the store could take the action in response to the selection of the custom status. To demonstrate the process, I will add a custom order status “Shipping In Progress”.

The following code snippets take care of the process. Remember that these snippet will go into functions.php file located in the theme folder.:

Register New Order Status

Add New Order Statuses to WooCommerce

Here’s how the custom order status would look in action:

Code Explanation

The order status that you’re registering through wc-shipping-progress is too long (-22). This will save the first 20 characters of the post status, which makes it invalid and causes errors.

The order statuses are registered as post statuses with a limit of 20 characters. wc-shipping-progress ensures that the limit remains at exactly 20 characters in length.

The wpblog_wc_add_order_statuses() function adds the new custom post status (also known as order status) into the list of available order statuses within the WooCommerce Orders and Edit Orders pages.

Create Faster WordPress Websites!

Free eBook on WordPress Performance right in your inbox.


Create Faster WordPress Websites!

Free eBook on WordPress Performance right in your inbox.

Moeez is ‘The’ blogger in charge of WPblog. He loves to interact and learn about WordPress with people in the WordPress community. Outside his work life, Moeez spends time hanging out with his friends, playing Xbox and watching football on the weekends. You can get in touch with him at moeez[at]wpblog.com.

THERE'S MORE TO READ

Newsletter

WP HelpZone - Ultimate WordPress Pit-Stop

Learning WordPress? Or are you expert enough to help others? Join our WP Facebook group!