Home » WooCommerce: Hide Specific Orders (e.g. On Hold) From My Account Orders Page

WooCommerce: Hide Specific Orders (e.g. On Hold) From My Account Orders Page

by adminkys

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!

In this example, I’d like to hide all “On hold” orders from the customer My Account page

PHP Snippet: Hide Specific Order Status @ My Account Orders Page

/**
 * @snippet       Hide Orders @ WooCommerce My Account
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://www.tutoraspire.com
 */

add_filter( 'woocommerce_my_account_my_orders_query', 'tutoraspire_exclude_status, 9999 );

function tutoraspire_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;
}

You may also like