App reviews, troubleshooting, and recommendations
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello, 👋
GET `/products/handle.json` return an JSON:
{ product: { id: 1, title: "title", body_html: 'body', vendor: "vendor", ... variants: [ { id: 1, product_id: 2, title: "variant title", ... }, ], ... }, }
JSON does not contain information about the variant's inventory quantity. How can I retrieve this data? I need it on the home page. I'm looking a solution for the Shopify theme app extension (I need this data in the app extension), so modifying the store's theme Liquid files is not an option.
Hi @Dzonotonas
You can refer to this video
https://www.youtube.com/watch?v=WMdYdvrFQ1s
The following GraphQL query retrieves inventory details for a specific product variant:
query GetVariantInventory {
productVariant(id: "gid://shopify/ProductVariant/43729076") {
id
title
inventoryQuantity
availableForSale
}
}
Make sure your app has the read_inventory access scope enabled to retrieve inventory data.
and also refer to here https://shopify.dev/docs/api/admin-graphql/2024-10/queries/productVariants