Development discussions around Shopify APIs
I am trying to update the quantity of a product variation, I read the docs and found inventoryQuantities which I also use when I am updating multiple variants through "productUpdate", but when I use it with productVariantUpdate for a single product it seems to have no effect. See the screenshot below where I send the mutation and in the response I get back there's still "10" in stock even though it should have updated it to 3. As I only have access to the variant SKU + locationID + the new stock level I need to find a way to update the inventory directly from the productVariant, which should be possible when looking in the docs, also it works with "productUpdate".
In order to adjust on-hand quantities you need to use the adjustInventoryLevelQuantity mutation. As described here --> https://shopify.dev/tutorials/manage-product-inventory-with-admin-api.
Below is a screen shot of a successful test run. Hope this helps!
Thank you for the fast reply. Then I don't understand why I am getting no error from my call, if the values aren't allowed. Also it works with "ProductUpdate". The problem with the adjustInventoryLevelQuantity is that it requires that you know the "inventoryLevelId" in advance. I am developing an integration with a POS system and use their SKU's as the unique identifier between the two systems.
It is a bit inconsistent in how it's handled between products, variants, quantities, other attributes, etc. In your use case, you might have to make a couple of API calls. One would determine the inventory item ID for a particular SKU. Then you'd have to make an API call to adjust the quantity for that particular inventory item. Not the slickest solution, but it should work.
Thanks for the reply, I understand that is possible with this other call. But I still hope someone can direct me to make the original call work, as it's documented it should work in their API documentation and would greatly reduce the complexity in the integration, also as I have to update thousands of products I would take a very long time if I had to fetch the inventoryLevels ID each time, due to the rate limiting of shopify.
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...By Jacqui Mar 10, 2023
Upskill and stand out with the new Shopify Foundations Certification programBy SarahF_Shopify Mar 6, 2023
One of the key components to running a successful online business is having clear and co...By Ollie Mar 6, 2023