> ## 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.

# Inventory Rules

> Automatically prioritize locations with the most available stock

Inventory rules automatically prioritize locations based on **how much stock they have**. Locations with more available inventory for the ordered products are ranked higher, helping reduce split shipments and balance stock across your network.

<Info>
  This is a "set it and forget it" rule. Once enabled, it automatically ranks locations by available stock—no configuration needed.
</Info>

## How inventory rules work

When a customer places an order, Charlie checks the **sellable inventory** at each location for the ordered products. Locations with more stock get higher priority.

```mermaid theme={"system"}
flowchart TD
    A[Order placed] --> B[Check sellable inventory<br/>at each location]
    B --> C[Rank locations by<br/>available quantity]
    C --> D[Location A: 50 units → Rank 1]
    C --> E[Location B: 30 units → Rank 2]
    C --> F[Location C: 10 units → Rank 3]
    D --> G[Try Location A first]
```

### What is sellable inventory?

Sellable inventory is the stock actually available for sale, calculated as:

```
Sellable = Available inventory - Safety stock
```

This ensures safety stock reserves are respected when ranking locations.

<Tip>
  Configure [safety stock rules](/inventory/safety-stock) to protect minimum inventory levels at each location.
</Tip>

## Why use inventory rules

<CardGroup cols={2}>
  <Card title="Reduce split shipments" icon="boxes-stacked">
    By preferring locations with more stock, orders are more likely to be fulfilled from a single location.
  </Card>

  <Card title="Balance inventory" icon="scale-balanced">
    Naturally draws down high-stock locations first, helping balance inventory across your network.
  </Card>

  <Card title="Improve fulfillment speed" icon="truck-fast">
    Locations with more stock can typically fulfill faster without waiting for replenishment.
  </Card>

  <Card title="No maintenance required" icon="wand-magic-sparkles">
    Rankings update automatically as inventory levels change—no manual configuration needed.
  </Card>
</CardGroup>

## Enable inventory rules

<Steps>
  <Step title="Access order routing settings">
    Go to **Charlie → Settings → Order routing** or **Shopify → Settings → Shipping and delivery → Order routing**.
  </Step>

  <Step title="Add the Inventory Rules rule">
    Find Charlie's **Inventory Rules** and add it to your routing strategy.
  </Step>

  <Step title="Enable the rule">
    Toggle the rule to **Enabled**. That's it—no additional configuration 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 the inventory rule" width="1330" height="214" data-path="images/order-routing-status-toggle.png" />
    </Frame>
  </Step>
</Steps>

<Note>
  Inventory rules require Charlie's inventory sync to be active. Make sure you've [configured inventory settings](/inventory/overview) in the Charlie app.
</Note>

## How ranking works

### Single product orders

For orders with one product, locations are ranked by their sellable quantity for that specific variant:

| Location    | Sellable inventory | Rank        |
| ----------- | ------------------ | ----------- |
| Warehouse A | 150 units          | 1 (highest) |
| Warehouse B | 80 units           | 2           |
| Store Paris | 25 units           | 3           |
| Store Lyon  | 10 units           | 4 (lowest)  |

### Multi-product orders

For orders with multiple products, Charlie calculates the **total sellable inventory** across all ordered items at each location:

**Example order:** 2x Product A + 1x Product B

| Location    | Product A | Product B | Total | Rank |
| ----------- | --------- | --------- | ----- | ---- |
| Warehouse A | 100       | 50        | 150   | 1    |
| Warehouse B | 60        | 40        | 100   | 2    |
| Store Paris | 20        | 10        | 30    | 3    |

### Tie-breaking

When multiple locations have the same total inventory, they receive the same rank. Shopify then uses its default logic to choose between them.

## Combining with other rules

Inventory rules work best when combined with other routing rules:

### With Ranked Location Groups

Use Ranked Groups as a primary filter, then Inventory Rules to optimize within groups:

