Customizing order statuses
WooCommerce uses order statuses to track the state of orders. WooCommerce includes several different order statuses, including the following:
Completed
Processing
Pending payment
On hold
Refunded
Canceled
Failed
But some shops may need more order statuses. You might need a Building status to indicate that you started building the order. You can easily add a custom order status yourself with some custom code. We’re going to start with our WooCommerce example plugin and then we’re going to register a post status and add it to WooCommerce.
Using the WooCommerce example plugin
We can start by using the example plugin we created earlier in this chapter.
We’ll copy the example code, and then we should change the name of the class from WC_Example
to WC_Building_Order_Status
, since this describes what this plugin will do. Here’s the code:
// only run if there's no other class with...