The customer’s WooCommerce My Account Orders page displays all their orders, no matter the “status” (completed, processing, on-hold, pending, etc.).
It may happen that you, as a WooCommerce store manager, need to hide certain orders, for example the “on-hold” ones, or all orders with a custom order status.
Thankfully, this is very easy with a few lines of PHP. Enjoy!
PHP Snippet: Hide Specific Order Status @ My Account Orders Page
/**
* @snippet Hide Orders @ WooCommerce My Account
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 7
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_my_account_my_orders_query', 'bbloomer_exclude_status', 9999 );
function bbloomer_exclude_status( $args ) {
$statuses = wc_get_order_statuses();
unset( $statuses['wc-on-hold'] ); // wc-completed, wc-processing, etc.
$args['status'] = array_keys( $statuses );
return $args;
}
And to use this on the Admin Orders pages to temporarily hide orders cancelled and completed..
Ideal if we could also put a tick up top to be able to de-activate it too..
Hello Ivan, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Error on code:
add_filter( ‘woocommerce_my_account_my_orders_query’, ‘bbloomer_exclude_status, 9999 );
must be
add_filter( ‘woocommerce_my_account_my_orders_query’, ‘bbloomer_exclude_status’, 9999 );
Thanks a lot, fixed!