Custom Fulfillment Service. Not all product inventories update.

Solved
Highlighted
Tourist
3 0 0

I have written a custom fulfillment service to provide timely inventory adjustments to our products. It works almost perfectly, however a few products are not updating correctly.

There are over 8500 products, 4 variants each. The vast majority correctly update their inventory when Shopify pulls updates from the callback url. eg https://myapp.com/fetch_stock.json

But, some products are stubborn and wont update inventory levels, even when deleted and re-created. Despite this, creating a different product works perfectly and inventory levels update immediately.

Notes:

  • The products that do not update, have not updated for over 72 hours.
  • All of the products in question have the same custom fulfillment service attached.

 

Things I have tried.

Toggle the fulfillment_service property on the product variants.

Result. Shopify requests the levels for SKUs of the product. My callback responds with the correct values. Shopify sets the levels at 0.

 

Delete the product and recreate it.

Result. Shopify requests the levels and ignores them, setting levels to 0.

 

Delete a working product and recreate it.

Result. Shopify requests the levels and correctly sets them.

 

Wait for the hourly all SKU request.

Result. Shopify requests all SKUs, my code responds with all SKU levels but Shopify does not update the products in question. It correctly updates the rest.

 

 

{
    "fulfillment_service": {
        "id": 99999999999,
        "name": "XXXXXXXXXXXXXXX",
        "email": null,
        "service_name": "XXXXXXXXXXXXXXX",
        "handle": "XXXXXXXXXXXXXXX",
        "fulfillment_orders_opt_in": false,
        "include_pending_stock": false,
        "provider_id": null,
        "location_id": 99999999999,
        "callback_url": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
        "tracking_support": false,
        "inventory_management": true
    }
}

 

I reached out to Shopify support and they directed me here as the issue was outside their scope.

I can provide Shop or product urls/json on request.

 

Any assistance would be greatly appreciated.

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
491 63 107

Hey @oldnightowl,

There's 2 things you can check:

- Make sure the SKU in question isn't being used on another product

- Make sure the SKU in question doesn't exist on any unfulfilled orders in the store.

If those don't fix the issue, please provide a few example inventory_item_ids and I can check our logs for more details.

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

1 Like
Highlighted
Tourist
3 0 0

Thanks for the reply.

Good questions.

I can 100% confirm the product SKU is unique to that product.

 

However, there are unfulfilled orders outstanding on this product but I am unclear on why this would prevent inventory updates.

We sold several, then received another shipment.

inventory_item_id

34391719870558
34391719903326
34391719936094
34391719968862

inventory_quantity in order should be 24, 0, 0, 1 yet they all show in Shopify as 0.
0 Likes
Highlighted
Shopify Staff
Shopify Staff
491 63 107

This is an accepted solution.

Hey @oldnightowl,

Here's a little blurb about the fetch_stock endpoint's behaviour:

When Shopify makes a fetch_stock call to a store, Shopify also takes into account any units that are currently unfulfilled in the store.

For example, say a store had 10 units of a particular SKU and 2 were sold. Those 2 units haven't been shipped yet, so they're just sitting on the pending unfulfilled orders in the store. When Shopify does a fetch_stock for this SKU, we expect your response to be 10 (since you haven't shipped the items, we expect 10 of them to be at your warehouse). When Shopify gets a response of 10, the pending unfulfilled units are subtracted, and in this case the inventory quantity displayed to the merchant is 8 (which is the actual number they have available for sale).

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.

 

I checked the inventory_item examples you provided, and the behaviour described above explains the numbers you're seeing. For example, I checked the item 34391719870558 which should have 24 units available, and I can see that SKU exists on many existing orders in the shop. You can delete/fulfill these orders, and then you will see the number from your response displayed as the available quantity in the admin. 

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

1 Like
Highlighted
Tourist
3 0 0

Thanks for your explanation _JB

My current process is to immediately process Shopify sales through our backend systems, deducting from available inventory.

I will need to rethink the timing of this as it causes unfulfilled orders to be counted twice.

0 Likes