A loop conditional is additional data such as the current count or Boolean values such as last or first in a loop.
Below you will find the output tags/boolean conditionals available in some selected loops.
{is_first} | Boolean (True/False) value if the current count is on the first iteration. |
{is_last} | Boolean (True/False) value if the current count is on the last iteration. |
{is_even} | Boolean (True/False) value if the current count of the loop is an even iteration. |
{is_odd} | Boolean (True/False) value if the current count of the loop is an odd iteration. |
{loop_count} | Numeric value of the current number of iterations this loop has looped. This is also known as a current loop count. |
{loop_size} |
Numeric value of the number of iterations this loop will loop. Also known as the size of the loop. |
For example, lets say you wanted to build a table while using the grid ordering loop. Using {is_first} and {is_last}, this is possible. See the example below.
{% loop product_grid_order %} {% if product_grid_order.is_first %} <table> <thead> <tr> <th>Product</th> <th>SKU</th> <th>Price</th> <th>Qty</th> </tr> </thead> <tbody> {% endif %} <tr> <td>{product_grid_order.product_name} ({product_grid_order.product_variation})</td> <td>{product_grid_order.product_sku}</td> <td class="price">{product_grid_order.product_price}</td> <td>{product_grid_order.product_quantity_html}{product_grid_order.ajax_id}</td> </tr> {% if product_grid_order.is_last %} </tbody> </table> {% endif %} {% endloop product_grid_order %}