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

# Cart Rules

> Control which locations can fulfill orders based on cart properties

Cart rules let you restrict fulfillment based on **cart properties**. When a cart meets specific criteria like total quantity, total amount, or contains items with specific attributes, you can control exactly which locations are allowed to fulfill the order.

<Info>
  Cart rules are ideal for routing high-value orders to secure locations, bulk orders to warehouses, or orders with special handling requirements to capable locations.
</Info>

## How cart rules work

A cart rule has two parts:

1. **When** (condition): Which cart properties trigger the rule
2. **Then** (filter): Which locations to block or allow when triggered

```mermaid theme={"system"}
flowchart LR
    A[Customer reaches<br/>checkout] --> B{Cart matches<br/>rule condition?}
    B -->|No| C[All locations<br/>eligible]
    B -->|Yes| D[Apply location<br/>filter]
    D --> E{Filter action}
    E -->|Include| F[Only specified<br/>locations can fulfill]
    E -->|Exclude| G[Specified locations<br/>blocked]
```

## Create a cart rule

<Steps>
  <Step title="Navigate to Fulfillment Constraints">
    Go to **Charlie → Fulfillment Constraints** and click **Create rule**.
  </Step>

  <Step title="Name your rule and set status">
    Enter a descriptive name (max 75 characters) that explains the rule's purpose, like "High-value orders - Warehouse only" or "Bulk orders - Distribution center".

    Set the **Status** to:

    * **Active**: Rule applies immediately at checkout
    * **Draft**: Rule is saved but won't affect checkout

    <Frame>
      <img src="https://mintcdn.com/charlie-6278c0d1/zIZXpEfAUH7cQkz5/images/constraints-cart-rule-form.png?fit=max&auto=format&n=zIZXpEfAUH7cQkz5&q=85&s=e6b30c00c7fbac24bb42da3359359702" alt="Cart rule form with name, status, and rule type" width="2194" height="1814" data-path="images/constraints-cart-rule-form.png" />
    </Frame>
  </Step>

  <Step title="Select Cart based as the rule type">
    Under **Rule type**, select **Cart based**.
  </Step>

  <Step title="Configure the condition (When)">
    In the **Configuration** section under **When**, set up what triggers the rule:

    **Condition**: Choose the cart property to evaluate

    <Frame>
      <img src="https://mintcdn.com/charlie-6278c0d1/zIZXpEfAUH7cQkz5/images/constraints-cart-condition.png?fit=max&auto=format&n=zIZXpEfAUH7cQkz5&q=85&s=92f9ca5328857907f53a20f939cccad4" alt="Condition dropdown showing Total cart quantity, Total cart amount, and Line item has attribute options" width="2248" height="1910" data-path="images/constraints-cart-condition.png" />
    </Frame>

    | Condition                   | Description                                    |
    | --------------------------- | ---------------------------------------------- |
    | **Total cart quantity**     | Total number of items in the cart              |
    | **Total cart amount**       | Total value of the cart in your store currency |
    | **Line item has attribute** | Items with specific custom attributes          |

    The available operators and value fields depend on the condition you select.
  </Step>

  <Step title="Configure the location filter (Then)">
    Under **Then**, define which locations are affected when the rule triggers:

    <Frame>
      <img src="https://mintcdn.com/charlie-6278c0d1/zIZXpEfAUH7cQkz5/images/constraints-cart-property.png?fit=max&auto=format&n=zIZXpEfAUH7cQkz5&q=85&s=b5e8bc451fd1804f16d1b5022eed7047" alt="Property dropdown showing Specific locations, Location with tag, and Location with type options" width="1802" height="574" data-path="images/constraints-cart-property.png" />
    </Frame>

    **Action:**

    | Action      | Effect                                                        |
    | ----------- | ------------------------------------------------------------- |
    | **Include** | Only the specified locations can fulfill (all others blocked) |
    | **Exclude** | The specified locations are blocked (all others allowed)      |

    **Property**: Choose how to target locations

    | Property               | Value                       | Use when                                         |
    | ---------------------- | --------------------------- | ------------------------------------------------ |
    | **Specific locations** | Select individual locations | You need precise control over specific locations |
    | **Location with tag**  | Enter tag names             | You want to target locations by capability       |
    | **Location with type** | Warehouse or Store          | You want to target all locations of a type       |
  </Step>

  <Step title="Save the rule">
    Click **Save** to create your rule. If set to Active, it takes effect immediately at checkout.
  </Step>
</Steps>

<Warning>
  You can create up to **10 configurable rules** total across Product, Customer, and Cart rule types. Plan your rules strategically.
</Warning>

## Condition types

