please help me. I cant use meta_query to filter products with a price range
if ( ! empty( $data['price_range'] ) ) {
$price_range = explode( '|', esc_attr($data['price_range']) );
if ( is_array($price_range) && count($price_range) == 2 ) {
$args['meta_query'][] = array(
'key' => '_price',
'value' => array(reset($price_range), end($price_range)),
'compare' => 'BETWEEN',
'type' => 'NUMERIC'
);
}
}
$products = wc_get_products( $args );
and this for final "$args" value
[meta_query] => Array
(
[0] => Array
(
[key] => _price
[value] => Array
(
[0] => 6.28
[1] => 6.56
)
[compare] => BETWEEN
[type] => NUMERIC
)
)
other "$args" value is [post_status] => publish [post_type] => Array ( [0] => product [1] => product_variation )
thanks for your help before