Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Show Custom Order Status in Bulk Actions on WooCommerce Orders Page (Compatible with HPOS Order Tables)?

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.

How to Show Custom Order Status in Bulk Actions on WooCommerce Orders Page (Compatible with HPOS Order Tables)? - Tyche Softwares

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?

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
2 Comments
Newest
Oldest
Inline Feedbacks
View all comments
Visitor
4 months ago

Thank you, copy-pasted this and it worked..

2
0
Would love your thoughts, please comment.x
()
x