I am trying to print the unique items based on their variant ids. Only unique items are to be printed.
{% set unique_items = [] %}
{% for item in items %}
{% if item.variant_id not in unique_items %}
{% set unique_items = unique_items + [item.variant_id] %}
{% set quantity = items | selectattr("variant_id", "equalto", item.variant_id)
| list | length %}
<tr>
<td style="width: 0; padding: 0px !important">
<img
src="{{ item.image_url }}"
style="height: 118px; width: 78px; border-radius: 4px"
/>
</td>
...
Here the code is trying to print image of only unique items that have different variant_id
s.
I have tried this but it prints all the items. I don't want repeating items.