Custom Bulk Action
-
Hi,
when I use WooCommerce with WordPress posts table I can use this code to add option in bulk actions:
add_filter( 'bulk_actions-edit-shop_order', function ( $bulk_actions ) { $bulk_actions['example'] = 'Example action'; return $bulk_actions; } );and second to handle the action:
add_filter( 'handle_bulk_actions-edit-shop_order', function ( $redirect_to, $do_action, $post_ids ) { if ( $do_action === 'example' ) { wp_die( 'Works!' ); } return $redirect_to; }, 10, 3 );But for WooCommerce orders tables the above code doesn’t works.
If I want add option to bulk action I can use the code:
add_filter( 'bulk_actions-woocommerce_page_wc-orders', function ( $bulk_actions ) { $bulk_actions['example'] = 'Example action'; return $bulk_actions; } );but not exists action / filter like ‘handle_bulk_actions-edit-shop_order’ to run custom actions.
I think that should exists filter in woocommerce/src/Internal/Admin/Orders/ListTable.php:909 like:
else { $redirect_to = apply_filters( 'handle_bulk_actions-orders', $redirect_to, $action, $ids ); }Great idea for backwards compatibility add:
apply_filters_deprecated('bulk_actions-edit-shop_order')andapply_filters_deprecated('handle_bulk_actions-edit-shop_order')WordPress: 6.1-beta3-54415
WooCommerce: 7.0.0`
The topic ‘Custom Bulk Action’ is closed to new replies.