Support » Plugin: WooCommerce » Hide “edit.php?post_status=wc-completed&post_type=shop_order” in Woocommerce

  • Resolved samengland

    (@samengland)


    I have tried without success to hide from people in our office that does not have admin privileges the edit.php?post_status=wc-completed&post_type=shop_order from the orders page in Woocommerce.

    I have attached a snap shot of the section that I am wanting to hide:

    Orders Completed and cancelled:

    https://i.stack.imgur.com/ouhbB.png1

    Any help would be greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @samengland,

    Thank you for sharing the screenshot.

    You can copy below code snippet and paste it in your currently active theme’s functions.php file to remove “Completed” and “Cancelled” filters from Orders page of WooCommerce for users who doesn’t have manage_options privileges.

    Code Snippet:

    add_filter( 'views_edit-shop_order', function( $views )
    {
    
    	if( current_user_can( 'manage_options' ) )
            return $views;
    
        $remove_views = [ 'wc-completed','wc-cancelled' ]; // 
    
        foreach( (array) $remove_views as $view )
        {
            if( isset( $views[$view] ) )
                unset( $views[$view] );
        }
        return $views;
    } );

    Please let me know if that works for you or not.

    Regards,
    Kartik Parmar

    Yes…Yes…Yes… that worked perfectly…THANK YOU SO MUCH…

    I would also like to hide the “ALL” section…is this possible?

    I have attached picture.

    https://imgur.com/a/yi0o05h

    Plugin Support Luminus

    (@luminus)

    Automattic Happiness Engineer

    Hi @samengland,

    If you add 'all' to the $remove_views array, you’ll be all set.

    Cheers.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.