[ad_1]
Hello @katmacau,
As you mentioned, wc_get_products() only works for a single quantity, but not a range. To get the IDs of all products that have a stock between 1 and 30, you could use the following query:
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_stock',
'value' => array( 1, 30 ),
'compare' => 'BETWEEN',
),
),
'fields' => 'ids'
);
$products = new WP_Query( $args );
$product_ids = $products->posts;
