Return management just got easier! We’ve launched Customer Self-Serve Returns to all Shopify merchants. Click here to learn more!

BuySDK minVariantPrice and maxVariantPrice return products outside selected price range?

fozweb
New Member
3 0 0

I am building an application using the Shopify Buy SDK, and I am trying to query products by their minVariantPrice, and their maxVariantPrice, and I am certain I have the code correct.  In this instance, I am using React and Redux, and sending the request via the Buy SDK client as such:

 client.product.fetchQuery({ priceRange:{minVariantPrice:20 AND maxVariantPrice:40} });

For the most part this works, but I will often get products back that do not fall in that price range.  I will then go through these products on my Shopify dashboard, and I won't find any variants for these products listed that match that price range. 

Does anyone have any idea why this is happening?  Is there something I'm missing on the dashboard side, like something telling the api I have variants that match those prices?  Should I take a deeper look at the query/code?  Or is this something happening on Shopify's end?

Replies 2 (2)
michaeltheodore
Explorer
59 6 9

Try this

let query = {
  query: "priceRange:minVariantPrice > 20 AND maxVariantPrice < 40"
}
client.product.fetchQuery(query).then((products) => {
  console.log(products)
})

 

fozweb
New Member
3 0 0

Thanks for the reply Michael.

 

Strangely, the query won't work with the greater-than and less-than symbols for me, but works with colons :

minVariantPrice:20 AND maxVariantPrice:40

^but that still includes the odd products without a matching price in that range