If

v1.9.1

Executes a block of code only if a certain condition is true.

if

Input

1
2
3
{% if product.title == "Awesome Shoes" %}
These shoes are awesome!
{% endif %}

Output

1
These shoes are awesome!

elsif / else

Adds more conditions within an if or unless block.

Input

1
2
3
4
5
6
7
8
<!-- If customer.name = "anonymous" -->
{% if customer.name == "kevin" %}
Hey Kevin!
{% elsif customer.name == "anonymous" %}
Hey Anonymous!
{% else %}
Hi Stranger!
{% endif %}

Output

1
Hey Anonymous!