Development discussions around Shopify APIs
I want to develop an app that would determine whenever an item is out of stock, or whenever an item is restocked.
My first approach to determine if an item is out of stock was to read every HTTP request from the orders/paid Webhook and extract every variant_id of each items in line_items.
Once I get every variant_id of the order, I make an API call that includes them.
My app extracts the following data from the API call.
To determine if the item that was just purchased is out of stock, I would only need to compare the inventory_quantity to the value of 0. If the value is equal to 0, then I can trigger whatever I want (update a row in a spreadsheet, send an sms notification and much more).
Now, the problem is that I can't figure a manner to determine if a product is restocked. The inventory_levels/update Webhook gives me the available field where I can see how many times we have a specific item, but I can't see if the old inventory level was 0 or 2. (where 2 would mean that the quantity of that item is not restocked, but decreased by 1).
I'll take every suggestions, and I hope every has a great day 🙂
This scenario looks familiar 😉
Thank you for answering. I've seen this thread before but what I've noticed from it is that I would need to have a database with every InventoryLevels of each product. That would be a lot of work and it would take time for every product's InventoryLevels to be initially updated.
Therefore, I'm wondering if there is a way to search for the inventory of an item at a certain date through your API. With this information, I could know if the item in question is either restocking or out of stock.
You could add the updated_at_min as a query parameter when fetching products via the REST API. That would only pull products that had been edited on or after the date/time you specify. That's behind a lot of our logic that syncs up records between various systems.
As a business owner, have you ever wondered when your customer's first impression of yo...By Skye Jun 6, 2023
We're excited to announce improvements to the threaded messaging experience in our communi...By TyW May 31, 2023
Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...By Jacqui May 30, 2023