We are having an issue with the fetch_stock function for one of our stores. Our Endpoint is reporting stock for items but the inventory history is setting the stock incorrectly. I have specific examples, but I'm new to this forum and not sure how detailed I should get with specific Endpoint calls. Here's one in particular:
This Endpoint call returns 2 in stock, but when you look at this items inventory history in the Shopify admin portal, the fetch_stock call is setting it to zero.
When Shopify makes a fetch_stock call to a store, it also takes into account any units that are currently unfulfilled in the store.
For example, if a store has 2 units that are pending fulfillment on orders, Shopify subtracts those from the number provided in the fetch_stock response, and adjusts store inventory accordingly. So if the store has 2 units on orders that are pending fulfillment and the fetch_stock call responds with `2`, Shopify subtracts pending unfulfilled from the fetch_stock (which in this case equals 0), and adjusts the store inventory accordingly.
The important thing to note here is that you don't need to account for pending_unfulfilled orders when responding to fetch_stock. Shopify decrements inventory from the fulfillment service when an order is actually fulfilled, so you need to ensure you only decrement inventory when fulfillments are created, and otherwise respond to the fetch_stock call with your current inventory level.
From the example you provided, it looks like the adjustment was being made due to pending unfulfilled orders on the store, though it's a bit difficult to interpret the logs because there were a number of orders for this SKU during the time period. If the above explanation doesn't help with the issue you're seeing, kindly provide another example (from either a test or production shop), including a timeframe and variant_id which was adjust incorrectly, as well as what you responded with in the fetch_stock call. With this information I should be able to take another look at our logs to determine what's happening.
JB | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution