Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Order routing not respected when creating order through API

Order routing not respected when creating order through API

ben_baback
Shopify Partner
4 0 0

Hi, 

 

I implemented a specific order routing système in order to fulfilled the order from the good location.

When I create an order from the shopify dashboard, routing rules are used. However, when I create an order from API, the default location is always selected, meaning that routing rule are not used to determined the good location.

 

What can I do ? 

Thank you

Replies 2 (2)

Liam
Community Manager
3108 342 884

Hi Ben,

 

When creating an order through the API, Shopify's built-in routing rules are not used by default. Instead, the location from which the order is fulfilled is determined by the location_id value that you specify when you create a fulfillment through the API.

 

If you want to use Shopify's built-in routing rules when creating an order through the API, you'll need to use the FulfillmentOrder resource. This resource allows Shopify to determine the best location for fulfilling an order based on your routing rules.

 

Here's how you can do it:

  1. Create the order using the Order API, but do not specify a location_id.
  2. Next, retrieve the order's FulfillmentOrder objects using the FulfillmentOrder API. Each FulfillmentOrder object represents a group of items in the order that should be fulfilled from the same location.
  3. For each FulfillmentOrder, you can then create a fulfillment using the Fulfillment API. Shopify will automatically select the best location based on your routing rules.

You can check out our dev docs here for more details on using this resource. 

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

GhostApps1
Shopify Partner
34 0 0

Hi Advanced Fulfillment Rules can do this, you can target the country, state or zip code. It can also split orders between warehouses and select the warehouse closest to the delivery address.