Query Product Availability

Solved
Highlighted
Tourist
13 0 1

Hello, I wanna know how to see if a product is out of stock? So we'll display an overlay to let the user know...

0 Likes
Highlighted
Shopify Partner
531 38 109

This is an accepted solution.

Here below is a GraphQL API example. Where I pass the variant ID into the query. The top level inventoryQuantity shows the total on-hand for this particular variant. Then in the example I iterate through the first five locations to list the on-hand at each site. Not necessary per your question, but another angle if you needed it.

Hope this helps!

{
  productVariant(id: "gid://shopify/ProductVariant/31513252823092") {
    displayName
    inventoryQuantity
    inventoryItem {
      inventoryLevels(first: 5) {
        edges {
          node {
            location {
              id
              name
            }
            available
          }
        }
      }
    }
  }
}

 

1 Like
Highlighted
Tourist
13 0 1

thank you Greg

0 Likes