# Control flow tags

Control flow tags create conditions that decide whether blocks of Liquid code run.

Control flow tags create conditions that decide whether blocks of Liquid code run.

## if

Runs a block of code only if a condition is met (the result is `true`).

```liquid
{% if product.title == 'Awesome Shoes' %}
  You are buying some awesome shoes!
{% endif %}
```

```text
You are buying some awesome shoes!
```

## unless

Like `if`, but runs a block of code only if a condition is **not** met (the result is `false`).

```liquid
{% unless product.title == 'Awesome Shoes' %}
  You are not buying awesome shoes.
{% endunless %}
```

```text
You are not buying awesome shoes.
```

This is the same as:

```liquid
{% if product.title != 'Awesome Shoes' %}
  You are not buying awesome shoes.
{% endif %}
```

## else / elsif

Adds more conditions to an `if` or `unless` block.

```liquid
{% if shipping_method.title == 'International Shipping' %}
  You're shipping internationally. Your order should arrive in 2–3 weeks.
{% elsif shipping_method.title == 'Domestic Shipping' %}
  Your order should arrive in 3–4 days.
{% else %}
  Thank you for your order!
{% endif %}
```

```text
Your order should arrive in 3–4 days.
```

## case / when

Creates a switch statement that runs a specific block of code when a variable has a specific value. `case` starts the switch statement, `when` defines the conditions.

You can add an optional `else` at the end to provide code that runs when none of the conditions is met.

```liquid
{% case shipping_method.title %}
  {% when 'International Shipping' %}
    You're shipping internationally. Your order should arrive in 2–3 weeks.
  {% when 'Domestic Shipping' %}
    Your order should arrive in 3–4 days.
  {% when 'Local Pick-Up' %}
    Your order will be ready for pick-up tomorrow.
  {% else %}
    Thank you for your order!
{% endcase %}
```

```text
Your order should arrive in 3–4 days.
```

## Multiple conditions (and / or)

Use the `and` and `or` operators to include more than one condition in a control flow tag. You can chain `and` and `or` to build complex conditions. See the [operators reference](https://developer.versacommerce.de/articles/liquid-basics-operators#order-of-operations) for the order in which they are evaluated.

## and

The `and` operator adds conditions to a tag. A condition with `and` is only true if **both** the left and the right side are true.

```liquid
{% if line_item.grams > 20000 and customer_address.city == 'Hannover' %}
  You are buying a heavy item and live in the same city as our store. Choose local pick-up as shipping option to avoid high shipping costs.
{% endif %}
```

```text
You are buying a heavy item and live in the same city as our store. Choose local pick-up as shipping option to avoid high shipping costs.
```

## or

The `or` operator adds conditions to a tag. A condition with `or` is true if **either** the left or the right side is true.

```liquid
{% if customer.tags contains 'VIP' or customer.email contains 'mycompany.com' %}
  Welcome! We're pleased to offer you a special discount of 15% on all products.
{% else %}
  Welcome to our store!
{% endif %}
```

```text
Welcome! We're pleased to offer you a special discount of 15% on all products.
```
