Headless commerce and custom storefronts with Shopify APIs and SDKs
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?
Try this
let query = {
query: "priceRange:minVariantPrice > 20 AND maxVariantPrice < 40"
}
client.product.fetchQuery(query).then((products) => {
console.log(products)
})
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
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022