Update stock quantity with variant id

shopjb
Tourist
6 0 1

I need to update the available quantity for a variant to which I only have the ID available.
From my understanding I can get the InventoryItem ID easily with a call for the variant data. Now to update the InventoryLevel I also need the location_id  but how do I get that one? How can I update the available quantity?

0 Likes
Greg_Kujawa
Shopify Partner
951 80 203

Below is a GraphQL API example of how you can query a product variant's inventory item's inventory levels to see on-hands by location. Once you get your locations then you can issue a GraphQL mutation request to change the on-hand availability for a particular location. As for the mutation, it's discussed here --> https://www.shopify.com/partners/blog/multi-location_and_graphql.

Hope this helps!

Untitled.png

0 Likes
shopjb
Tourist
6 0 1

That is helpful. Thank you very much. Do you know if it would be possible to have the same inventoryitem for two different products?
So that they share the quantity and if one decreases, the other one does too?

0 Likes
Greg_Kujawa
Shopify Partner
951 80 203

As far as I'm aware, each InventoryItem is a unique record based on its ID. So I don't think that more than one Product (or ProductVariant) can share the same InventoryItem ID.

0 Likes