
How to add Custom Order Status in WooCommerce
- January 7, 2016
- Leave a comment
WooCommerce provides some custom order statuses but these might not fulfill the need of your online store or violate your business rationale. You can simply include another custom order status in WooCommerce to make it work with your e-store and adjust to your business logic perfectly.
Here is a list of the default order statuses provided by WooCommerce:
- Completed
- Processing
- Pending payment
- On hold
- Refunded
- Canceled
- Failed
You can add a new one, for instance “Awaiting Shipment” by adding the following code in your Theme’s functions.php or Child Theme’s functions.php file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
/** * PressTigers WooCommerce Tutorials - Register new order status **/ function pt_register_awaiting_shipment_order_status() { register_post_status( 'wc-awaiting-shipment', array( 'label' => 'Awaiting shipment', 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop( 'Awaiting shipment <mark>(%s)</mark>', 'Awaiting shipment <mark>(%s)</mark>' ) ) ); } add_action( 'init', 'pt_register_awaiting_shipment_order_status' ); // Add to list of WC Order statuses function pt_add_awaiting_shipment_to_order_statuses( $order_statuses ) { $new_order_statuses = array(); // add new order status after processing foreach ( $order_statuses as $key => $status ) { $new_order_statuses[ $key ] = $status; if ( 'wc-processing' === $key ) { $new_order_statuses['wc-awaiting-shipment'] = 'Awaiting shipment'; } } return $new_order_statuses; } add_filter( 'wc_order_statuses', 'pt_add_awaiting_shipment_to_order_statuses' ); |
Now save your functions.php file and open any order that you want to modify. You will see the following order statuses now:
- Completed
- Processing
- Pending payment
- On hold
- Refunded
- Canceled
- Failed
- Awaiting shipment
You can change the name of this label by modifying the code above.
User Comments