Shopify Admin GraphQL minVariantPrice is incorrect

Highlighted
Shopify Partner
5 0 0

When I retrieve the `minVariantPrice` of a product from the Admin GraphQL API (NOT the Storefront GraphQL API), I receive a value that is the amount of the least expensive variant multiplied by 100. For example a product's min variant will be $16.99, but the priceRange > minVariantPrice > amount will be $1699.0

Is this calculated by Shopify? Why is this happening?

0 Likes
Highlighted
Shopify Partner
1840 177 719

What query are you using and from which SDK?

Using plain GraphQL via Storefront API:

{
  shop {
    products(first: 1) {
      edges {
        node {
          priceRange {
            minVariantPrice { amount }
            maxVariantPrice { amount }
          }
          variants(first: 3) {
            edges {
              node {
                title
                price
              }
            }
          }
        }
      }
    }
  }
}

Results in:

{
  "data": {
    "shop": {
      "products": {
        "edges": [
          {
            "node": {
              "priceRange": {
                "minVariantPrice": {
                  "amount": "300.0"
                },
                "maxVariantPrice": {
                  "amount": "400.0"
                }
              },
              "variants": {
                "edges": [
                  {
                    "node": {
                      "title": "S",
                      "price": "300.00"
                    }
                  },
                  {
                    "node": {
                      "title": "M",
                      "price": "350.00"
                    }
                  },
                  {
                    "node": {
                      "title": "L",
                      "price": "400.00"
                    }
                  }
                ]
              }
            }
          }
        ]
      }
    }
  }
}

Which is correct behavior.

Any other details as to how you are querying the products and how they're setup would be helpful.

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
0 Likes
Highlighted
Shopify Partner
5 0 0

I'm not using any SDK! Just using the Shopify Admin GraphQL API, the API that seems to be still in beta.

0 Likes
Highlighted
Shopify Partner
5 0 0

I'm also able to retrieve the correct value using the Storefront GraphQL API, I'm just wondering why the value is incorrect on the Admin GraphQL API

0 Likes
Highlighted
Shopify Partner
1840 177 719

@projectspirit

Yeah, I can confirm now. I initially tried the Storefront API which behaves as expected. Admin GraphQL API has the priceRange min/max amount multiplied by x100 as you say.

Definitely a bug @Shopify.

Steps to reproduce:

  1. Create product with 3 variants
  2. Run below query
query {
  products(first: 1) {
    edges {
      node {
        priceRange {
          minVariantPrice { amount }
          maxVariantPrice { amount }
        }
        variants(first: 3) {
          edges {
            node {
              price
            }
          }
        }
      }
    }
  }
}


Actual result:

{
  "data": {
    "products": {
      "edges": [
        {
          "node": {
            "priceRange": {
              "minVariantPrice": {
                "amount": "30000.0"
              },
              "maxVariantPrice": {
                "amount": "40000.0"
              }
            },
            "variants": {
              "edges": [
                {
                  "node": {
                    "price": "300.00"
                  }
                },
                {
                  "node": {
                    "price": "350.00"
                  }
                },
                {
                  "node": {
                    "price": "400.00"
                  }
  ...
}


Expected result:

{
  "data": {
    "products": {
      "edges": [
        {
          "node": {
            "priceRange": {
              "minVariantPrice": {
                "amount": "300.00"
              },
              "maxVariantPrice": {
                "amount": "400.00"
              }
            },
            "variants": {
              "edges": [
                {
                  "node": {
                    "price": "300.00"
                  }
                },
                {
                  "node": {
                    "price": "350.00"
                  }
                },
                {
                  "node": {
                    "price": "400.00"
                  }
                }
   ...
}

 

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
3 Likes
Highlighted
Shopify Partner
5 0 0

@karloffenberger

Thanks for that clean bug report! Yes, precisely! Hopefully someone from Shopify sees this soon.
@Shopify

0 Likes
Shopify Partner
9 0 1

@KarlOffenberger @projectspirit_A

After one year, yet the bug still there unresolved...  @Busfox Sorry for tagging you here as I only know you from Shopify Staff.., could you please have someone look into this bug? Thank you very much!

0 Likes
Highlighted
New Member
5 0 0

Is there any update from shopify developer? The bug still there.

{
  shop {
    currencyFormats {
      moneyFormat
    }
  }
  products(first: 10) {
    edges {
      cursor
      node {
        legacyResourceId
        featuredImage {
          src
          transformedSrc(maxHeight: 150, maxWidth: 150)
        }
        title
        handle
        priceRange {
          minVariantPrice {
            amount
          }
        }
      }
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
    }
  }
}
Result: 
"priceRange": {
              "minVariantPrice": {
                "amount": "6000.0"
              }
            }

Expected Result:

"priceRange": {
              "minVariantPrice": {
                "amount": "60.00"
              }
            }

The bug still there as of 04-30-2020

0 Likes
Highlighted
Shopify Partner
5 0 1

It may be a bug but they aren't likely to change the behavior in this api version. (currently /2020-04/)

Safe enough to document the weirdness and work around it and then come back when the next version of the api is released.

I wish they would at least acknowledge it or document it.

side note: It looks to me like they're saving price as an integer.

 

0 Likes