Solved

Unable to get the `avaialableQuantity` property in StoreFront API

sidaticom
Visitor
2 0 1

Hello my dev fellows,
Im working on mobile app using StoreFront API and i'm not able to get the avaialableQuantity property for each variant, I found this link https://shopify.dev/changelog/inventory-quantity-available-on-storefront-graphql-api, but there is no thing such as the "inventory quantity" checkbox meanwhile there is a "unauthenticated_read_product_inventory" checkbox. i checked it as mentioned here https://shopify.dev/docs/storefront-api/reference/object/productvariant?api[version]=2020-04. Still no luck same error :

 

Field 'quantityAvailable' doesn't exist on type 'ProductVariant'

Im stuck as the property is very important to decide whether the product is available for certain quantity or not.

Any help would be greatly appreciated

Accepted Solution (1)
vix
Shopify Staff
540 103 122

This is an accepted solution.

Hi @JAM-Team @sidaticom 

 

If you are utilizing version 2020-4 and have granted the permission unauthenticated_read_product_inventory access scope

you should have no problem accessing this information from the Storefront API. Here is an example query: 

 

 

query {
  products(first:1)
 {
    edges {
      node {
        variants(first:1) {
          edges {
            node {
              availableForSale
              quantityAvailable
            }
          }
        }
       title
        id
        publishedAt
      }
    }
  }
}

 

 

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

View solution in original post

Replies 4 (4)

JAM-Team
Tourist
4 0 2

We have the exact same problem.

It seem to be a bug into the api 😢

 

Did you find a solution?

I think the only workaround is to use Shopify Admin api 😬

vix
Shopify Staff
540 103 122

This is an accepted solution.

Hi @JAM-Team @sidaticom 

 

If you are utilizing version 2020-4 and have granted the permission unauthenticated_read_product_inventory access scope

you should have no problem accessing this information from the Storefront API. Here is an example query: 

 

 

query {
  products(first:1)
 {
    edges {
      node {
        variants(first:1) {
          edges {
            node {
              availableForSale
              quantityAvailable
            }
          }
        }
       title
        id
        publishedAt
      }
    }
  }
}

 

 

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

sidaticom
Visitor
2 0 1

Thanks to @vix, i start checking the API version and i found out that i'm using

Instead of

https://store-id.myshopify.com/api/2020-04/graphql 

After fixing that issue, the API is now working as expected, hope this is the case with you too @JAM-Team 

JAM-Team
Tourist
4 0 2

Yeah it was the same problem, thanks @sidaticom & @vix