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

# Customer Rules

> Prioritize fulfillment locations based on who is placing the order

Customer rules let you prioritize locations based on **who is buying**. When specific customer types or segments place orders, you can control which locations should be preferred for fulfillment.

<Info>
  Unlike [fulfillment constraints](/constraints/customer-rules) which **block** locations, customer routing rules **prioritize** locations. If the preferred location is out of stock, Shopify automatically falls back to the next available location.
</Info>

## Constraints vs Routing

|                                       | Fulfillment Constraints                    | Order Routing Rules                                    |
| ------------------------------------- | ------------------------------------------ | ------------------------------------------------------ |
| **Effect**                            | Blocks locations entirely                  | Ranks locations by preference                          |
| **If no stock at preferred location** | Checkout blocked                           | Falls back to next priority                            |
| **Configured in**                     | Charlie app                                | Shopify Order Routing settings                         |
| **Use case**                          | "B2B orders can ONLY ship from warehouses" | "Prefer warehouse for B2B, but allow stores as backup" |

## How customer routing rules work

A customer routing rule has two parts:

1. **When** (condition): Which customers trigger the rule
2. **Then** (groups): How to rank locations when triggered

```mermaid theme={"system"}
flowchart LR
    A[Customer places<br/>order] --> B{Customer matches<br/>rule condition?}
    B -->|No| C[Default routing<br/>applies]
    B -->|Yes| D[Apply location<br/>group ranking]
    D --> E[Try Group 1 first]
    E --> F{Stock<br/>available?}
    F -->|Yes| G[✅ Fulfill from Group 1]
    F -->|No| H[Try Group 2]
    H --> I[Continue to next group...]
```

## Configure a customer routing rule

<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 Customer Rules rule">
    Find Charlie's **Customer Rules** and add it to your routing strategy.
  </Step>

  <Step title="Configure the condition (When)">
    Set up which customers trigger this rule:

    | Condition         | Description                                         |
    | ----------------- | --------------------------------------------------- |
    | **Customer B2B**  | Targets customers with a B2B account in Shopify     |
    | **Customer tags** | Targets customers based on tags assigned in Shopify |

    For **Customer tags**, choose the operator:

    | Operator             | Effect                                                       |
    | -------------------- | ------------------------------------------------------------ |
    | **Includes**         | Rule triggers when customer has any of the specified tags    |
    | **Does not include** | Rule triggers when customer does NOT have the specified tags |
  </Step>

  <Step title="Configure location groups (Then)">
    Create ranked groups of locations. Group 1 has highest priority, Group 2 is the fallback, and so on.

    For each group, click **Add selector** and choose how to select locations:

    | Selector type          | Description                          |
    | ---------------------- | ------------------------------------ |
    | **Specific locations** | Choose individual locations manually |
    | **Location type**      | All Warehouses or all Stores         |
    | **Location tag**       | Locations with specific tags         |

    <Tip>
      Locations that don't match any group will be ranked last.
    </Tip>
  </Step>

  <Step title="Enable the rule">
    Toggle the rule to **Enabled** when you're ready to apply it to live orders.
  </Step>
</Steps>

## Condition types

