--- url: https://developer.youcan.shop/themes/tags/if.md --- # `if` If a particular condition is evaluated to be `truthy`, output the encapsulated block. ```liquid {% if condition %} block_to_output {% endif %} ``` * `condition`: Truthy condition to evaluate. * `block_to_output`: Rendered expression in case the condition is met. **Example** ::: details Data ```json { "product": { "track_inventory": true } } ``` *Note: Data is only refereed as a reference for this example and is in no means reflecting real world data.* ::: ```liquid {% if product.track_inventory == true %} There only 15 items left. Hurry up! {% endif %} ``` ::: tip Output There only 15 items left. Hurry up! ::: ## `elseif` `elseif` statement can be used in cases where you want to extend the `if` statement by specifying another condition if the preceding condition is `falsy`. **Example** ::: details Data ```json { "product": { "track_inventory": true, "price": 100, "compare_at_price": 140, "slug": "youcan" } } ``` *Note: Data is only refereed as a reference for this example and is in no means reflecting real world data.* ::: ```liquid {% if product.track_inventory == false %} First condition is truthy {% elseif product.price < product.compare_at_price %} First condition is falsy, and the second condition is truthy {% elseif product.slug == 'youcan' %} If both the first and second conditions are both falsy, and the third one is truthy {% endif %} ``` ::: tip Output First condition is false, and the second condition is truthy :::