I want to make a query to get the product detail by the location
This is my actual query with graphql:
query Product{ product(id:"gid://shopify/Product/id") { title handle description priceRange { maxVariantPrice { amount currencyCode } } options(first: 1) { values } variants(first: 7) { edges { node { availableForSale inventoryQuantity selectedOptions { name value } } } } images(first: 3) { edges { node { transformedSrc(maxHeight: 600, preferredContentType: JPG) altText } } } } }
Result:
{ "data": { "product": { "title": "Vestido Catalina Noir", "handle": "vestido-catalina-noir", "description": "El perfecto oversized. Friendly para un asado en familia y mas de un postre. Creamos ese vestido fresco que pairs well con el verano paraguayo y nuestros carbs favoritos. - Sin manguitas - 100% poliester - Oversized - Midi - Con bolsillos Hecho por Carolina Stephie viste un talle XS Para info sobre nuestra política de devolución y la recepción de prenda, leéme", "priceRange": { "maxVariantPrice": { "amount": "379000.0", "currencyCode": "PYG" } }, "options": [ { "values": [ "xs", "s", "m", "l", "xl" ] } ], "variants": { "edges": [ { "node": { "availableForSale": true, "inventoryQuantity": 4, "selectedOptions": [ { "name": "Tamaño", "value": "xs" }, { "name": "Color", "value": "Noir" } ] } }, { "node": { "availableForSale": true, "inventoryQuantity": 5, "selectedOptions": [ { "name": "Tamaño", "value": "s" }, { "name": "Color", "value": "Noir" } ] } }, { "node": { "availableForSale": true, "inventoryQuantity": 6, "selectedOptions": [ { "name": "Tamaño", "value": "m" }, { "name": "Color", "value": "Noir" } ] } }, { "node": { "availableForSale": true, "inventoryQuantity": 3, "selectedOptions": [ { "name": "Tamaño", "value": "l" }, { "name": "Color", "value": "Noir" } ] } }, { "node": { "availableForSale": false, "inventoryQuantity": 0, "selectedOptions": [ { "name": "Tamaño", "value": "xl" }, { "name": "Color", "value": "Noir" } ] } } ] }, "images": { "edges": [ { "node": { "transformedSrc": "https://cdn.shopify.com/s/files/1/1816/7365/products/20A4979_x600.png.jpg?v=1572442259", "altText": null } }, { "node": { "transformedSrc": "https://cdn.shopify.com/s/files/1/1816/7365/products/20A4981_x600.png.jpg?v=1572442259", "altText": null } }, { "node": { "transformedSrc": "https://cdn.shopify.com/s/files/1/1816/7365/products/20A4989_x600.png.jpg?v=1572442259", "altText": null } } ] } } }, "extensions": { "cost": { "requestedQueryCost": 24, "actualQueryCost": 20, "throttleStatus": { "maximumAvailable": 1000, "currentlyAvailable": 980, "restoreRate": 50 } } } }
This query only show the product variants of a single location, I have two locations with their respective inventories,
how can I make a list according to the location?
Hey @GuilleCaba ,
You can use the InventoryItem connection to variant, which allows you to list out the inventory level available for that variant at each location in your shop. In your query it will look something like this:
variants(first: 7) {
edges {
node {
inventoryItem {
inventoryLevels(first: 4) {
edges {
node {
available
location {
name
}
}
}
}
}
JB | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
User | Count |
---|---|
12 | |
11 | |
10 | |
8 | |
8 |