phpwordpresswoocommerceordersbulkupdate

Hide bulk actions from admin orders list except for processing status filtered list


Is there any way to hide bulk actions from admin orders list except for processing status filtered list: post_status=wc-processing where I only want to show bulk actions?

I tried to use code from How to remove bulk actions from admin orders page, but it hides bulk actions from all orders lists.

What I want is to show bulk actions only for Processing status filtered list. Is it possible?


Solution

  • Simply use the following to only show bulk actions on "Processing" status orders list:

    add_filter( 'bulk_actions-edit-shop_order', 'bulk_actions_only_on_processing_orders_list', 100 );
    function bulk_actions_only_on_processing_orders_list( $bulk_actions ) {
        if( ! (isset($_GET['post_status']) && $_GET['post_status'] === 'wc-processing') ) {
            $bulk_actions = array();
        }
        return $bulk_actions;
    }
    

    Code goes in functions.php file of your child theme (or in a plugin file). Tested and works.