Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

compareAtPriceRange does not work

compareAtPriceRange does not work

sullizer
Shopify Partner
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'

Replies 7 (7)

polozerance
Tourist
4 0 3

I'm facing a similar issue for few days !

marissatraina
Visitor
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

JustinMetros
Tourist
6 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

JustinMetros
Tourist
6 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.

 

vix
Shopify Staff
541 103 123

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. 

To learn more visit the Shopify Help Center or the Community Blog.

wisslb1
New Member
5 0 0

Regrading this URL from shopify 'https://shopify.dev/graphiql/storefront-graphiql' compareAtPriceRange is available in product but when i used i got error

 

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

 

but both are available in the version (2010-10 latest).
any idea?

vix
Shopify Staff
541 103 123

@JustinMetros @sullizer @marissatraina We have pushed a change that should accurately reflect the proper compare at price range. Let me know if you see otherwise. 

 
 

To learn more visit the Shopify Help Center or the Community Blog.