Not able to fetch variation sales product according to particular product category . My code fetch only simple products not variable products.
$cat_id = $_GET['catid'];
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' =>-1,
'meta_query' => array(
'relation' => 'OR',
array( // Variable products type
'key' => '_min_variation_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'numeric'
),
array( // Simple products type
'key' => '_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'numeric'
)
),
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id', //This is optional, as it defaults to 'term_id'
'terms' => $cat_id,
'include_children' => true,
'operator' => 'IN' // Possible values are 'IN', 'NOT IN', 'AND'.
)
)
);
$products = new WP_Query($args);