Hello, I can’t get a grip on the line_item object. I’m trying to to something like this in the cart before checkout:
{%- for collection in item.product.collections -%}
{%- if line_item.sku == “12345” and line_item.quantity > 1 -%}
something...
{%- endif -%}
{%- endfor -%}
I’m adding the code into main-cart-items.liquid (Dawn 2.0).
Has anyone an idea how to solve this?
Greetings,
Eduard
P.S. I can’t link the shop (secrecy).
For everyone who has the same question at some point. Here is what I’ve found out so far:
In main-cart-items.liquid you’re already in a for loop:
{%- for item in cart.items -%}
so, if you want to loop or get data out of this loop you need to address the objects with simply “item.[…]”. To get a better understanding write this snippet at some point in your loop:
With the dev tool on your browser you’ll be able to see all properties/attributes.
1 Like