Determine which location to use for a fulfillment through the API when stock is tracked by Shopify

New Member
2 0 2

We've developed an app for generating shipping labels. After printing, the app also creates a fulfillment with the tracking code and url.

Now with the new locations features, we experience a problem. We have a client with multiple stores from where he will ship his items. With locations enabled he can manage the stock from the different stores through Shopify, which is great. But as an app, we need to determine which location needs to fulfill the orders, we appearently we can't. 

For example: 
Product 1 is available on location A and location B
Product 2 is only available on location B
When someone orders these two products, Shopify will reduce the stock of both items at location B. 

So far so good. But through the API I can't find for which location Shopify has reserved this item. In other words, from which location the items should be fulfilled? 

I can only find the available items for each location, but not the reserved items. 

In my opinion this information should be provided when calling /admin/orders/#{order_id}.json. But it doesn't.
So does anyone have an idea how to solve this?

0 Likes
Shopify Staff
Shopify Staff
1087 75 140

Hi Evelyn, 

There's actually no wrong answer here - where an item should be fulfilled from is entirely up to you which is why we don't just tell you which location to use.

The location that inventory is decremented from can still change when the fulfillment is created, and we'll adjust things accordingly and reduce the inventory at whichever location your app decides to use in its fulfillment creation. 

So in this case, you can use either Location A or Location B and it will work fine, provided that the items you're fulfilling are stocked at those locations. 

If you wanted to fulfill one item from Location A and the other from Location B as well, that is also possible - you would just need to do so with two separate fulfillments (one per location). 

0 Likes
New Member
2 0 2

Hi Josh,

Thank you for your reply.

I know we can create fulfillments for each location regardless from which location the inventory is decremented. And Shopify handles everything gracefully. But in our case we want to list the orders per location, so that a staff member at the specific location can print the shipping labels and fulfill the orders.

The Shopify Admin offers this functionality. You can now filter orders per location. Also, on the order detail page, you will see the location next to the order line items. And as you mentioned, you can change the location and even split the order for multiple locations. That's perfect. But when our clients click our action link "Print shipping label" (see screenshot), they get redirect to our app and we have no clue which location to use for the fulfillment. We can check inventory levels but changes are that the items are already out of stock because they are reserved for that order. 

That's why we have to know from which location Shopify decremented the stock.

2 Likes
Shopify Staff
Shopify Staff
1087 75 140

Hey again Evelyn, 

Sorry for the slow response here - currently though filtering orders by location via API isn't possible I'm afraid, though your use-case does sound like a good reason to have it.

I'll at the very least provide the feedback to the relevant parties here so that it can be considered for the future. As it stands right now though, where we've 'committed' inventory to currently isn't something that is surfaced publicly. 

0 Likes
New Member
1 0 1

Our Company is running into this same exact issue in trying to migrate a huge website to Shopify. Our Company uses ShipStation to centralize orders for six Shopify sites (potentially seven), since Shopify does not have a solution for centralizing orders.

If a Shopify user is using any kind of app to fulfill and/or Orders, there is nothing in the Shopify Order API before the Order is fulfilled, to tell you the Shopify location that should be fulfilling this order. There is an origin_location on the items before fulfillment, but it defaults whatever is set as the Default Origin in your Shipping Settings. So if you use an external fulfillment service, you have to manually do the work that Shopify has already automated. It's pretty ridiculous, and is a huge reason for us not to sign up for Shopify Plus, or migrate our main website to this platform.

 

1 Like
Tourist
6 0 3

Determining the "reserved location" is possible via the API.  The necessary data is present in order.draftFulfillments.

0 Likes
Excursionist
16 0 11

I'm also interested in using the API to retrieve the draft fulfilment for a given order, but am really struggling. Does anyone know how to query this? This is where I am but not working...

 

{
  order(id: "gid://shopify/Order/xxxxxxxxxxxxxx") {
    draftFulfillments {
      lineItems
    }
  }
}

Thanks in advance.

0 Likes
Tourist
6 0 3

Seems like you just need to pull some additional attributes  - give this a try:

 

{
    order(id: "gid://shopify/Order/xxxxxxxxxxxx") {
      draftFulfillments {
        lineItems {
          id
          fulfillableQuantity
        }
        service {
          location {
            id
            name
          }
        }
      }
    }
}
1 Like
Excursionist
16 0 11

Thank you! Unfortunately this query receives Internal error. Looks like something went wrong on our end. and it seems to be to do with service/location as taking this out and re-sending the request is valid. Any ideas?

0 Likes
Tourist
6 0 3

Some ideas:

  1. Is your store actually setup / enabled for locations?
  2. Do you have read permissions enabled for inventory?
1 Like