'how to get highest number of loop elements in shopify
how can I get highest numbers from loop here is my code
from this code I got
2
,1
,3
,1
,2
So I want3
as a result could you please help me to solve this problem any help would be appriciated {% for line_item in cart.items %}
{% assign c_no = line_item.properties | join:',' | remove_first : 'meal pack,' | strip | split : '-' | last | sort: 'price' %}
<h1>{{c_no}}</h1>
{% endfor %}
Solution 1:[1]
Use the {{ forloop.length }}
{% for product in collections.frontpage.products %}
{% if forloop.first %}
<p>This collection has {{ forloop.length }} products:</p>
{% endif %}
<p>{{ product.title }}</p>
{% endfor %}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Michel Arteta |
