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.
Advertisement
Answer
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.
add_filter( 'woocommerce_my_account_my_orders_query', 'unset_pending_payment_orders_from_my_account', 10, 1 ); function unset_pending_payment_orders_from_my_account( $args ) { $statuses = wc_get_order_statuses(); unset( $statuses['wc-pending'] ); $args['post_status'] = array_keys( $statuses ); return $args; }