How do I wrap my products in a new <div class="row"></div>
after every 3rd product? I have looked at using the cycle
iteration tag but can’t quite figure out how to implement properly in my code.
{% for product in collection.products %}
<!-- product -->
<div class="col-xs-6 col-md-4 product">
<a href="{{product.url}}" class="product-link"></a>
<!-- / product-link -->
<img src="{{ product.featured_image.src | img_url: '480x480' }}" alt="">
<!-- / product-image -->
<!-- product-details -->
<div class="product-details">
<h3 class="product-title">{{product.title}}</h3>
<h6 class="product-price"> {{ product.price | money }}</h6>
</div><!-- / product-details -->
</div><!-- / product -->
{% endfor %}
2
Answers
Worked it out, if there are any better ways/suggestions I would be happy to hear them :)
You might use a modulo calculation applied on forloop.index then apply an if statement according to modulo result.
https://help.shopify.com/themes/liquid/filters/math-filters#modulo