灵感来自线程'Hiding order status in My Account recent orders list page' 我试图在“我的帐户”页面上隐藏状态为(待付款)的订单。
我稍微修改了代码,但我无法让它工作。
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;
}
非常感谢任何帮助。谢谢。
最佳答案
现在您正在使用 woocommerce_my_account_my_orders_actions
过滤器,它可以让您过滤“我的帐户”页面上“操作”列中的按钮。
如果您想从订单列表中过滤掉某些订单状态,您必须使用 woocommerce_my_account_my_orders_query
过滤器。
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;
}
关于php - 在 WooCommerce 我的帐户页面上隐藏状态为(待付款)的订单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64155814/