Inventory decremented twice - by Shopify and App

Highlighted
Tourist
19 0 2

@_JB Thanks for helping me through this. I've made the code changes to reflect how it should work, and I'm now seeing the opposite (wrong) behavior).

 

 

Here's the timeline.

 

Store: event-ticketing-integration-testing-leave-alone.myshopify.com

Variant: 31336084504650 ("inv test")

SKU: 15744

Date: This morning, November 22nd

 

7:32AM PST: SKU added with inventory 10. fetch_stock returns {"15740":5,"15742":5,"15743":4,"15744":10}

Inventory is 10 in Shopify.

 

7:33AM PST: Order #1005 placed for 1 item. 

Inventory is 9 in Shopify.

 

7:33-8:28AM PST: Order remains unfulfilled, no calls to fetch_stock logged. Inventory is correct @9

 

8:28AM PST: Shopify calls fetch_stock and application returns {"15740":5,"15742":5,"15743":4,"15744":10}

 

Inventory is now 10 in Shopify. (it should stay at 9!) 

10 returned from fetch_stock - 1 pending unfulfilled = Shopify inventory should be 9.

 

Screen Shot 2019-11-22 at 8.57.17 AM.png

Inventory history: https://event-ticketing-integration-testing-leave-alone.myshopify.com/admin/products/4388137140298/v...

 

Please advise. Thanks.

 

0 Likes
Highlighted
Tourist
5 0 1

Hi everyone,

 

I am experiencing the same behavior. Isn't this an incorrect behavior?  As a "Fulfillment Service" I provide fulfillment products and services to a wide range of stores. When an order comes though my system I respond back to Shopify's fetch_stock request with an updated stock number based on pending orders.  If I didn't do this, then other stores with the same product would show and inflated amount of available stock and possibly cause order issues. This means that I now have to track pending stock for each store and reply to fetch_stock different depending on if the store has pending orders or not.  Seems like this introduces a place for errors to happen.

1 Like
Highlighted
Shopify Partner
6 1 11

@_JB is this a new behavior? I've recently started receiving a lot of reports from multiple merchants claiming their inventory was not reflecting their apps'. I double checked our fetch_stock.json responses to Shopify requests and confirmed we're returning the correct (or what it used to be correct) inventory.

 

When an order is placed in Shopify we sync it to our app and decrease the inventory from the items of that order, that's how we've always done it.

 

Should we change the behavior of our fetch_stock.json endpoint to stop considering unfulfilled quantities from shopify orders?

0 Likes
Highlighted
Tourist
5 0 1

@_JB  Can we get an update on this for the last few questions.  This behavior doesn't make sense when tracking inventory across multiple Shopify stores and we even track inventory across multiple platforms (not just Shopify).

0 Likes
Shopify Staff
Shopify Staff
225 23 25

Hey @Dyego_Costa,

 

Should we change the behavior of our fetch_stock.json endpoint to stop considering unfulfilled quantities from shopify orders?

This behaviour isn't new, but yes you should definitely change this behaviour on your end since Shopify already accounts for pending unfulfilled orders. The assumption being made here is that your FulfillmentService will decrement inventory at the moment the item ships, so when Shopify makes a fetch_stock request it's expected for the response count to include pending unfulfilled items.

 

Our documentation here outlines the best practices to use with the fetch_stock endpoint.

 

Hey @jayknott,

 

The purpose of the hourly fetch_stock call is to keep inventory levels in sync between Shopify and your warehouse, particularly when units from the warehouse are being sold outside Shopify. If a unit sells from another store/platform, you can respond to fetch_stock with a decremented number, and Shopify will adjust accordingly. The current behaviour makes it so that when building, you don't need to account for pending unfulfilled orders in Shopify. If you're selling through other platforms or connecting a single warehouse to multiple Shopify stores, you may need to build out your own logic to "commit" sold inventory, so that Shopify is made aware of the new inventory level in the hourly fetch_stock request.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Partner
2 0 0

