# Operators

Liquid has access to many logical and comparison operators.

Liquid has access to many logical and comparison operators. Use them to build logic with [control flow tags](https://developer.versacommerce.de/articles/liquid-tags-control-flow-tags).

## Basic operators

| Operator | Function |
|---|---|
| `==` | equals |
| `!=` | does not equal |
| `>` | greater than |
| `<` | less than |
| `>=` | greater than or equal to |
| `<=` | less than or equal to |
| `or` | condition A **or** condition B |
| `and` | condition A **and** condition B |

For example:

```liquid
{% if customer.has_account == true %}
  Welcome back to our shop!
{% endif %}
```

You can combine several comparisons in one tag with `and` and `or`:

```liquid
{% if product.type == "Shirt" or product.type == "Shoes" %}
  This is a shirt or a pair of shoes.
{% endif %}
```

## contains

`contains` checks whether a string contains a substring.

```liquid
{% if customer.email contains "example.com" %}
  Hello, dear colleagues!
{% endif %}
```

`contains` can also check whether a string is part of an array of strings.

```liquid
{% if product.tags contains "outdoor" %}
  This product is great for outdoor use!
{% endif %}
```

`contains` only works with strings. You cannot use it to find an object in an array of objects.

## Order of operations

In tags with more than one `and` or `or` operator, the operators are evaluated *from right to left*. You cannot change the order with parentheses. Parentheses are invalid characters in Liquid tags and break them.

```liquid
{% if true or false and false %}
  This evaluates to true, because the "and" condition is checked first.
{% endif %}
```

```liquid
{% if true and false and false or true %}
  This evaluates to false, because the tags are checked like this:

  true and (false and (false or true))
  true and (false and true)
  true and false
  false
{% endif %}
```
