SET inventory at location using Graphql

LeonardoMolina4
New Member
2 0 0

Hello!

We are using the graphql mutation inventoryBulkAdjustQuantityAtLocation, but it adjust the item quantity at location, We need to SET the quantity at location.

At the moment, to reach that, we are using the API REST Set(/admin/api/2021-04/inventory_levels/set.json) to replace inventory quantity and make that we need. But this API is item by item (one request API by item). 

With the mutation inventoryBulkAdjustQuantityAtLocation, is great because we can send several items for a location at one request

what can We do? or there is another mutation to solve that?

 

 

0 Likes
HunkyBill
Shopify Expert
4504 46 490

You are correct. You adjust the with the call. You have to adjust. You cannot just set. The reason is, you have no clue what the true value of inventory at that time is, inside Shopify. You could have an item being checked out, others being returned to stock. So you adjust.

So if you want the quantity to be X no matter what, the formula is pretty easy. Take the current value from Shopify, and the current value you want it to be. Now just subtract the two to get the proper delta to apply. Boom. Bob is your uncle. I do this for many hundreds of thousands of SKUs using the update in bulk at a location, as you can update 100 at a time! So good!

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes