Is there any way to get default location id using GraphQL?

Highlighted
Excursionist
38 0 1

I can get all active locations but I am not sure how I can get default location which is set as default in Shopify Admin.

0 Likes
Highlighted
New Member
7 0 0

We have similar problem too.

Is it possible to get the default location via restful API?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
622 95 110

Hey @Yu727 and @john91 ,

 

Currently, the best way to get the default location / primary location of a Shopify Store is to use the REST Admin API and send a GET request to the end point of "admin/api/2020-01/shop.json". The value you are looking for will be in the field "primary_location_id". https://help.shopify.com/en/api/reference/store-properties/shop

 

However you will see through the documentation that this field is headed towards deprecation. That is because as Shopify shifts toward the concept of multiple locations, the concept of a 'default' or 'primary' location goes away. If you're using this field for fulfillment or inventory management purposes, in the long run it's likely safer to look up the location that inventory has been stocked at using either this guide (if you're creating or managing fulfillments) or this guide (if you're updating inventory)

 

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

0 Likes
Highlighted
Excursionist
38 0 1

Hi @hassain 

Thank you for your time with us!

 

primary_location_id can help me.

I am going to manage fulfillment with default location so I checked your second suggested way.

 

This guide describes how to manage fulfillments without the concept of Fulfillment Orders (valid for the 2019-10 API version and earlier). For a guide that describes how to manage fulfillments by using Fulfillment Orders, see Managing fulfillments with the FulfillmentOrder resource.

But it looks like we can't use this with current API version(2020-01).

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
622 95 110

Hey @Yu727 ,

 

Yes you are correct, for API version 2020-01 and up FulfillmentOrders is the best way to manage fulfillments. Thank you for bringing this up!

 

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

0 Likes
Highlighted
Tourist
4 0 0

> That is because as Shopify shifts toward the concept of multiple locations, the concept of a 'default' or 'primary' location goes away.

@hassainBUT, you still need a "default" fulfillment location for orders for 2 reasons.

 

1. Because there needs to be a location where inventory is deducted from before the order ships. The reason for this is to make sure more is not sold than is in inventory. ie. If the "online store"'s default shipping (fulfillment) location has 10 units, and all 10 are sold, the product is now out-of-stock and can't be bought anymore.

2. The "default" location is also what might be displayed on the "online store" to show something like "Only 1 more remaining" so customers know that if they wait they might miss out.

Can you explain how those two use-cases for a default might disappear?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
622 95 110

Hey @hardwoodmarble ,

 

Just to be clear, moving away from the concept of "default" or primary location does not mean that when Orders are created they will not be assigned any locations or that inventory won't be deprecated when an order is made. When Orders are are made, all of the line items in the order are assigned a location. By default Shopify will always try to fulfil all the line items from the same location whenever possible, so if all the line items can be fulfilled using the stock at a single location, then the unfulfilled section will show all of the items in the order listed together. If the order can't be fulfilled using the stock at a single location, then the unfulfilled section will show the available items listed by location.

Through the Shopify Web Admin, or the Admin API, you can see which location each line item in the Order is assigned to and you can update it if you choose before starting the fulfillment. Inventory levels will be deducted for the location the line item is assigned to, so you have no issues of inventory levels not being deducted or not being able to report inventory quantity on the storefront or items that are out of stock being available to be purchased online.  

 

For more information you can follow these documents: https://help.shopify.com/en/manual/locations/managing-orders
https://shopify.dev/tutorials/manage-fulfillments-with-fulfillment-and-fulfillmentservice-resources (if you are using API version equal or below 2019-10)
https://shopify.dev/tutorials/manage-fulfillments-with-fulfillment-and-fulfillmentorder-resources (if you are using API version greater than 2020-01)

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

0 Likes