Ever wanted to extend the functionality of showing the custom status in ‘Edit Orders’ page and making it easily accessible in the bulk actions menu as well? Look no further! With this code snippet, you can integrate your custom order status, such as ‘Shipped’, into the bulk actions of the WooCommerce Orders page.
Solution: Show Custom Order Status in Bulk Actions Dropdown
This code will display the custom status in the bulk actions dropdown even if your store is enabled for HPOS or Custom Order Tables.
add_filter( 'woocommerce_register_shop_order_post_statuses', 'ts_register_custom_order_status' ); function ts_register_custom_order_status( $order_statuses ) { // Status must start with "wc-"! $order_statuses['wc-shipped'] = array( 'label' => 'Shipped', 'public' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>', 'woocommerce' ), ); return $order_statuses; } add_filter( 'wc_order_statuses', 'ts_show_custom_order_status_single_order_dropdown' ); function ts_show_custom_order_status_single_order_dropdown( $order_statuses ) { $order_statuses['wc-shipped'] = 'Shipped'; return $order_statuses; } // Adding custom status to admin order list bulk actions dropdown function ts_custom_dropdown_bulk_actions_shop_order( $actions ) { $new_actions = array(); // Add new custom order status after processing foreach ($actions as $key => $action) { $new_actions[$key] = $action; if ('mark_processing' === $key) { $new_actions['mark_shipped'] = __( 'Change status to shipped', 'woocommerce' ); } } return $new_actions; } add_filter( 'bulk_actions-woocommerce_page_wc-orders', 'ts_custom_dropdown_bulk_actions_shop_order', 20, 1 ); add_filter( 'handle_bulk_actions-woocommerce_page_wc-orders', 'ts_custom_dropdown_bulk_actions_shop_order', 20, 1 );
Output
The code will create a custom status ‘shipped’ and the status will be shown on both ‘edit orders’ dropdown and ‘Bulk actions ‘ dropdown. When the user selects the option ‘Change status to shipped’ from the bulk actions menu and applies it, the chosen status updates are reflected in the status column of the orders table.
As a store owner, you can find the dropdown options useful to filter custom statuses quickly. However, internal statuses like ‘Shipped’ don’t need to appear on the customer’s account page. In such cases, you can also Hide Order Status Column from My Account > Orders Page?
Thank you, copy-pasted this and it worked..
Hi,
You’re welcome! Glad to know that it worked for you.