'how to show products based on line item property on cart page
I have created a cart page in which I want to show all cart products based on their property for example cart property name one time and under this all products which have this property
for example I have 6 products which have property named 6 product pack then my cart will show something like this 6 product pack product 1, product 2, product 3, product 4, product 5, product 6,
This is my code currently it is showing all properties and products could you please help me to solve this problem any help would be appreciated
{%- for item in cart.items -%}
{%- for property in item.properties -%}
{%- assign property_first_char = property.first | slice: 0 -%}
{%- if property.last != blank and property_first_char != '_' -%}
<div class="product-option">
{{ property.first }}: {{ property.last }}
<br> {{ item.product.title | escape }}
</div>
{%- endif -%}
{%- endfor -%}
I want Output something like this
Porperty 1
- Product one
- Product two
- Product three
Porperty 2
- Product one
- Product two
- Product three
Porperty 3
- Product one
- Product two
- Product three
and so on..
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
