I’ve built a custom WooCommerce plugin to allow bulk printing of shipping labels from the Orders page. However, the custom bulk action I've added (Print Shipping Labels) does not appear in the Bulk Actions dropdown on the WooCommerce > Orders admin page.
I've added the bulk action using the bulk_actions-edit-shop_order filter:
add_filter( 'bulk_actions-edit-shop_order', [ $this, 'add_bulk_actions_to_orders' ] );
public function add_bulk_actions_to_orders( $actions ) {
$actions['wsplp_print_shipping_labels'] = __( 'Print Shipping Labels', 'wsplp' );
return $actions;
}
Also using handle_bulk_actions-edit-shop_order for handling:
add_filter( 'handle_bulk_actions-edit-shop_order', [ $this, 'handle_bulk_print_labels' ], 10, 3 );
The hooks are called inside a class WSPLP_Admin, and I call $admin->run(); from the main plugin file to initialize the hooks.
The current logged-in user has full admin rights, including manage_woocommerce.
Plugin is active and visible in the WP admin panel. Everything else works fine.
I've tried:
Tested on a clean WordPress site (latest version, WooCommerce latest).
No other plugins are active (to rule out conflicts).
Theme is the default Twenty Twenty-Four.
Checked browser console – no JS errors.
Verified that add_bulk_actions_to_orders() is called using error_log().
Despite all this, "Print Shipping Labels" is not showing up in the Bulk Actions dropdown on the WooCommerce Orders page. I expected it to show alongside the default actions like “Move to Trash”.
Is there anything wrong in my use of the bulk_actions-edit-shop_order filter?
Does WooCommerce override or delay the loading of these bulk actions in a way I need to adjust for?
Is there a better hook or method for injecting bulk actions into WooCommerce Orders admin?
The issue you are facing is because High-Performance Order Storage (HPOS) is now enabled by default since few years, the hooks you are using only work with legacy WordPress Post storage.
In the class constructor function, you need to replace:
add_filter( 'bulk_actions-edit-shop_order', [ $this, 'add_bulk_actions_to_orders' ] );
add_filter( 'handle_bulk_actions-edit-shop_order', [ $this, 'handle_bulk_print_labels' ], 10, 3 );
with:
add_filter( 'bulk_actions-woocommerce_page_wc-orders', [ $this, 'add_bulk_actions_to_orders' ] );
add_filter( 'handle_bulk_actions-woocommerce_page_wc-orders', [ $this, 'handle_bulk_print_labels' ], 10, 3 );
It should work.