Issue
here is my code i tried to fetch only unique value from items variable but I got all value can someone please help to solve this
{% capture items %}
{% for tag in product.tags %}
{%if tag contains 'pair'%}
{% assign tag_split = tag | remove_first: 'pair::' | split: "::" %}
{% assign color = tag_split[0] %}
{{color}}
{% endif %}
{% endfor %}
{% endcapture %}
{% assign my_array = items | split: ", " %}
<p>{{ my_array | uniq }} </p>
Solution
This filter should help you to keep only one elem per value: https://shopify.github.io/liquid/filters/uniq/
Answered By - Alice Girard Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.