Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi,
I would like to get the availability of all my product variants by location, to know whether or not they are available for sale and where.
For this I am calling the storefront API to get my product, and including the storeAvailability field, with the parameter first: X to retrieve all of them.
The query works well, I do get a response, however I only get one location data, even though I have more.
In the admin dashboard, they are all setup the same way with an address and with the option Fulfill online orders from this location enabled.
Here's the query I am using:
query {
node(id: $id) {
... on ProductVariant {
availableForSale
title
product {
title
}
storeAvailability(first: 100) {
edges {
node {
available
location {
id
name
}
}
}
}
}
}
}
And here's the response I get:
{
"data": {
"node": {
"availableForSale": true,
"title": "34",
"product": {
"title": "Title"
},
"storeAvailability": {
"edges": [
{
"node": {
"available": true,
"location": {
"id": ID,
"name": "BOUTIQUE LYON"
}
}
}
]
}
}
}
}
I only get one location result, event though on this specific variant, I added 7 of them with or without inventory.
Thanks for the help!
Hey @MarionOtt
Could I ask if your other locations(that are not returned) have Local Pickup enabled? Trying this myself for an in stock Product Variant, If I switch my locations to have Local Pickup enabled, then I can make the same query and I'll be returned my locations that have Local Pickup enabled. storeAvailability on the Product Variant provides the in-store pick up availability of the Product Variant(docs).
Alternatively if still no progress after that, please feel free to send me a x-request-id returned from the headers and I'll look into it - let me know how that goes - thanks!
Hey @Luke_K , thanks for your reply!
It appears Shopify kept cache from a query I made when the option was indeed enabled. So after I disabled it, I still received an old payload, that's why I thought there was something missing.
All good now, thanks!