php - 在 WooCommerce 我的帐户页面上隐藏状态为(待付款)的订单

标签 php wordpress woocommerce

灵感来自线程'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/

相关文章:

php - 如何仅为自定义产品类型定义字段 - Woo Commerce Hook

php - cakephp 控制台应用程序中的多个数据库

php - 将参数从 C++ 传递到 PHP

html - 鼠标悬停 CSS 问题(CSS 之后应用不透明度)

linux - 在 Amazon EC2 (Amazon Linux) 上设置 WordPress 权限

php - 基于 Woocommerce 3 中的数量的购物车商品折扣

php - 使用 cookie 限制访问

javascript - 在php中确认后隐藏按钮

css - 如何识别 CSS 中的导航栏颜色

wordpress - 有什么方法可以覆盖我的functions.php 中的get_stock_quantity?