Reader small image

You're reading from  Shopify Theme Customization with Liquid

Product typeBook
Published inOct 2021
PublisherPackt
ISBN-139781801813969
Edition1st Edition
Tools
Right arrow
Author (1)
Ivan Djordjevic
Ivan Djordjevic
author image
Ivan Djordjevic

Ivan Djordjevic comes from the small town of Prokuplje, Serbia. As a self-taught developer, he spent the first few years working on different projects, but only when he came in contact with Shopify and learned about Liquid that he found himself. In 2016, Ivan joined Shopify Experts under HeyCarson, where he moved to the lead developer position after a few months. Since joining the Shopify family, Ivan found his passion in sharing his knowledge with other developers and guiding them on their way to becoming a Shopify Expert.
Read more about Ivan Djordjevic

Right arrow

Learning the comparison operators

With Liquid, we have access to seven comparison operators, which we can combine to create any type of logical flow that our code requires. Let's review them as follows:

  • The == operator allows us to check whether the element we are comparing is equal to some value:
    {% if collection.title == "Winter Shoes" %}
      Winter Shows collection found!
    {% endif %}

    If collection.title is strictly equal to our string of "Winter Shows", the logic returns true, and we will see our message shown. Otherwise, the logic returns false. Note that comparison will only return true if the string is an exact match, including the text case.

  • The!= operator works similarly to the previous operator. The difference is that this operator checks whether the element we are comparing is not equal to some value:
    {% if collection.title != "Winter Shows" %}
      Winter Shows collection is not found!
    {% endif %}

    As with the previous...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Shopify Theme Customization with Liquid
Published in: Oct 2021Publisher: PacktISBN-13: 9781801813969

Author (1)

author image
Ivan Djordjevic

Ivan Djordjevic comes from the small town of Prokuplje, Serbia. As a self-taught developer, he spent the first few years working on different projects, but only when he came in contact with Shopify and learned about Liquid that he found himself. In 2016, Ivan joined Shopify Experts under HeyCarson, where he moved to the lead developer position after a few months. Since joining the Shopify family, Ivan found his passion in sharing his knowledge with other developers and guiding them on their way to becoming a Shopify Expert.
Read more about Ivan Djordjevic