1. **Ranked Location Groups:** Warehouses (Group 1) → Stores (Group 2)
2. **Inventory Rules:** Among warehouses, prefer those with most stock

**Result:** Orders go to warehouses first, and among warehouses, the one with most stock is preferred.

### With Customer Rules

Route customer segments to specific location types, then optimize by inventory:

1. **Customer Rules:** B2B customers → Prefer warehouses
2. **Inventory Rules:** Among preferred locations, use the one with most stock

**Result:** B2B orders go to the warehouse with the most available inventory.

### With Capacity Rules

Balance inventory optimization with operational capacity:

1. **Inventory Rules:** Prefer locations with most stock
2. **Capacity Rules:** Deprioritize locations at capacity

**Result:** Orders prefer high-stock locations, but avoid overloading busy ones.

## Example scenarios

### Reduce split shipments

**Problem:** Orders frequently ship from multiple locations, increasing shipping costs.

**Solution:** Enable Inventory Rules to prefer locations that can fulfill the complete order.

**How it helps:** A location with 50 units of Product A and 30 units of Product B ranks higher than one with 100 units of A but 0 units of B—making complete fulfillment more likely.

***

### Balance warehouse stock

**Problem:** One warehouse always runs low while another accumulates excess inventory.

**Solution:** Enable Inventory Rules to naturally draw down high-stock locations first.

**How it helps:** The warehouse with 500 units gets orders until it drops below the other warehouse's 300 units. Stock levels naturally balance over time.

***

### Optimize for fulfillment speed

**Problem:** Some locations frequently go out of stock mid-fulfillment, causing delays.

**Solution:** Enable Inventory Rules to prefer locations with comfortable stock levels.

**How it helps:** Locations with more inventory can fulfill without risk of stockouts during the fulfillment process.

## Best practices

<CardGroup cols={2}>
  <Card title="Combine with location groups" icon="layer-group">
    Use Ranked Groups to define location preferences, then Inventory Rules to optimize within those groups.
  </Card>

  <Card title="Configure safety stock" icon="shield">
    Set up safety stock rules to ensure the sellable inventory calculation respects your minimum reserves.
  </Card>

  <Card title="Keep inventory synced" icon="rotate">
    Ensure Charlie's inventory sync is running to maintain accurate stock data for ranking.
  </Card>

  <Card title="Monitor balance over time" icon="chart-line">
    Check if inventory is balancing as expected across locations after enabling the rule.
  </Card>
</CardGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Orders not going to highest-stock location">
    **Check:**

    1. Is the rule **enabled**?
    2. Is Charlie's inventory sync active and up to date?
    3. Are there other routing rules with higher priority overriding inventory rankings?
    4. Are there constraint rules blocking the high-stock location?
    5. Is safety stock reducing the sellable quantity below other locations?
  </Accordion>

  <Accordion title="Inventory data seems outdated">
    **Check:**

    1. Go to **Charlie → Settings → Inventory** and verify sync status
    2. Check when the last sync occurred
    3. Trigger a manual sync if needed
  </Accordion>

  <Accordion title="Split shipments still occurring">
    Inventory Rules prefer locations with more stock, but can't guarantee single-location fulfillment if:

    * No single location has all products in stock
    * Other rules override inventory-based ranking
    * Constraint rules limit eligible locations

    Consider adding [Fulfillment Constraints](/constraints/overview) to enforce single-location fulfillment for specific scenarios.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Inventory Overview" icon="boxes-stacked" href="/inventory/overview">
    Configure inventory sync settings
  </Card>

  <Card title="Safety Stock" icon="shield" href="/inventory/safety-stock">
    Protect minimum inventory levels
  </Card>

  <Card title="Capacity Rules" icon="gauge-high" href="/order-routing/capacity-rules">
    Balance inventory with operational capacity
  </Card>

  <Card title="Ranked Location Groups" icon="layer-group" href="/order-routing/ranked-location-groups">
    Define primary location preferences
  </Card>
</CardGroup>
