39
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 tutoraspire.com FREE
* @author Tutor Aspire
* @compatible WooCommerce 6
* @donate $9 https://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;
}