The assumption being made here is that your FulfillmentService will decrement inventory at the moment the item ships, so when Shopify makes a fetch_stock request it's expected for the response count to include pending unfulfilled items.

Hi @_JB, we've experienced the exact same thing as @Dyego_Costa. We implemented the fulfillment service on the 2017 API and everything was great and now recently we are getting complaints that inventory is off. Here is what is happening currently:

 

  • Customer places order in Shopify.
  • Shopify creates new Fulfillment, we receive notice via webhook from Shopify.
  • We create a new order in the WMS and then call 'fulfillments/:id/open.json' to mark the fulfillment as received/processing.
    • At this point the WMS has deducted the order from the available amount as it is now reserved for that order. The reserved inventory is not advertised in the response to `fetch_stock.json`.
  • The order is split into one or more shipments which are eventually each picked and packed.
  • We PUT the tracking numbers back to the fulfillment as shipments are packed.
  • Once the last shipment is complete we call 'fulfillments/:id/complete.json' to mark the Shopify fulfillment as complete.

Is this incorrect? There is a lot of mixed terminology floating around here.. Can you clarify what "pending unfulfilled orders" means to Shopify? E.g. does it transition from "unfulfilled" to "fulfilled" after `open.json` or `complete.json`?

 

Thanks!

Colin

0 Likes
Highlighted
Shopify Staff
Shopify Staff
225 23 25

Hey @Colin_M,

 

Your current flow requires a change to how you're responding to fetch_stock. The golden rule here is:

 

Fetch_stock expects your response to include inventory for any items on existing orders that have a fulfillment_status of null or unfulfilled in Shopify.

 

From your description, it sounds like your fetch_stock response doesn't isn't including these numbers right now, since you're not advertising the "unavailable" inventory to Shopify. From Shopify's perspective, your fetch_stock response should include any units that are still physically located at your warehouse and have not been shipped.

 

The fulfillment_status for line items will change to fulfilled once you complete the fulfillment. At this point it's assumed the items are no longer in your warehouse, and shouldn't be included in the fetch_stock response.

 

Definitely agree that all the terminology floating around can make this hard to decipher. Let me know if there's anything I can clarify further.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes
Highlighted
Shopify Partner
2 0 0

Hi @_JB,

 

There is no "unfulfilled" status listed in the docs, only these:

 

  • pending: The fulfillment is pending.
  • open: The fulfillment has been acknowledged by the service and is in processing.
  • success: The fulfillment was successful.
  • cancelled: The fulfillment was cancelled.
  • error: There was an error with the fulfillment request.
  • failure: The fulfillment request failed.

Please clarify your statement as it relates to the above status names.

 

For what it's worth, when testing individual orders it seems to work as I'm expecting which is the "open" status is not subtracted from the Shopify inventory (e.g. if we return 99 to fetch_stock then 99 is available for sale while the one fulfillment for the item is in "open" status). In production with thousands of orders in different statuses it is hard to verify this but this is what we're seeing with our test environment.

 

Thanks,

Colin

0 Likes
Highlighted
Shopify Staff
Shopify Staff
225 23 25

Hey @Colin_M,

 

The statuses you mentioned relate to the actual fulfillment object. Fulfillments can have a status of pending, open, success, etc.

 

What I mentioned was in reference to the line_items on an order. When an order is created, each line_item has it's own fulfillment status (usually starts as null). Until the line_item's fulfillment_status is changed to fulfilled, you need to include that unit of inventory in your fetch_stock response. A line_item's fulfillment status will change to fulfilled once a fulfillment for that item has been completed ( status:success for the fulfillment object)

. If you're seeing unexpected results, the first thing to check is make sure the store isn't using the same SKU value on multiple variants. If they are, this will product unexpected results, and will need to be changed so that each SKU value is only used once. If that doesn't explain it, please provide an example of a variant_id including the expected vs actual inventory count in the Shopify admin, and the response on the fetch_stock call.

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes