Smart order routing: product based decision making

Hello Community,

I am in the process of reworking our custom fulfillment processes and I am trying to achieve the following:
On order placement, I want to choose a fulfillment channel for most or all of the products based on a ranking of the product with the respective fulfillment channel, but the products are available in both channels and both channels are available for the order (same market, same products in both, no general ranking between the locations possible)

  1. order is placed
  2. with the MIP (most important product from line_items) choose fulfillment channel based on product priority for the MIP/channel
  3. create fulfillment orders based on this information

I have a custom logic to do that, but it means I have to completely ignore the fulfillment order splits done by shopify and I would like to have shopify reflect the actual state of affairs.

From what I tried and read in the docs, this is not possible with the default routing services.
Can I somehow inject some custom logic into the smart order routing to create such functions?

Thank you so much in advance

Theo

Hi Theo,

It sounds like you’re trying to implement custom fulfillment logic that Shopify’s default routing doesn’t fully support. One approach could be to use Shopify Flow or a custom app/webhook to evaluate your Most Important Product (MIP) and assign fulfillment channels before the fulfillment orders are created.

You could:

  1. Capture the order creation event via a webhook.

  2. Run your custom logic to determine the fulfillment channel based on the MIP.

  3. Use the Fulfillment API to create fulfillment orders that reflect your logic, rather than relying on Shopify’s default split.

This way, Shopify will reflect the actual state without ignoring the system entirely.

Other Shopify partners have successfully used private apps or Flow + custom scripts to handle advanced routing like this.

Would love to hear if anyone else has implemented something similar!

Hello Theo,

You are correctm you can’t inject custom logic directly into Shopify’s Smart Order Routing. It’s a closed process.

However, you can achieve your goal. The solution is to build an app that corrects the routing immediately after the order is placed.

Here is the short workflow:

  1. Trigger: Use the orders/create webhook to start your process the moment an order is created.
  2. Decide: Your app runs its “Most Important Product” (MIP) logic to determine the correct fulfillment location for the order.
  3. Correct: Use the fulfillmentOrderMove GraphQL mutation to move all necessary line items from Shopify’s default split to the single fulfillment order associated with your chosen location.

Pro-Tip: To prevent your fulfillment services from acting on the wrong order split, use the fulfillmentOrderHold mutation at the start of your process and fulfillmentOrderReleaseHold after your logic is complete.

This approach gives you full control over routing while keeping Shopify’s data accurate.

Hi Theo,

You’re correct — Shopify’s default routing and smart order routing don’t currently allow you to inject custom logic like ranking fulfillment channels based on your own product priorities. Shopify’s system will always try to split fulfillment orders according to its standard logic (location availability, stock levels, etc.), and there isn’t a built-in way to override that with a custom ranking.

If you want Shopify to reflect your logic (instead of just handling it outside), you generally have two options:

Custom App or Fulfillment Service API

You can build (or use) a custom app that listens for the orders/create webhook.

On order creation, your app applies your logic (MIP → fulfillment channel ranking).

Then the app can call the FulfillmentOrder API to reassign or move fulfillment orders to the location you decide.

This essentially bypasses Shopify’s smart routing and enforces your own.

Manual Workaround with Locations/Priorities

If the logic is consistent enough, you can sometimes simulate it using multiple locations with priority settings.

But since you mentioned both channels are always valid and priorities are product-dependent, this probably won’t fit well.

Unfortunately, you can’t “inject” your code directly into smart order routing — it’s a black box. The supported way is to use the APIs/webhooks to restructure fulfillment orders after Shopify creates them.

So in short:

Default smart routing can’t do this.

Custom app + FulfillmentOrder API is the way to make it happen if you want Shopify to reflect your actual fulfillment logic.

Thanks

Hi Theo,

I came across your post about injecting custom logic into Shopify’s smart order routing.
I’m not looking to solve routing itself, but I’m researching a related gap:
Shopify doesn’t seem to have a native concept of “priority” across fulfillment decisions.

From your experience, would you say Shopify’s fulfillment model is fundamentally
optimized for execution rather than decision-making?

Just curious from a system-design perspective.

Hi @naokitakashima ,

imho shopify did a lot to improve over the last 2 years and I am quite happy with it.
Things like this order routing seem to have been planned and executed without a proper strategy in mind. It seems to me we only got an interface exposed to add to the logic it was already using.
So if it looks a little bare-bones to you, it probably is.

Solutions like the one above, where the shopify partner suggested to then instead completely circumvent the shopify processes for fulfillment creation to do it yourself are always possible. But I for one tend to not like this, as it is in no way future-proof, not adhering to the shopify way (even though this was suggested by a partner, as soon as something is amiss, it is gonna be on you to find out why) and not very practical at all.

We managed to implementa similar function by just using shopify functions in the meantime. It does its job. I have found the last year in particular to be very bountiful in terms of new features, that make sense from a devs perspective.
I think shopify strives to go from just execution to actually providing Quality-of-life improvements you enjoy working with.

I hope this helps.

For anyone curious:

We were able to implement this by creating a small custom app that sets a priority location for each product and a priority number.
The number determines the MIP, the location which fulfillment service to use.

This allows for a weighted response, that integrates with the existing logic in shopify functions for order routing. We created a block, that can be used the same as the shopify provided rules like “minimize splits”…

The function calculates each prio value and then uses simple weights (1/2 per priority level down) to priorize the associated location. If another rule already set the value to 0, it will not be considered further.