WooCommerce -How to add Custom Order Status to your WordPress WooCommerce eCommerce website - WooCommerce PHP

 /**

* Register new statuses - add an array for each status * code created by https://thiarara.co.ke * youtube tutorial: thiarara **/ function register_new_wc_order_statuses() { 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 (%s)', 'Awaiting shipment (%s)' ) ) ); register_post_status( 'wc-packing', array( 'label' => 'Packing', 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop( 'Packing (%s)', 'Packing (%s)' ) ) ); // repeat register_post_status() for each new status } add_action( 'init', 'register_new_wc_order_statuses' ); // Add new statuses to list of WC Order statuses function add_new_wc_statuses_to_order_statuses( $order_statuses ) { $new_order_statuses = array(); // add new order statuses 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'; $new_order_statuses['wc-packing'] = 'Packing'; // Add a $new_order_statuses[key] = value; for each status you've added (in the order you want) } } return $new_order_statuses; } add_filter( 'wc_order_statuses', 'add_new_wc_statuses_to_order_statuses' );





Comments