I am doing a for loop in shopify, I need to increment a variable.
However, when I do
{% increment variable %}
besides incrementing it, it shows the output on the screen!
I can't believe it. Is there a way to avoid this?
Thank you
If you are using a different logic for incrementing the value than forloop.index
, you can use the plus
filter to increment the variable:
{% assign variable = 0 %}
{% for … %}
{% assign variable = variable | plus: 1 %}
{% endfor %}
I can also recommend that you have a look at the cheat sheet for Shopify.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With