When I first started using Shopify one of the first things I wanted to do was create a dropdown list of quantites in the product.liquid template as I prefer them to having input boxes where a user can type in a number.
The simple way would be:
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
That’s all well and good but I wanted up to a quantity of 30 and been a programmer didn’t want to repeat the same thing another 29 times. So a simple way to achive this using Liquid is to create a For loop and assign a variable to the maximum quantity, in my case 30.
{% assign max_quantity = 30 %}
{% for ii in (1..max_quantity) %}
<option value="{{ ii }}">{{ ii }}</option>
{% endfor %}
You can see this working here.