<Tabs>
  <Tab title="Customer B2B">
    Automatically targets customers who have a B2B account in Shopify.

    **Best for:**

    * Preferring warehouses for wholesale orders
    * Routing B2B to locations with bulk packaging
    * Separating B2B from B2C fulfillment flows

    <Info>
      This condition requires [Shopify B2B](https://help.shopify.com/en/manual/b2b) to be enabled on your store.
    </Info>
  </Tab>

  <Tab title="Customer tags">
    Targets customers based on tags you've assigned in Shopify.

    **Best for:**

    * VIP customers preferring flagship stores
    * Regional customers preferring local locations
    * Loyalty program members with dedicated fulfillment

    <Tip>
      Customer tags are managed in Shopify Admin under **Customers**. You can add tags manually or use Shopify Flow to automate tagging.
    </Tip>
  </Tab>
</Tabs>

## Examples

### B2B orders prefer warehouse

A wholesaler wants B2B orders to be fulfilled from warehouses when possible, with stores as backup.

<Steps>
  <Step title="Create the rule">
    * **Condition:** Customer B2B
    * **Operator:** Is B2B = true
  </Step>

  <Step title="Configure groups (Then)">
    * **Group 1:** Location type = Warehouse
    * **Group 2:** Location type = Store
  </Step>
</Steps>

**Result:** B2B orders prefer warehouses. If the warehouse is out of stock, stores can still fulfill. No checkout blocking.

***

### VIP customers prefer flagship stores

A luxury retailer wants VIP customers to receive orders from flagship stores with premium service, but allows other locations as backup.

<Steps>
  <Step title="Tag VIP customers">
    In Shopify Admin, add the tag `vip` to your VIP customers.
  </Step>

  <Step title="Tag flagship stores">
    Add the tag `flagship` to your flagship store locations.
  </Step>

  <Step title="Create the rule">
    * **Condition:** Customer tags
    * **Operator:** Includes
    * **Value:** `vip`
  </Step>

  <Step title="Configure groups (Then)">
    * **Group 1:** Location tag = `flagship`
    * **Group 2:** Location type = Warehouse
    * **Group 3:** Location type = Store
  </Step>
</Steps>

**Result:** VIP customers' orders prefer flagship stores. If out of stock, warehouses are tried, then other stores.

***

### Regional customers prefer local fulfillment

A retailer wants customers in specific regions to be served from nearby locations first.

<Steps>
  <Step title="Tag customers by region">
    Use Shopify Flow to automatically tag customers based on their shipping address (e.g., `east-coast`, `west-coast`).
  </Step>

  <Step title="Tag locations by region">
    Add regional tags to your locations (e.g., `east-coast`, `west-coast`).
  </Step>

  <Step title="Create rules for each region">
    **East Coast rule:**

    * **Condition:** Customer tags includes `east-coast`
    * **Group 1:** Location tag = `east-coast`
    * **Group 2:** All other locations

    **West Coast rule:**

    * **Condition:** Customer tags includes `west-coast`
    * **Group 1:** Location tag = `west-coast`
    * **Group 2:** All other locations
  </Step>
</Steps>

**Result:** Customers are served from their nearest region first, reducing shipping time and cost.

***

### New customers prefer warehouse (quality control)

A retailer wants orders from new customers to be fulfilled from warehouses where quality control is more consistent.

<Steps>
  <Step title="Tag verified customers">
    Use Shopify Flow to add a `verified` tag after a customer's first successful order.
  </Step>

  <Step title="Create the rule">
    * **Condition:** Customer tags
    * **Operator:** Does not include
    * **Value:** `verified`
  </Step>

  <Step title="Configure groups (Then)">
    * **Group 1:** Location type = Warehouse
    * **Group 2:** Location type = Store
  </Step>
</Steps>

**Result:** New customers (without the `verified` tag) prefer warehouse fulfillment for consistent quality.

## Combining with constraints

For maximum control, combine routing rules with constraints:

| Rule type        | Purpose                                        |
| ---------------- | ---------------------------------------------- |
| **Constraint**   | Block locations that absolutely cannot fulfill |
| **Routing rule** | Prioritize among remaining eligible locations  |

**Example: B2B fulfillment strategy**

1. **Fulfillment Constraint:** B2B customers → Include only locations tagged `b2b-enabled`
   → Non-B2B locations are **blocked**

2. **Customer Routing Rule:** B2B customers → Prefer locations tagged `bulk-packaging`
   → Bulk-capable locations are **preferred** among the eligible B2B locations

**Result:** B2B orders can only ship from B2B-enabled locations (constraint), and prefer those with bulk packaging (routing).

## Best practices

<CardGroup cols={2}>
  <Card title="Use routing for preferences" icon="arrow-trend-up">
    Use routing rules when you have preferences but can accept alternatives. Reserve constraints for hard requirements.
  </Card>

  <Card title="Automate customer tagging" icon="wand-magic-sparkles">
    Use Shopify Flow to automatically tag customers based on behavior, purchase history, or location.
  </Card>

  <Card title="Combine with inventory rules" icon="warehouse">
    Add Inventory Rules after Customer Rules to prefer locations with more stock among the prioritized group.
  </Card>

  <Card title="Test with different customer types" icon="flask">
    Place test orders as different customer types to verify routing behavior.
  </Card>
</CardGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="B2B orders not routing to expected locations">
    **Check:**

    1. Is the rule **enabled**?
    2. Is the customer actually a B2B customer in Shopify?
    3. Does the preferred location have stock?
    4. Are there constraint rules blocking the location?
    5. Is another routing rule with higher priority overriding this one?
  </Accordion>

  <Accordion title="Customer tags rule not triggering">
    **Check:**

    1. Does the customer actually have the tag in Shopify? (Check Customers → Customer profile)
    2. Is the tag spelled exactly the same? (Tags are case-sensitive)
    3. Is the operator correct? ("Includes" vs "Does not include")
  </Accordion>

  <Accordion title="Wrong group being selected">
    Remember: Shopify tries groups in order and uses the first one with available stock. If Group 1 is out of stock, it moves to Group 2 automatically.

    Verify stock levels at each location for the products in question.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Customer Constraints" icon="ban" href="/constraints/customer-rules">
    Block locations based on customers (hard rules)
  </Card>

  <Card title="Ranked Location Groups" icon="layer-group" href="/order-routing/ranked-location-groups">
    Create default location priorities
  </Card>

  <Card title="Cart Rules" icon="cart-shopping" href="/order-routing/cart-rules">
    Prioritize by cart properties
  </Card>

  <Card title="Location Tags" icon="tags" href="/locations/tags">
    Set up tags for flexible grouping
  </Card>
</CardGroup>
