Warehouse Inventory on Frontend

I think I already know the answer here, but is there a way to query individual warehouse availability for products on the frontend without using Admin API or expose API keys/secrets?

We have a client that is wanting to add a QTY selector to PDPs, but the problem is that they can’t ship across country lines (US/CA), but have inventory for single products in both locations (two warehouses). If we query something like variant.inventory_quantity, I’ll get the count for both warehouses which is a poor experience when we only have 1 in stock in CA, but like 600 in the US. A Canadian user would add multiple just fine, get to checkout to find that they can only actually purchase 1…

Any ideas? I really wish we had like a variant.warehouses[0].inventory_quantity property or something…

Without using the Admin API, the closest you could do would be store availabilities on the Storefront API, but this relies on the location being available for pickup - https://shopify.dev/docs/api/storefront/2024-04/objects/ProductVariant#connection-storeavailability

Otherwise you’ll need to build an endpoint as such to be able to access the admin api and access inventory data by location.

1 Like

Could create variant metafields (or metaobject structure) containing inventory quantity for each location, and then use those entry points.

Should be possible to keep those hydrated with Shopify flow - otherwise third party apps like Mechanic and Arigato can do the trick.

Think I’ve done something similar in the past, but can’t remember the case.

Regarding this, you could enable pickup for them to be available in the storefront API (I thought that object only contains true/false availability and not specific quantities? edit: that was the correspondig liquid object) and then use Functions (checkout blocks/buddy can do) to hide the pickup shipping methods.