> For the complete documentation index, see [llms.txt](https://responsive-media.gitbook.io/advanced-free-shipping/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://responsive-media.gitbook.io/advanced-free-shipping/core-concepts/and-vs-or-logic.md).

# AND vs OR Logic

## Understanding the Difference

The key to creating effective shipping discounts is understanding when to use:

* **Multiple Conditions** (AND logic) - All must be true
* **Multiple Rule Groups** (OR logic) - Any one can be true

## AND Logic: Multiple Conditions

When you add multiple conditions to a **single rule group**, they use AND logic. **All conditions must be met** for the discount to apply.

### Visual Representation

```mermaid
graph LR
    Condition1[Condition 1: Cart ≥ $50] --> AND{AND}
    Condition2[Condition 2: Country = US] --> AND
    AND --> Result{Both True?}
    Result -->|Yes| Discount[Apply Discount]
    Result -->|No| NoDiscount[No Discount]
```

### Example: Free Shipping for US Orders Over $50

**Configuration**:

* Rule Group 1:
  * Condition 1: Cart total ≥ $50
  * Condition 2: Country is US

**How it evaluates**:

* Cart is $60, customer in US → ✓ Both true → Discount applies
* Cart is $60, customer in Canada → ✗ Only one true → No discount
* Cart is $40, customer in US → ✗ Only one true → No discount

{% hint style="info" %}
Think of AND as "all of these requirements together." The customer must meet every single condition.
{% endhint %}

### Common AND Logic Use Cases

{% tabs %}
{% tab title="Geographic + Value" %}
**Free shipping for California orders over $50**

* Condition 1: Province is CA
* Condition 2: Cart total ≥ $50

Both geography and value must match.
{% endtab %}

{% tab title="Product + Customer" %}
**Free shipping on winter coats for VIP customers**

* Condition 1: Product contains "Winter Coat"
* Condition 2: Customer tag contains "VIP"

Must have the product AND be a VIP.
{% endtab %}

{% tab title="Multiple Products" %}
**Free shipping when cart has both Product A and Product B**

* Condition 1: Product contains "Product A"
* Condition 2: Product contains "Product B"

Both products must be in cart.
{% endtab %}

{% tab title="Value + Weight" %}
**Free shipping for heavy orders over $100**

* Condition 1: Cart total ≥ $100
* Condition 2: Cart weight ≥ 20 lbs

Must meet both value and weight requirements.
{% endtab %}
{% endtabs %}

***

## OR Logic: Multiple Rule Groups

When you create **multiple rule groups**, they use OR logic. **Any one rule group** can trigger the discount.

### Visual Representation

```mermaid
graph TD
    Start[Customer at Checkout] --> Group1{Rule Group 1:<br/>VIP Customer?}
    Group1 -->|Yes| Discount[Apply Discount]
    Group1 -->|No| Group2{Rule Group 2:<br/>Cart ≥ $100?}
    Group2 -->|Yes| Discount
    Group2 -->|No| NoDiscount[No Discount]
```

### Example: Free Shipping for VIPs OR High-Value Orders

**Configuration**:

* Rule Group 1:
  * Condition: Customer tag contains "VIP"
* Rule Group 2:
  * Condition: Cart total ≥ $100

**How it evaluates**:

* VIP customer, $30 cart → ✓ Rule Group 1 met → Discount applies
* Regular customer, $150 cart → ✓ Rule Group 2 met → Discount applies
* VIP customer, $150 cart → ✓ Both rule groups met → Discount applies
* Regular customer, $30 cart → ✗ Neither rule group met → No discount

{% hint style="info" %}
Think of OR as "any of these paths works." The customer only needs to meet one complete rule group.
{% endhint %}

### Common OR Logic Use Cases

{% tabs %}
{% tab title="VIP or High Value" %}
**Free shipping for VIPs or anyone spending $100+**

* Rule Group 1: Customer tag contains "VIP"
* Rule Group 2: Cart total ≥ $100

VIPs always qualify, OR high spenders qualify.
{% endtab %}

{% tab title="Multiple Regions" %}
**Different thresholds for different countries**

* Rule Group 1:
  * Country is US
  * Cart total ≥ $50
* Rule Group 2:
  * Country is CA
  * Cart total ≥ $75

US customers need $50 OR Canadian customers need $75.
{% endtab %}

{% tab title="Product Options" %}
**Free shipping on Collection A or Collection B**

* Rule Group 1: Collection contains "Summer Sale"
* Rule Group 2: Collection contains "Clearance"

Either collection triggers the discount.
{% endtab %}

{% tab title="Customer Segments" %}
**Free shipping for first-time customers or loyalty members**

* Rule Group 1: Customer order count = 0
* Rule Group 2: Customer tag contains "Loyalty"

New customers OR loyalty members qualify.
{% endtab %}
{% endtabs %}

***

## Combining AND + OR Logic

The most powerful discounts combine both:

### Example: Regional Tiered Discount

**Goal**: Free shipping for:

* US orders over $50, OR
* Canadian orders over $75, OR
* VIP customers anywhere

**Configuration**:

```
Rule Group 1 (US High Value):
  - Condition 1: Country is US (AND)
  - Condition 2: Cart total ≥ $50 (AND)

Rule Group 2 (CA High Value):
  - Condition 1: Country is CA (AND)
  - Condition 2: Cart total ≥ $75 (AND)

Rule Group 3 (VIP):
  - Condition 1: Customer tag contains "VIP"
```

**How it evaluates**:

* US customer, $60 cart → Rule Group 1 ✓ → Discount
* CA customer, $80 cart → Rule Group 2 ✓ → Discount
* VIP customer, $20 cart, any country → Rule Group 3 ✓ → Discount
* UK customer, $100 cart → No rule group ✗ → No discount

### Example: Product Bundle Discount

**Goal**: Free shipping when customer buys:

* Product A AND Product B, OR
* 3+ items from Collection C

**Configuration**:

```
Rule Group 1 (Bundle):
  - Condition 1: Product contains "Product A" (AND)
  - Condition 2: Product contains "Product B" (AND)

Rule Group 2 (Collection Quantity):
  - Condition 1: Collection "Collection C" (AND)
  - Condition 2: Collection item quantity ≥ 3 (AND)
```

***

## Decision Guide

### Use Multiple Conditions (AND) When:

* **Narrowing Requirements** - You want to be MORE restrictive. Each condition narrows who qualifies.
* **Combined Criteria** - Multiple things must be true simultaneously (location + value, product + customer, etc.).

### Use Multiple Rule Groups (OR) When:

* **Broadening Eligibility** - You want to be MORE inclusive. Each rule group adds another way to qualify.
* **Alternative Paths** - Different customer segments should qualify through different criteria.

***

## Common Patterns

### Pattern 1: Tiered by Value

Create multiple rule groups with increasing cart values:

```
Rule Group 1: Cart ≥ $30 → 25% off shipping
Rule Group 2: Cart ≥ $50 → 50% off shipping
Rule Group 3: Cart ≥ $75 → Free shipping
```

{% hint style="info" %}
Shopify evaluates discounts and applies the best one. If a customer qualifies for multiple, they get the highest discount.
{% endhint %}

### Pattern 2: Regional Variations

Different requirements for different regions:

```
Rule Group 1: US + $50 cart
Rule Group 2: CA + $75 cart
Rule Group 3: UK + $100 cart
```

### Pattern 3: Customer Segments

Different paths for different customer types:

```
Rule Group 1: VIP tag (no other requirements)
Rule Group 2: Loyalty tag + $50 cart
Rule Group 3: First-time customer + specific product
```

### Pattern 4: Product Promotions

Multiple products or collections that qualify:

```
Rule Group 1: Product A in cart
Rule Group 2: Product B in cart
Rule Group 3: Collection C in cart
```

***

## Testing Your Logic

1. **Draw It Out** - Sketch your logic on paper:
   * Boxes for rule groups
   * Lists for conditions within each rule group
   * Arrows showing OR between rule groups, AND within rule groups
2. **Write Test Cases** - For each rule group, write:
   * One case where all conditions are met
   * One case where only some conditions are met
   * One case where no conditions are met
3. **Enable Test Mode** - Create the discount with Test Mode enabled.
4. **Test Each Case** - Create test orders matching your test cases and verify the discount behaves correctly.

{% hint style="info" %}
Use the [Testing Guide](/advanced-free-shipping/troubleshooting/testing-guide.md) for a comprehensive testing checklist.
{% endhint %}

***

## Common Mistakes

{% hint style="warning" %}
**Mistake**: Creating multiple rule groups when you meant AND logic.

**Example**: You want "US orders over $50" but create:

* Rule Group 1: Country is US
* Rule Group 2: Cart ≥ $50

**Problem**: This gives free shipping to ALL US orders OR ALL orders over $50 (regardless of country).

**Fix**: Use one rule group with both conditions.
{% endhint %}

{% hint style="warning" %}
**Mistake**: Creating multiple conditions when you meant OR logic.

**Example**: You want "VIP customers OR orders over $100" but create:

* Condition 1: Customer tag contains "VIP"
* Condition 2: Cart ≥ $100

**Problem**: This requires BOTH VIP tag AND $100 cart.

**Fix**: Use two rule groups, one for each requirement.
{% endhint %}

***

## Next Steps

* [**How It Works**](/advanced-free-shipping/core-concepts/how-it-works.md) - Deep dive into rule groups and conditions
* [**Multiple Scenarios**](/advanced-free-shipping/advanced-features/multiple-rule-groups.md) - Advanced OR logic examples
* [**Use Cases**](/advanced-free-shipping/common-use-cases/use-cases.md) - See real-world examples
* [**Testing Guide**](/advanced-free-shipping/troubleshooting/testing-guide.md) - Test your logic thoroughly


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://responsive-media.gitbook.io/advanced-free-shipping/core-concepts/and-vs-or-logic.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
