> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usecharlie.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Understand how order routing controls which locations fulfill orders and in what priority

Order routing determines **where** your orders are fulfilled from when multiple locations have available inventory. Charlie extends Shopify's native order routing with powerful rules that let you optimize fulfillment based on your business needs.

## Constraints vs Routing rules

Charlie offers two complementary ways to control fulfillment:

<CardGroup cols={2}>
  <Card title="Fulfillment Constraints" icon="ban" href="/constraints/overview">
    **Block** locations from fulfilling specific orders. Hard rules that completely remove locations from consideration.
  </Card>

  <Card title="Order Routing Rules" icon="arrow-down-1-9">
    **Prioritize** locations for fulfillment. Soft rules that rank locations by preference without blocking any.
  </Card>
</CardGroup>

|                   | Fulfillment Constraints                          | Order Routing Rules                         |
| ----------------- | ------------------------------------------------ | ------------------------------------------- |
| **Effect**        | Blocks locations entirely                        | Ranks locations by priority                 |
| **When no match** | Checkout blocked, no shipping options            | Falls back to next priority                 |
| **Risk level**    | High (can block checkout)                        | Low (always has fallback)                   |
| **Use case**      | Hard business requirements                       | Optimization preferences                    |
| **Example**       | "Fragile items can NEVER ship from small stores" | "Prefer warehouse first, then large stores" |

<Tip>
  **Rule of thumb:** Use constraints when a location **must not** fulfill certain orders under any circumstances. Use routing rules when you **prefer** certain locations but can accept alternatives.
</Tip>

## How order routing works

When a customer reaches checkout, Shopify processes fulfillment in this order:

```mermaid theme={"system"}
flowchart TD
    A[Customer checkout] --> B[Apply Fulfillment Constraints]
    B --> C{Any locations<br/>remaining?}
    C -->|No| D[❌ Checkout blocked]
    C -->|Yes| E[Apply Order Routing Rules]
    E --> F[Rank remaining locations]
    F --> G[Check inventory at top-ranked location]
    G --> H{Stock<br/>available?}
    H -->|Yes| I[✅ Fulfill from this location]
    H -->|No| J[Try next-ranked location]
    J --> G
```

## Where to configure order routing

<Note>
  Charlie's order routing rules are configured in **Shopify's Order Routing settings**. You can access these settings either from Charlie or directly from Shopify.
</Note>

Charlie's routing rules are **Shopify Functions** that integrate directly into Shopify's Order Routing. This means you can combine Charlie's rules with Shopify's native routing options in one place.

<Tabs>
  <Tab title="From Charlie">
    1. Open the Charlie app
    2. Go to **Settings**
    3. Under **Order management**, click **Order routing**

    This takes you directly to Shopify's Order Routing settings.
  </Tab>

  <Tab title="From Shopify">
    1. In your Shopify admin, go to **Settings**
    2. Click **Shipping and delivery**
    3. Scroll to **Order routing**
  </Tab>
</Tabs>

Both paths lead to the same place — choose whichever is most convenient for you.

### Enable or disable rules

Each routing rule can be **enabled or disabled** independently. This allows you to:

* **Build rules in advance** without affecting live orders
* **Test configurations** before activating them
* **Quickly disable a rule** if issues arise, without deleting it
* **Prepare for peak seasons** by pre-configuring rules and enabling them when needed

<Frame>
  <img src="https://mintcdn.com/charlie-6278c0d1/zIZXpEfAUH7cQkz5/images/order-routing-status-toggle.png?fit=max&auto=format&n=zIZXpEfAUH7cQkz5&q=85&s=1b1a416422fb9189dba60ac76880a94b" alt="Status toggle to enable or disable an order routing rule" width="1330" height="214" data-path="images/order-routing-status-toggle.png" />
</Frame>

<Tip>
  Create and configure your routing rules ahead of time, then enable them when you're ready to go live. This is especially useful for seasonal strategies like Black Friday.
</Tip>

## Available routing rules

Charlie provides eight types of order routing rules:

