问题
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?
回答1:
You can remove Free order it by using parse_query filter with
$pagenow
global variable.
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',
]
];
}
}
Code goes in function.php file of your active child theme (or theme). Or also in any plugin php files.
Code is tested and works.
Hope this helps!
来源:https://stackoverflow.com/questions/42567994/hide-free-orders-in-woocommerce-orders-section-from-admin-panel