<Tabs>
  <Tab title="Total cart quantity">
    Triggers based on the total number of items in the cart.

    **Operators available:**

    <Frame>
      <img src="https://mintcdn.com/charlie-6278c0d1/zIZXpEfAUH7cQkz5/images/constraints-cart-operator.png?fit=max&auto=format&n=zIZXpEfAUH7cQkz5&q=85&s=b2f524dd372751777a01e237f817b561" alt="Operator dropdown showing Equal, Not Equal, Greater Than, Less Than, Greater Than Or Equal, Less Than Or Equal" width="1376" height="544" data-path="images/constraints-cart-operator.png" />
    </Frame>

    | Operator                  | Description                                |
    | ------------------------- | ------------------------------------------ |
    | **Equal**                 | Cart has exactly this many items           |
    | **Not Equal**             | Cart does not have exactly this many items |
    | **Greater Than**          | Cart has more than this many items         |
    | **Less Than**             | Cart has fewer than this many items        |
    | **Greater Than Or Equal** | Cart has this many or more items           |
    | **Less Than Or Equal**    | Cart has this many or fewer items          |

    **Value**: Enter the quantity threshold

    **Best for:**

    * Routing bulk orders to warehouses
    * Limiting small stores to single-item orders
    * Handling large orders with dedicated fulfillment

    **Example:** Orders with more than 10 items should only be fulfilled from warehouses with bulk packaging capabilities.
  </Tab>

  <Tab title="Total cart amount">
    Triggers based on the total value of the cart in your store currency.

    **Operators available:** Same as Total cart quantity (Equal, Not Equal, Greater Than, Less Than, Greater Than Or Equal, Less Than Or Equal)

    **Value**: Enter the amount threshold (in your store currency)

    **Best for:**

    * High-value orders requiring secure handling
    * Premium orders with special packaging
    * Insurance or verification requirements

    **Example:** Orders over €500 should only be fulfilled from your central warehouse with dedicated security processes.
  </Tab>

  <Tab title="Line item has attribute">
    Triggers based on custom attributes attached to line items. This is the most flexible condition type.

    <Frame>
      <img src="https://mintcdn.com/charlie-6278c0d1/zIZXpEfAUH7cQkz5/images/constraints-cart-line-item-attribute.png?fit=max&auto=format&n=zIZXpEfAUH7cQkz5&q=85&s=07f6bbbea9097302ad1f82006a82a033" alt="Line item attribute configuration with attribute key and value fields" width="1488" height="726" data-path="images/constraints-cart-line-item-attribute.png" />
    </Frame>

    <Note>
      Constraint applies only to line items matching this attribute. Other items in the cart are not affected.
    </Note>

    **Operators available:**

    | Operator       | Description                     |
    | -------------- | ------------------------------- |
    | **Equal**      | Attribute value exactly matches |
    | **Not Equal**  | Attribute value does not match  |
    | **Is Set**     | Attribute exists (any value)    |
    | **Is Not Set** | Attribute does not exist        |

    **Fields:**

    * **Attribute key**: The name of the attribute (max 125 characters)
    * **Attribute value**: The value to match (max 125 characters, not required for Is Set/Is Not Set)

    **Best for:**

    * Gift wrapping or special packaging
    * Engraving or personalization
    * Pre-order or backorder items
    * Custom handling requirements

    **Example:** Items with a `gift_wrap` attribute set to `true` should only be fulfilled from locations with gift wrapping capabilities.

    <Tip>
      Line item attributes are typically set by your theme or custom app at cart/checkout. Common examples include gift messages, personalization text, or special handling instructions.
    </Tip>
  </Tab>
</Tabs>

## Location filters

<AccordionGroup>
  <Accordion title="Filter by specific locations">
    Select individual locations from your list. Use this when you need precise control.

    **Example setup:**

    * Action: **Include**
    * Property: **Specific locations**
    * Value: Central Warehouse, Secure Facility

    **Result:** Only the selected locations can fulfill orders matching the condition.
  </Accordion>

  <Accordion title="Filter by location tag">
    Target locations based on tags you've assigned. This is powerful for capability-based routing.

    **Example setup:**

    * Action: **Include**
    * Property: **Location with tag**
    * Value: `high-value-certified`

    **Result:** Only locations tagged `high-value-certified` can fulfill orders matching the condition.

    <Info>
      Make sure you've [set up location tags](/locations/tags) before using this filter.
    </Info>
  </Accordion>

  <Accordion title="Filter by location type">
    Target all Warehouses or all Stores at once.

    **Example setup:**

    * Action: **Include**
    * Property: **Location with type**
    * Value: Warehouse

    **Result:** Only warehouses can fulfill orders matching the condition; all stores are blocked.
  </Accordion>
</AccordionGroup>

## Examples

### High-value orders from warehouse only

A jewelry retailer wants to ensure orders over €500 are only fulfilled from their central warehouse where they have insurance verification and secure packaging.

<Steps>
  <Step title="Create the rule">
    * **Name:** High-value orders - Warehouse only
    * **Status:** Active
    * **Type:** Cart based
  </Step>

  <Step title="Set condition (When)">
    * **Condition:** Total cart amount
    * **Operator:** Greater Than
    * **Value:** 500
  </Step>

  <Step title="Set filter (Then)">
    * **Action:** Include
    * **Property:** Location with type
    * **Value:** Warehouse
  </Step>
</Steps>

**Result:** Orders over €500 are fulfilled exclusively from warehouses with proper security handling.

