Getting the previous quantity or delta change in IventoryLevel webhook

18 0 4


We have a tricky problem with an app we develop.

We are setting up an inventory structure so that for example "Battery 100-pack" consists of 10x"Battery 10-pack".

Lets say that the shop have 10x"Battery 100-pack" in inventory. That means that the shop have 100x"Battery 10-pack".

So if 1x"Battery 10-pack" is sold (inventory adjusted), then the shop has 9x"Battery 100-pack" and 99x"Battery 10-pack".

So far so good. But if the shops orders 2x"Battery 100-pack" and adds this to the inventory, then the calculation will be wrong because they already have a left-over of 9x"Battery 10-pack".

We were thinking about using the InventoryLevel webhook to update this structure. But since we have no way (that we can see) of knowing what the inventory was before the change, we cannot update the structure because it will be wrong. It will then think we have 11x"Battery 100-pack" = 110x"Battery 10-pack" when it should be 119x"Battery 10-pack" (the left-overs from the previous sale).

Any ideas of how this can be solved ?

This is extra strange because Shopify itself are using delta changes. So the perfect solution would be to get the delta changes in inventory, or new and old inventory (even better).