Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple conditions in if statement (Liquid)

Is it possible to put multiple conditions inside a single if statement in Shopify Liquid?

For example this is what I have:

{% if product.type != "A" and product.type != "B" and product.type != "C" %}
//do something
{% endif %}

The reason I'm wondering is because syntax highlighting stops after the first "and" operator, as if everything after that has incorrect syntax.

like image 854
Windbrand123 Avatar asked May 21 '26 08:05

Windbrand123


1 Answers

Your syntax is 100% valid and will work in Shopify

{% if product.type != "A" and product.type != "B" and product.type != "C" %}
    //do something
{% endif %}

I guess the editor what you are using has a bug in syntax highlighter for liquid. That's why you confused

like image 82
Victor Leontyev Avatar answered May 25 '26 19:05

Victor Leontyev