Whether you have set up a custom order status plugin or used code snippets to create a custom order status, it is common to deactivate the plugin or delete custom order statuses. Based on your products/services if you have created multiple custom order statuses and when you want to delete them, doing it manually is a tedious task. With custom coding you can delete these unused custom order statuses.
Solution: Delete Custom Order Statuses
The code snippet below will delete certain unused or obsolete statuses that is no longer needed.
add_filter( 'wc_order_statuses', 'ts_add_outofstock_order_statuses' ); function ts_remove_order_status( $statuses ) { if( isset( $statuses['wc-outofstock'] ) ){ unset( $statuses['wc-outofstock'] ); } return $statuses; } add_filter( 'wc_order_statuses', 'ts_remove_order_status', 10);
Output
Let’s say for example, if you have created a custom order status called “Out of Stock” to track orders that are temporarily not available. But when the products are restocked or when you don’t want this status in the order stages of the fulfillment process, you can use the above code snippet and delete it. I have created a custom order status such as ‘Out Of Stock’ as shown in the image given below.
The code will delete the status ‘Out of Stock’ from the list of available order statuses.
Alternatively, once the payment is done for all orders in one go, you can automatically complete order in WooCommerce when they go to the processing status.