Fulfillable location ID in Order API

Highlighted
Shopify Expert
10 0 6

Hi all,

 

I have a question regarding the REST API for Orders, or it is more a 'feature request' ;)

It came to my attention that the fulfillable location is not in the JSON output of the API for an order.

 

So when an order is placed the unfulfilled items are listed in the order detail page. You can change the fulfillable location if you want. It would be very nice if it is possible to put this fulfillable location id in the JSON of the order (in the line_items section since an order can be fulfilled from 2 locations).

 

So when we fulfil the order through the API that we know what the current value is and we can just use this value directly in the fulfillment API request.

 

Thanks!

 

fulfillable-location.png

Developer at CODE Internet Applications | Delft | The Netherlands
3 Likes
Highlighted

+1 for this!

 

Just got a request for it recently from a customer of one of our apps.

Co-Founder / Developer at Highview Apps
Our Shopify Apps: EZ Exporter | EZ Inventory | EZ Importer | EZ Notify | EZ Fulfill
0 Likes
Highlighted
Tourist
6 0 3

+1 ! Any update on this ? 

In the graphql api there is the "DraftFulfillment" and we can get the location from "service.location" but the location name is different from the one shown on the order =/

0 Likes
Highlighted
Excursionist
12 0 3

Any update here?

Since its sortable and can be updated via UI, one would think it should be possible to access via API. Based on some research and checking the json payload, this doesn't seemed solved yet, hoping I'm wrong.

1 Like
Highlighted
Tourist
7 0 3

Is there a solution for this? Is this solved?

0 Likes
Highlighted
Shopify Partner
654 46 131

There has been a solution to this for awhile now. Either through the REST API (https://shopify.dev/docs/admin-api/rest/reference/inventory/inventorylevel?api[version]=2020-07), or the GraphQL API. You can get all of the information in one shot a lot easier through the GraphQL API in my opinion at least. So here's an example where you can query the API for a product variant and see fulfillable quantities at up to 10 fulfillment locations.

{
  productVariant(id: "gid://shopify/ProductVariant/31512998182964") {
    title
    id
    product {
      title
    }
    inventoryItem {
      id
      inventoryLevels(first: 10) {
        edges {
          node {
            id
            available
            location {
              id
              name
              address {
                address1
                address2
                city
                province
                country
                phone

              }
            }
          }
        }
      }
    }
  }
}

 

0 Likes
Highlighted
Excursionist
12 0 3

Hmm I don't believe this actually solves the current issue @Greg_Kujawa. If the specific Item has inventory at 2 locations both of these locations will appear in the Inventory Levels response. There doesn't seem to be a way to get the location_id for what is selected from the dropdown. 


If I'm mistaken, please let me know. I ran through the endpoints quickly with Postman to confirm. Product_variant -> Inventory_item -> Inventory_levels

 

Lasvad_1-1595953258686.png

 

 

0 Likes
Highlighted
Shopify Partner
654 46 131

So you actually tried the GraphQL example that I provided? It displays the id (i.e. - the location_id) and the name (i.e. - the display name, like in the Shopify web admin dropdown) in the results. I'll paste the raw data for the GraphQL API response that I received when I tried it. You can install the Shopify GraphiQL App as an app on a production store, test store, development store, etc. and test out API requests. It's pretty useful for learning how it works.

Specifically below, the  

...

"location": {
"id": "gid://shopify/Location/203128",
"name": "Sawmill",

...

is what you are looking for. In above, the 203128 is the location_id and Sawmill is the display name. Can't be much plainer than that?

 

 

{
  "data": {
    "productVariant": {
      "title": "Default Title",
      "id": "gid://shopify/ProductVariant/31512998182964",
      "product": {
        "title": "\"Be Own Kind of Beautiful\" Cuff"
      },
      "inventoryItem": {
        "id": "gid://shopify/InventoryItem/33055390433332",
        "inventoryLevels": {
          "edges": [
            {
              "node": {
                "id": "gid://shopify/InventoryLevel/4232978?inventory_item_id=33055390433332",
                "available": 2,
                "location": {
                  "id": "gid://shopify/Location/203128",
                  "name": "Sawmill",
                  "address": {
                    "address1": "6280 Sawmill Road",
                    "address2": "",
                    "city": "Dublin",
                    "province": "Ohio",
                    "country": "United States",
                    "phone": ""
                  }
                }
              }
            },
            {
              "node": {
                "id": "gid://shopify/InventoryLevel/17069604926?inventory_item_id=33055390433332",
                "available": 0,
                "location": {
                  "id": "gid://shopify/Location/17431658558",
                  "name": "Easton",
                  "address": {
                    "address1": "3960 New Bond Street",
                    "address2": "",
                    "city": "Columbus",
                    "province": "Ohio",
                    "country": "United States",
                    "phone": ""
                  }
                }
              }
            },
            {
              "node": {
                "id": "gid://shopify/InventoryLevel/17069637694?inventory_item_id=33055390433332",
                "available": 0,
                "location": {
                  "id": "gid://shopify/Location/17431691326",
                  "name": "Weber",
                  "address": {
                    "address1": "1523 East 15th Street",
                    "address2": "",
                    "city": "Tulsa",
                    "province": "Oklahoma",
                    "country": "United States",
                    "phone": ""
                  }
                }
              }
            }
          ]
        }
      }
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 35,
      "actualQueryCost": 14,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 986,
        "restoreRate": 50
      }
    }
  }
}

 

 

0 Likes
Highlighted
Excursionist
12 0 3

Appreciate the response @Greg_Kujawa, I used the rest endpoints for my test.

the solution you described returns all the locations that a specific product_variant has inventory at. 

What we are looking for is how to get the location_id for the selected dropdown location by only using the API.

Example using the data you provided

If in the Shopify UI we had selected `Sawmill` from the dropdown of an unfulfilled order, how would we be able to determine that from the response? The return has 3 different locations.

We need some way to get ether the name of the location, which can then be used to find the location_id from all the locations of the shop, or we need a `reference_location_id` that directly points to the location that is used for the dropdown on the unfulfilled order.

 

Please let me know if any piece is unclear. Happy to dive into more details.

 

Cheers

0 Likes
Highlighted
Shopify Partner
654 46 131

I thought you were looking to retrieve all of the location ID's and display names for a variant that's stocked. If you are just looking to pull any/all locations with their ID's and display names, then this is also something possible using the Shopify GraphQL API.

Here's a query. First 10 locations with this information:

 

{
    locationsAvailableForDeliveryProfilesConnection (first: 10) {
        edges {
            node {
                id
                name
            }
        }
    }
}

 

 

And here was the response that I got back:

 

{
  "data": {
    "locationsAvailableForDeliveryProfilesConnection": {
      "edges": [
        {
          "node": {
            "id": "gid://shopify/Location/203128",
            "name": "Sawmill"
          }
        },
        {
          "node": {
            "id": "gid://shopify/Location/17431658558",
            "name": "Easton"
          }
        },
        {
          "node": {
            "id": "gid://shopify/Location/17431691326",
            "name": "Weber"
          }
        },
        {
          "node": {
            "id": "gid://shopify/Location/18763743294",
            "name": "Green Hills"
          }
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 12,
      "actualQueryCost": 6,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 994,
        "restoreRate": 50
      }
    }
  }
}

 

So translating this to the Shopify web admin, if I were to pull down Sawmill in the location dropdown, this would map to location_id 203128 in the API. Does this make more sense?

 

0 Likes