compareAtPriceRange does not work

Highlighted
Shopify Expert
3 0 1

I can easily find the pricerange and some other product informations with this query :

    const params = {
      query :  `query {
        products(first: 250, query: "` + query + `") {
          edges {
            node {
              id
              title
              handle
              onlineStoreUrl
              tags
              priceRange {
                maxVariantPrice {
                  amount
                  currencyCode
                }
                minVariantPrice {
                  amount
                  currencyCode
                }
              }
              images (first:1) {
                edges {
                  node {
                    originalSrc
                    altText
                  }
                }
              }
            }
          }
        }
      }`
    };

 
But if I add the compareAtPriceRange according to the documentation like this :

    const params = {
      query :  `query {
        products(first: 250, query: "` + query + `") {
          edges {
            node {
              id
              title
              handle
              onlineStoreUrl
              tags
              priceRange {
                maxVariantPrice {
                  amount
                  currencyCode
                }
                minVariantPrice {
                  amount
                  currencyCode
                }
              }
              compareAtPriceRange {
                maxVariantPrice {
                  amount
                  currencyCode
                }
                minVariantPrice {
                  amount
                  currencyCode
                }
              }
              images (first:1) {
                edges {
                  node {
                    originalSrc
                    altText
                  }
                }
              }
            }
          }
        }
      }`
    };

I'm getting this error:

Field 'compareAtPriceRange' doesn't exist on type 'Product'

1 Like
Highlighted
New Member
1 0 1

I'm facing a similar issue for few days !

1 Like
Highlighted
New Member
2 0 0

I have the same exact issue! In my mind it should be queried just like priceRange based on docs, and it is listed as a field on the Product object. Would definitely appreciate some insight here @shopify

0 Likes
Highlighted
Tourist
5 1 1

Just ran into same issue.

It looks like compareAtPriceRange was added in API version 2020-04.

Updating the API version in my graphQl endpoint to 2020-07 fixed this for me.

You can view here how the field is shown when you are in 2020-04 or later version: https://shopify.dev/docs/storefront-api/reference

1 Like
Highlighted
Tourist
5 1 1

Just got an email post got a thumbs up, cool thank you!

But there is still an issue here!!!

compareAtPriceRange does not work properly in any current API version ( as far as we tested )

There is an open issue on github that we can confirm and have replicated: https://github.com/Shopify/js-buy-sdk/issues/774

We got around this bug for now by looping over variants using compareAtPriceV2 to get the data we needed. Not ideal since a top level query would be a lot cleaner, but it can work.

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
493 98 88

Hi everyone - 

 

The bug with the compareAtPriceRange returning the incorrect range is under investigation! The fact that it was not appearing is due to the wrong version as pointed out in earlier comments. I'll update here when this has been updated. 

Vix | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 


0 Likes