Menu Close

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

default

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 CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 7
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

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;
}
View Source
Posted in WooCommerce Tips