***

### Bulk orders to distribution center

A wholesaler wants orders with more than 20 items to be fulfilled only from their distribution center equipped for bulk packaging.

<Steps>
  <Step title="Tag your distribution center">
    Go to [Locations](/locations/overview) and add the tag `bulk-capable` to your distribution center.
  </Step>

  <Step title="Create the rule">
    * **Name:** Bulk orders - Distribution center
    * **Status:** Active
    * **Type:** Cart based
  </Step>

  <Step title="Set condition (When)">
    * **Condition:** Total cart quantity
    * **Operator:** Greater Than
    * **Value:** 20
  </Step>

  <Step title="Set filter (Then)">
    * **Action:** Include
    * **Property:** Location with tag
    * **Value:** `bulk-capable`
  </Step>
</Steps>

**Result:** Large orders are routed to locations equipped to handle bulk fulfillment.

***

### Gift-wrapped items from flagship stores

A fashion brand offers gift wrapping, but only flagship stores have the premium packaging materials and trained staff.

<Steps>
  <Step title="Tag flagship stores">
    Add the tag `gift-wrap-capable` to stores with gift wrapping services.
  </Step>

  <Step title="Create the rule">
    * **Name:** Gift wrap - Flagship stores only
    * **Status:** Active
    * **Type:** Cart based
  </Step>

  <Step title="Set condition (When)">
    * **Condition:** Line item has attribute
    * **Operator:** Equal
    * **Attribute key:** `gift_wrap`
    * **Attribute value:** `true`
  </Step>

  <Step title="Set filter (Then)">
    * **Action:** Include
    * **Property:** Location with tag
    * **Value:** `gift-wrap-capable`
  </Step>
</Steps>

**Result:** Items with gift wrapping are only fulfilled from stores with gift wrapping capabilities.

<Info>
  Remember: with Line item has attribute, only the specific items matching the attribute are constrained. Other items in the same cart can be fulfilled from any location.
</Info>

***

### Exclude small stores from large orders

A retailer has small urban stores with limited inventory and packing space. Orders with more than 5 items should skip these locations.

<Steps>
  <Step title="Tag small stores">
    Add the tag `small-store` to locations with limited capacity.
  </Step>

  <Step title="Create the rule">
    * **Name:** Large orders - No small stores
    * **Status:** Active
    * **Type:** Cart based
  </Step>

  <Step title="Set condition (When)">
    * **Condition:** Total cart quantity
    * **Operator:** Greater Than
    * **Value:** 5
  </Step>

  <Step title="Set filter (Then)">
    * **Action:** Exclude
    * **Property:** Location with tag
    * **Value:** `small-store`
  </Step>
</Steps>

**Result:** Orders with more than 5 items skip small stores and are routed to larger locations or warehouses.

## Best practices

<CardGroup cols={2}>
  <Card title="Use quantity for operational limits" icon="boxes-stacked">
    Set quantity thresholds based on what your locations can realistically pack and ship in a timely manner.
  </Card>

  <Card title="Use amount for risk management" icon="shield">
    Route high-value orders to locations with proper insurance, security, and verification processes.
  </Card>

  <Card title="Use attributes for special handling" icon="wand-magic-sparkles">
    Leverage line item attributes for personalization, gift services, or custom requirements that need specific capabilities.
  </Card>

  <Card title="Test with Draft status" icon="flask">
    Create rules in Draft mode first, verify the logic with test orders, then activate.
  </Card>
</CardGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="High-value orders see 'no shipping options'">
    This means all locations with stock are blocked for orders meeting the amount threshold.

    **Check:**

    1. Does at least one allowed location have all products in stock?
    2. Is your amount threshold in the correct currency?
    3. Are there conflicting rules blocking all locations?

    **Quick fix:** Set the rule to Draft temporarily to restore checkout.
  </Accordion>

  <Accordion title="Line item attribute rule doesn't apply">
    **Check:**

    1. Is the rule status set to **Active**?
    2. Is the attribute key spelled exactly right (case-sensitive)?
    3. Is the attribute actually being set on the line item? Check the cart/checkout payload.
    4. If using "Equal", does the value match exactly?

    **Debug tip:** Use your browser's developer tools to inspect the cart data and verify the attribute is present.
  </Accordion>

  <Accordion title="Rule applies when it shouldn't">
    **Check:**

    1. Is the operator correct? ("Greater Than" vs "Greater Than Or Equal")
    2. For amounts, are you using the right currency value?
    3. For quantities, remember it's total items, not unique products

    **Example:** "Greater Than 5" triggers at 6+ items, not at 5. Use "Greater Than Or Equal 5" to include 5.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Product Rules" icon="box" href="/constraints/product-rules">
    Restrict locations based on what's in the cart
  </Card>

  <Card title="Customer Rules" icon="user" href="/constraints/customer-rules">
    Restrict locations based on who is buying
  </Card>

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

  <Card title="Order Routing" icon="route" href="/order-routing/overview">
    Prioritize locations instead of blocking them
  </Card>
</CardGroup>
