Re: fetch_stock.json populates wrong location with permitsSkuSharing: true and inventoryManagement:

Solved

fetch_stock.json populates wrong location with permitsSkuSharing: true and inventoryManagement: true

Nicholas_P
Shopify Partner
30 3 25

I'm working on migrating our application from the legacy fulfillment API to fulfillment orders, and figured I would tackle permitsSkuSharing: true at the same time.

 

I think I've found a bug when using inventoryManagement: true, which is the mechanism that triggers Shopify to call a fetch_stock.json page that we host.

 

Here is how you can recreate the issue:

 

1. Create a development store.

 

2. For the sake of completeness, add two traditional locations to the store. I renamed the default one "Alpha Location" and the second one "Zeta Location". The store's default location is still "Alpha Location".

 

3. Use the GraphQL version 2022-07 to call fulfillmentServiceCreate:

 

 

                mutation CreateFulfillmentServiceInShopifyIfNotExists {
                    fulfillmentServiceCreate(
                        name: "Contoso 3PL"
                        permitsSkuSharing: true
                        trackingSupport: false
                        fulfillmentOrdersOptIn: true
                        callbackUrl: "https://example.com/"
                        inventoryManagement: true
                    ) {
                        fulfillmentService {
                            id
                            location {
                                id
                            }
                        }
                    }
                }

 

 

Note that permitsSkuSharing and inventoryManagement are both true, and this call implicitly creates the "Contoso 3PL" legacy location associated with the fulfillment service.

 

4. You will now see 3 locations in the store. The two traditional locations, and the special app location that was implicitly created by Shopify during the fulfillmentServiceCreate call.

 

5. Use the Shopify Admin to create a product and give it a SKU, like PRODUCT-SKU. Click "Edit Locations" to make sure it is stocked at all 3 locations.

 

6. Shopify calls your callback url (i.e., https://contoso.com/fetch_stock.json?sku=PRODUCT-SKU&...) and you can reply with the expected payload:

 

 

{ "PRODUCT-SKU": 24 }

 

 

7. Shopify incorrectly applies the quantity of 24 to the "Alpha Location", instead of the "Contoso 3PL" location. This is the bug.

 

8. You can get Shopify to apply it to the correct location only by clicking "Edit Locations" and removing the store's default location. This is part of the bug. You should not have to do this. This defeats the whole purpose of SKU sharing.

 

Other observations:

 

A. It is not possible to change the "Contoso 3PL" location (the location associated with the fulfillment service) as a default location in the Shopify Admin. It does not show up in the list. Partner Support suggested this as a workaround.

 

B. It is also not possible, according to the documentation, to return a location_id in the "fetch_stock.json" reply, as it is simply not documented there, and Shopify should know what it is anyway since they are the ones initiating the call. (It mentions a location_id as possible query parameter coming from Shopify in the unstable API, but in my observations Shopify is not sending this parameter in 2022-07.)

 

C. Changing the location priority in the Shopify Admin does not change the behavior.

 

D. If you make "Zeta Location" the default location and deactivate the "Alpha Location", then "Zeta Location" inherits the erroneous behavior, as if the inventory from fetch_stock.json is simply being written to the first location_id that is returned from some internal Shopify API call.

 

I tried reporting this through Shopify Partners and failed, and I tried a post back in March and didn't get a response. I hope by putting it in this new board, I may get some visibility.

 

It simply does not work correctly. Is there any hope that this can be fixed?

Accepted Solution (1)

Nicholas_P
Shopify Partner
30 3 25

This is an accepted solution.

Closing the loop here, they fixed this bug in late September 2022.

View solution in original post

Replies 3 (3)

guest4
Shopify Partner
90 6 24

Confirming that we are finding that this is not working as expected, as well. The above post is a  complete description of the issue.

Nicholas_P
Shopify Partner
30 3 25

As of noon Eastern, Shopify has suddenly started passing the location_id in fetch_stock.json, which the documentation says is only supposed to be unstable, and instantly broke HMAC validation.

 

I guess that means they are working on it.

Nicholas_P
Shopify Partner
30 3 25

This is an accepted solution.

Closing the loop here, they fixed this bug in late September 2022.