I have some events that are zero cost (free). But they are getting my orders page really full and confusing.
Now in WooCommmerce orders admin panel, I want to hide all orders which have 0 as Price.
Is there any hook or filter function available to achieve this?
答案 0 :(得分:0)
您可以使用
parse_query
过滤器删除免费订购$pagenow
全局变量。
add_filter('parse_query', 'wh_alterAdminPostList');
function wh_alterAdminPostList($query)
{
global $pagenow;
if (is_admin() && $pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'shop_order')
{
$query->query_vars['meta_query'] = [
[
'key' => '_order_total',
'value' => 0.00,
'compare' => '>',
'type' => 'DECIMAL',
]
];
}
}
代码进入活动子主题(或主题)的function.php文件。或者也可以在任何插件php文件中。
代码已经过测试并且有效。
希望这有帮助!