PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, May 15, 2022

[FIXED] How to remove bulk actions from admin orders page

 May 15, 2022     php, woocommerce, wordpress     No comments   

Issue

I'm trying to remove all default bulk actions from the admin's orders page with the following code:

add_filter( 'bulk_actions-edit-shop_order', 'remove_order_statuses_bulk' );
function remove_order_statuses_bulk ( $bulk_actions ) {
    error_log( print_r( $bulk_actions, true ) );

    $unwanted_actions = array( "mark_processing", "mark_pending", "mark_on-hold", "mark_completed", "mark_cancelled", "mark_refunded", "mark_failed" );

    foreach ( $unwanted_actions as $action ) {
        if ( isset( $bulk_actions[$action] ) ) {
            unset( $bulk_actions[$action] );
        }
    }

    return $bulk_actions;
}

The error_log shows the array containing just "edit", "trash" and "mark_custom-status" (which is a status that I've created using the same hook). So the array is already empty.

The problem is that the menu with bulk actions in wp-admin/edit.php?post_type=shop_order is still showing the removed entries.

I have no caching plugin at present. What may be causing this?


Solution

Your function is being called too early since you don't have a priority set.

Change the priority of your add_filter and it works.

add_filter( 'bulk_actions-edit-shop_order', 'remove_order_statuses_bulk', 40, 1 );


Answered By - Howard E
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing