I have a shopify app that listens to the `order/updated` event. For one specific store I'm having the following issue:
1. I receive the webhook payload and all line items have the `fulfillable_quantity: 0`
2. Then I receive the same payload but now the fulfillable quantity matches the quantity of the item on the order
I've seen a few people mentioning "on hold" fulfillments and inventory issues, which I don't think is the case here because the difference between those 2 events are milliseconds, they happen basically at the same time. This store have a bunch of orders like that
My backend has some triggers when the fulfillable quantity is 0 and because of that some events are being incorrectly fired.
Any idea of what can be causing that?
This issue could be due to a variety of reasons. Here are a few possibilities:
Race Condition: The issue could be due to a race condition, where your app is processing the webhook payloads out of order. Even though the two events may appear to be fired at the same time, processing delays could result in your app handling the second event first and the first event.
Delayed Inventory Deduction: Shopify might be updating the fulfillable quantity after the order is updated due to some internal processes. This could include things like payment verification, order risk analysis, or other operations that might temporarily put the order on hold.
Fulfillment Service Delay: If the store uses a custom fulfillment service, it could be causing the delay. The service might be taking time to confirm the inventory availability, causing the fulfillable quantity to be updated only after confirmation.
To diagnose this issue, you can log the timestamps of when you receive each webhook and when you process them. This could help you identify any processing delays or race conditions. Try out the above and let us know if you're still unable to resolve this so we can dig in further!
Hi @Liam thanks for the feedback. Giving you more context: my app is a delivery guarantee that is added as a product in the buyer's cart. My backend listens to orders events to identify when the other items of the given order are fulfilled, I only fulfill my product once there's nothing else left to fulfill in the order. In this case, the race condition is irrelevant for me, because actually the first events (order create/update) that I receive have the fulfillable quantity = 1, but as soon as I receive one with fulfillable quantity = 0 my backend will understand there is nothing else left to fulfill, regardless if this is the first or afterwards events. We're also relying on this field because of removed items, that will stay as an item in the order but will have no fulfillment created.
Regarding options 2 and 3, both are out of my control and will depend on how the merchant is managing it. So what is the best way to tell the real fulfillment status of each item? Taking into consideration that removed items don't have a specific status, I believe they stay as "pending" or "open".
Is there another way to identify removed items? because then I could stop relying on fulfillable quantity and start looking into the fulfillments list of the order and ignore the removed items