Logic

From Shopify Wiki

Revision as of 14:13, 23 April 2010 by Mark (Talk | contribs)
Jump to: navigation, search

Logic are conditional Liquid statements.

Example of a logic statement

Lets say we are working on product.liquid template and want to display the message "Free shipping", but only on products whose price is greater than $100. Since the product will either have a price greater than $100 or less than $100, the if logic statement is the most appropriate statement to use...

{% if product.price > 100 %}
  Free Shipping
{% else %}
  No free shipping
{% end if %}

Notice how we use the {% %} logic tags and not the {{ }} output tags

Operators

You can use different operators when using logic statements...

  • == - Equal