Hi,
I am creating orders via API, and for each line item I am including the Product id, the ProductVariant id and the fulfillmentService id. If inventory levels were good, this used to result in the order getting created and assigned to my fulfillment service. However, now orders are getting assigned to Shop Location.
I assume it was a change in the API but I could not find it. Any here knows how to accomplish this?
Thanks
1 Like
Hey @ChrisGU, this is expected behavior.
When you create an order, the stores Order Routing Rules evaluate after creation and assign the order based on their logic (minimize split fulfillments, stay within market, ship from closest location, etc.). The fulfillmentService field you’re passing gets overridden during this process.
The solution here is to use the order.fulfillment.locationId field instead, which bypasses Order Routing Rules:
mutation CreateOrderWithGuaranteedLocation {
orderCreate(
order: {
lineItems: [
{
variantId: "gid://shopify/ProductVariant/YOUR_VARIANT_ID"
quantity: 1
}
]
email: "customer@example.com"
fulfillment: {
locationId: "gid://shopify/Location/YOUR_FULFILLMENT_SERVICE_LOCATION_ID"
notifyCustomer: true
}
}
options: {
inventoryBehaviour: DECREMENT_OBEYING_POLICY
}
) {
order {
id
name
}
userErrors {
field
message
}
}
}
For context, the orderCreate mutation documentation includes an example of this under “Create an order with fulfillment details.”
If you need custom routing logic (rather than direct assignment), you can build an order routing app using Functions. This lets merchants add custom location rules to their routing strategy (e.g., “prioritize locations in buyer’s country”).
Hey @ChrisGU, does the above help clarify this behaviour you are seeing?
Hi,
I did try this but the order still got assigned to Shop Location. I confirmed that the item in the order has inventory for that location available. Also, at the item level I am specifying the fulfillmentService handle and ProductVariantId.
Is there anything else I could try?
Thanks!
Interesting. What are the current order routing rules for the shop where this is happening? Does that align with what you’re seeing?
I see the following routing rules in this order
-Minimize split fulfillments
-Stay within the destination market
-Ship from the closest location
For the fulfillment service I have added the Shipping Zone as well, not sure if that is needed.
Anything else I should check?
I set up my fulfillment rules the same as you have, and still the orderCreate with order.fulfillment.locationId is being applied regardless.
Can you share examples of your mutations and the x-request-id returned in the response headers? That should help give me a more clear picture of what’s happening.
Hey Chris, are you still experiencing this issue, or can I mark this as solved?
Hey Kyle,
It is working now! I guess it was a temporary behavior on Shopify. I will open a new conversation it it ever happens again. Thanks!
1 Like