Js-buy-sdk: compareAtPriceRange returns the same priceRange values even compare at price are set.

Created on 29 Jul 2020  路  7Comments  路  Source: Shopify/js-buy-sdk

compareAtPriceRange returns the same priceRange values even if compare at price are set.

{
  products(first: 2, reverse: true) {
    edges {
      node {
        id
        title
        compareAtPriceRange {
          maxVariantPrice {
            amount
          }
          minVariantPrice {
            amount
            currencyCode
          }
        }
        priceRange {
          maxVariantPrice {
            amount
          }
          minVariantPrice {
            amount
            currencyCode
          }
        }
        variants(first: 2) {
          edges {
            node {
              presentmentPrices(first: 2) {
                edges {
                  node {
                    compareAtPrice {
                      amount
                    }
                  }
                }
              }
              product {
                id
              }
            }
          }
        }
        onlineStoreUrl
      }
    }
  }
}

If you use this query inside https://shopify.dev/graphiql/storefront-graphiql you will get the product on sale.

{
  "data": {
    "products": {
      "edges": [
        {
          "node": {
            "id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzQ0NjQ1OTA4NDgz",
            "title": "[BB-TESTING] 3/4 SLEEVE CREWNECK PULLOVER",
            "createdAt": "2017-12-13T15:42:25Z",
            "compareAtPriceRange": {
              "maxVariantPrice": {
                "amount": "300.0"
              },
              "minVariantPrice": {
                "amount": "3.0",
                "currencyCode": "CAD"
              }
            },
            "priceRange": {
              "maxVariantPrice": {
                "amount": "300.0"
              },
              "minVariantPrice": {
                "amount": "3.0",
                "currencyCode": "CAD"
              }
            },
            "variants": {
              "edges": [
                {
                  "node": {
                    "presentmentPrices": {
                      "edges": [
                        {
                          "node": {
                            "compareAtPrice": {
                              "amount": "255.55"
                            }
                          }
                        }
                      ]
                    },
                    "product": {
                      "id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzQ0NjQ1OTA4NDgz"
                    }
                  }
                },
                {
                  "node": {
                    "presentmentPrices": {
                      "edges": [
                        {
                          "node": {
                            "compareAtPrice": {
                              "amount": "305.0"
                            }
                          }
                        }
                      ]
                    },
                    "product": {
                      "id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzQ0NjQ1OTA4NDgz"
                    }
                  }
                }
              ]
            },
            "onlineStoreUrl": "https://graphql.myshopify.com/products/bb-testing-3-4-sleeve-crewneck-pullover"
          }
        }
      ]
    }
  }
}

And you can see that it returns the same values:

            "compareAtPriceRange": {
              "maxVariantPrice": {
                "amount": "300.0"
              },
              "minVariantPrice": {
                "amount": "3.0",
                "currencyCode": "CAD"
              }
            },
            "priceRange": {
              "maxVariantPrice": {
                "amount": "300.0"
              },
              "minVariantPrice": {
                "amount": "3.0",
                "currencyCode": "CAD"
              }
            },

When it should return:

            "compareAtPriceRange": {
              "maxVariantPrice": {
                "amount": "305.0"
              },
              "minVariantPrice": {
                "amount": "255.55",
                "currencyCode": "CAD"
              }
            },
            "priceRange": {
              "maxVariantPrice": {
                "amount": "300.0"
              },
              "minVariantPrice": {
                "amount": "3.0",
                "currencyCode": "CAD"
              }
            },

All 7 comments

Hi @Gardemarin Thanks for bringing this to our attention. I will let you know when a fix has been implemented into the Storefront API.

Hi @Gardemarin

The compareAtPriceRange now returns the correct values. Let me know if you have any more issues with that!

@vixdug we're still getting an internal error when including the compareAtPriceRange field for many clients, below is the error response.

{
  "errors": [
    {
      "message": "Internal error. Looks like something went wrong on our end.\nRequest ID: 629ba93e-0bdf-4ba1-a5dc-933e79664415 (include this in support requests).",
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "requestId": "629ba93e-0bdf-4ba1-a5dc-933e79664415"
      }
    }
  ]
}

@brod-dotdev We've reverted the PR and you should not be receiving the internal server error. I will update here when we rerelease a fix for the ranges.

hi @vixdug

I have tried it, and I find that.. It still has the same problem until now
compareAtPriceRange return the same value with priceRange

There is a post on Shopify forums referencing this here

Shopify staff says should be working now in latest I guess ( 2020-10) haven't checked yet but sending through the info.

Apologies for the delay here - we re-released the fix mid September.

Was this page helpful?
0 / 5 - 0 ratings