Inspired by the thread ‘Hiding order status in My Account recent orders list page’
I tried to hide orders with status (Pending Payment) on the ‘My Account’ page.
I modified the code slightly, but I can’t get it to work.
add_filter('woocommerce_my_account_my_orders_actions', 'custom_removing_order_status_pending_payment', 10, 1);
function custom_removing_order_status_pending_payment( $order ){
unset($order['wc-pending']);
return $order;
}
I really appreciate any help. Thank you.
2
Answers
Right now you are using the
woocommerce_my_account_my_orders_actions
filter which will let you filter the buttons in the ‘Action’ column on the ‘My Account’ page.If you want to filter out certain order statuses from the order list you will have to use the
woocommerce_my_account_my_orders_query
filter.The accepted answer is mostly, OK, however, it relies on WooCommerce saving Orders as a WordPress custom post type, and there’s been for a while a conversation about moving orders to their own custom table to improve performance and scalability of WooCommerce-powered stores.
As a general rule, it is better to use WooCommerce’s specific methods and parameters.
The filter
woocommerce_my_account_my_orders_query
uses wc_get_orders which says to use'status'
as parameter, and not'post_status'
The updated answer using WC_Order_Query would be