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

# Logic gates

> AND, OR, and NOT blocks in Galantis Discount Flow, plus Then/Otherwise branching — how to combine conditions into precise discount targeting.

A single condition answers one question; real campaigns usually ask several. Galantis Discount Flow gives you two ways to combine them: chain conditions through their **Then** and **Otherwise** outputs, or route multiple conditions into a dedicated logic gate. Both approaches produce the same evaluation everywhere the flow runs — in the builder, on the storefront, and at checkout.

Three logic gates are available, each with a single output that continues the flow when the gate passes.

## The three gates

<CardGroup cols={3}>
  <Card title="AND" icon="circle-check">
    All connected conditions must be true for the flow to continue.
  </Card>

  <Card title="OR" icon="circle-half-stroke">
    Any one of the connected conditions being true is enough.
  </Card>

  <Card title="NOT" icon="circle-xmark">
    Inverts the connected condition — true becomes false, false becomes true.
  </Card>
</CardGroup>

Connect the **Then** outputs of two or more conditions into a gate's input, then connect the gate's output onward to an action or further logic. **AND** and **OR** accept multiple inputs; **NOT** inverts a single input.

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/digifist/images/galantis/discount/rule-builder/logic-gates-branching.png" alt="Two conditions feeding into an AND gate, whose output connects to a Percentage off action" />
</Frame>

## Then / Otherwise branching

Every condition has two outputs:

* **Then** — followed when the condition passes
* **Otherwise** — followed when it fails

This makes each condition a branch point on its own. Chaining conditions through **Then** is an implicit AND: the flow only reaches the end of the chain when every condition along the way passed. The **Otherwise** output lets you do something different for carts that fail a check — route them to a smaller offer, a different action, or simply nowhere (no discount).

## Worked examples

<AccordionGroup>
  <Accordion title="VIP customers with a cart over 100" icon="crown">
    Two equivalent builds:

    * **Chained:** **Start** → **Customer segment** (VIP) → **Then** → **Cart total** (**is greater than** 100) → **Then** → **Percentage off**. The discount only fires when both checks pass.
    * **With an AND gate:** connect the **Then** outputs of both conditions into an **AND** block, and connect the gate's output to the action.

    For two conditions, chaining is usually simpler. The gate version becomes valuable when the same combined result needs to feed several places, or when you start mixing in OR logic.
  </Accordion>

  <Accordion title="Everyone except first-time buyers" icon="user-slash">
    To exclude first orders, use the **First order** condition's **Otherwise** output: **Start** → **First order** → **Otherwise** → your action. Customers on their first order follow **Then** (which you leave unconnected or route elsewhere), and everyone else gets the discount.

    <Warning>
      Do not build this as **First order** → **NOT** → action. An action that is only reachable through a NOT gate can never apply, and the builder flags it as an issue. Use the condition's **Otherwise** output instead, or route the NOT into an AND/OR gate alongside another input.
    </Warning>
  </Accordion>

  <Accordion title="Weekend shoppers or VIPs" icon="calendar-days">
    Connect the **Then** outputs of **Day of week** (Saturday and Sunday selected) and **Customer segment** (VIP) into an **OR** block, then connect the gate to a **Free shipping** action. Either being true — it is the weekend, or the customer is a VIP — unlocks the offer. This is the pattern chaining cannot express, since a **Then** chain always means "all of these".
  </Accordion>
</AccordionGroup>

## Chaining vs gates

| Situation                                        | Use                                                                                         |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------- |
| All conditions must pass (simple AND)            | Chain conditions through **Then**                                                           |
| Different outcomes for pass and fail             | The condition's **Then** and **Otherwise** outputs                                          |
| Any one of several conditions is enough          | An **OR** gate                                                                              |
| Many conditions must all pass and feed one point | An **AND** gate — keeps the canvas readable                                                 |
| Invert a check                                   | Prefer the condition's **Otherwise** output; use **NOT** only as an input into AND/OR logic |

<Tip>
  If a chain of **Then** connections is getting long, run **Auto-layout** from the toolbar and consider replacing part of the chain with an **AND** gate. The evaluation is identical, but the graph becomes much easier to read — and easier to test.
</Tip>

## Related guides

* [Conditions](/galantis/discount/rule-builder/conditions) — The eleven checks that feed your gates
* [Actions & discount types](/galantis/discount/rule-builder/actions) — Where the combined logic ultimately leads
* [Testing flows](/galantis/discount/rule-builder/testing-flows) — Watching the active path light up through your gates