<AccordionGroup>
  <Accordion title="Ranked Location Groups" icon="layer-group">
    Create prioritized groups of locations. Orders are routed to the highest-priority group with available stock.

    **Use cases:**

    * Prefer warehouses over stores
    * Prioritize locations by region
    * Create fallback hierarchies

    **Example:** Group 1 (Central Warehouse) → Group 2 (Regional Warehouses) → Group 3 (Stores)

    [Learn more →](/order-routing/ranked-location-groups)
  </Accordion>

  <Accordion title="Product Rules" icon="box">
    Prioritize locations based on what products are in the cart.

    **Use cases:**

    * Route specific brands to dedicated locations
    * Prioritize collections to certain stores
    * Handle product-specific fulfillment preferences

    **Example:** Premium products → Flagship stores first

    [Learn more →](/order-routing/product-rules)
  </Accordion>

  <Accordion title="Customer Rules" icon="user">
    Prioritize locations based on who is placing the order.

    **Use cases:**

    * B2B customers → Warehouse priority
    * VIP customers → Premium locations
    * Regional customers → Local stores

    **Example:** B2B orders → Distribution center first

    [Learn more →](/order-routing/customer-rules)
  </Accordion>

  <Accordion title="Cart Rules" icon="cart-shopping">
    Prioritize locations based on cart properties like quantity, amount, or line item attributes.

    **Use cases:**

    * Large orders → Bulk fulfillment centers
    * High-value orders → Secure locations
    * Gift-wrapped items → Stores with gift services

    **Example:** Orders > 10 items → Warehouse first

    [Learn more →](/order-routing/cart-rules)
  </Accordion>

  <Accordion title="Inventory Rules" icon="warehouse">
    Automatically prioritize locations with more available stock.

    **Use cases:**

    * Reduce split shipments
    * Balance inventory across locations
    * Prefer locations that can fulfill complete orders

    **Example:** Location with most stock → Highest priority

    [Learn more →](/order-routing/inventory-rules)
  </Accordion>

  <Accordion title="Capacity Rules" icon="gauge-high">
    Prioritize locations based on their current fulfillment capacity.

    **Use cases:**

    * Avoid overloading busy locations
    * Balance workload during peak periods
    * Route away from locations at capacity

    **Example:** Location with most available capacity → Highest priority

    [Learn more →](/order-routing/capacity-rules)
  </Accordion>

  <Accordion title="Backlog Routing" icon="list-check">
    Prioritize locations based on how many open, unfulfilled orders they currently have. Optionally block locations once their backlog crosses a threshold.

    **Use cases:**

    * Balance pipeline depth across stores
    * Protect small locations from overload
    * Combine soft preference (short backlog) with hard cap (block when backlog exceeds threshold)

    **Example:** Location with fewer pending orders → Higher priority

    [Learn more →](/order-routing/backlog-routing)
  </Accordion>

  <Accordion title="Performance Routing" icon="stopwatch">
    Rank locations into performance tiers by a metric like average time to ship, and route to your fastest performers first.

    **Use cases:**

    * Prefer locations that ship fastest
    * Steer volume toward your best-performing stores
    * Combine speed with stock and capacity signals

    **Example:** Location shipping in under 24h → Higher priority

    [Learn more →](/order-routing/analytics-metric)
  </Accordion>
</AccordionGroup>

## Combining rules

You can use multiple routing rules together. Shopify evaluates them in the order you set:

```mermaid theme={"system"}
flowchart LR
    A[All locations] --> B[Rule 1:<br/>Customer Rules]
    B --> C[Rule 2:<br/>Inventory Rules]
    C --> D[Rule 3:<br/>Capacity Rules]
    D --> E[Final ranking]
```

<Warning>
  The order matters! Rules earlier in the list have higher priority. If Rule 1 assigns a location rank 1, subsequent rules refine the ranking within that constraint.
</Warning>

### Example: Optimized B2B fulfillment

A wholesaler wants to:

1. Route B2B orders to warehouses first
2. Among warehouses, prefer those with more stock
3. Avoid locations at capacity

**Setup:**

1. **Customer Rules:** B2B customers → Warehouse group priority
2. **Inventory Rules:** Rank by available stock
3. **Capacity Rules:** Deprioritize locations at capacity

**Result:** B2B orders go to the warehouse with the most stock that isn't at capacity.

## Constraints + Routing: Working together

For complex fulfillment strategies, combine constraints and routing rules:

| Layer | Type              | Purpose                                         |
| ----- | ----------------- | ----------------------------------------------- |
| 1️⃣   | **Constraints**   | Remove ineligible locations (hard requirements) |
| 2️⃣   | **Routing rules** | Rank remaining locations (optimization)         |
| 3️⃣   | **Shopify**       | Select location with stock at best rank         |

### Example: Fragile items strategy

**Business requirement:** Fragile items should never ship from small stores, and should prefer the central warehouse.

**Setup:**

1. **Fulfillment Constraint (Product Rule):**
   * Condition: Products in "Fragile Items" collection
   * Filter: Exclude locations tagged `small-store`
   * Effect: Small stores are **blocked**
2. **Order Routing (Ranked Groups):**
   * Group 1: Central Warehouse
   * Group 2: Large stores
   * Effect: Central warehouse is **preferred**

**Result:**

* Small stores can never fulfill fragile items (constraint)
* Central warehouse is tried first (routing)
* Large stores are the fallback (routing)
* If all are out of stock, checkout is blocked (no eligible location)

## Best practices

<CardGroup cols={2}>
  <Card title="Start with routing rules" icon="play">
    Routing rules are safer since they never block checkout. Add constraints only for hard requirements.
  </Card>

  <Card title="Use inventory rules for efficiency" icon="chart-line">
    Inventory-based routing automatically reduces split shipments and balances stock levels.
  </Card>

  <Card title="Combine with capacity management" icon="gauge">
    Add capacity rules to prevent overloading locations during peak periods.
  </Card>

  <Card title="Test before peak seasons" icon="calendar">
    Verify your routing strategy with test orders before high-volume periods like Black Friday.
  </Card>
</CardGroup>

## Related

<CardGroup cols={2}>
  <Card title="Fulfillment Constraints" icon="ban" href="/constraints/overview">
    Block locations from fulfilling specific orders
  </Card>

  <Card title="Location Tags" icon="tags" href="/locations/tags">
    Set up tags to use in your routing rules
  </Card>

  <Card title="Location Capacity" icon="gauge-high" href="/locations/capacity">
    Configure capacity limits for your locations
  </Card>
</CardGroup>
