Hi,
I’m building a third-party AI assistant for a Shopify store to improve product discovery. While suggesting products/variants, I want to filter them based on inventory at the customer’s active location (the one Shopify uses for fulfillment).
Right now, I can fetch inventory across all locations, for example:
inventoryItem {
id
inventoryLevels(first: 250) {
edges {
node {
location {
id
name
}
quantities(names: ["available"]) {
name
quantity
}
}
}
}
}
This gives me inventory for each location.
The issue: I cannot find a way to determine which location the customer is actually shopping from on the storefront. Without that, I don’t know which location.id
to use when filtering availability.
Question:
- Is there a way to fetch the customer’s active/assigned location ID from the storefront (via Storefront API, checkout, or cart context)?
- Or any workaround Shopify provides for mapping the browsing customer to the right location?
Any help would be greatly appreciated!
Thanks!