We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Ad content in specific line-item in cart, based on product tag

Solved

Ad content in specific line-item in cart, based on product tag

upandaway
Shopify Partner
7 0 5

Hello, wonderful people! 

In the cart there are several products.

Some have the tag 'extra'.

The products with the 'extra' tag should show an extra line of text.

Anyone?

Accepted Solution (1)

LitExtension
Shopify Partner
4963 1010 1192

This is an accepted solution.

Hi @upandaway,

Please add code in {%- for item in cart.items -%}:

{%- assign tags = item.product.tags -%}
{%- assign checkTags = tags | where:'extra' -%}
{%- if checkTags != blank -%}
show an extra line of text
{%- endif -%}

Hope it is clear to you.

If you find my answer helpful for you, please mark it as a solution. Thank you and good luck

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com

View solution in original post

Replies 6 (6)

Guleria
Shopify Partner
4299 825 1189

Hello @upandaway ,

You can use it in cart template a/to your need

{% for tag in item.tags %}
   {% if tag contains 'iextra' %}
        <!-- Add you line item here -->
   {% endif %}
{% endfor %}

If you are also looking for cart line item attributes you can check here https://ui-elements-generator.myshopify.com/pages/cart-attribute

Thanks

- Elevate Your Store with Expert Shopify Services. Email: guleriathakur43@gmail.com - Need a quick fix or a tailored customization? I’ve got you covered.
- Looking to enhance your pages? Try GEMPAGES- a powerful drag & drop page builder.
- Let’s make your store stand out. Get in touch today!
- My Apps: Productify Groups – Smart product grouping made easy.
upandaway
Shopify Partner
7 0 5

Hi Guleria, and thank you for your answer. 

I've tried this, and it did find the tag in question, but it applied it to all the line items regardless if they had the tag or not. Placed it inside {%- for line_item in cart.items -%} block. Am I putting it in the wrong place? 

 

Thank you!

LitExtension
Shopify Partner
4963 1010 1192

This is an accepted solution.

Hi @upandaway,

Please add code in {%- for item in cart.items -%}:

{%- assign tags = item.product.tags -%}
{%- assign checkTags = tags | where:'extra' -%}
{%- if checkTags != blank -%}
show an extra line of text
{%- endif -%}

Hope it is clear to you.

If you find my answer helpful for you, please mark it as a solution. Thank you and good luck

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com
upandaway
Shopify Partner
7 0 5

Hi LitExtension, and thank you for you answer. 

I've tried your code, placed it inside the {%- for line_item in cart.items -%}, where I also did my previous attempts. It doesn't work, sadly. Both solutions recommended are pretty close to things i already tried. The closest i got was giving all the products in the cart the same line of extra text, regardless of what products contained the tag and not. As long as at least one of them did, everyone got the extra text. 

 

LitExtension
Shopify Partner
4963 1010 1192

Did you add the 'extra' tag to the product? https://i.imgur.com/Tvs9903.png
Please send me the code of cart file, I will check it.

 

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com
TiagoSilva23
Tourist
18 0 2

Hello, I want to add to drawer cart and checkout a product text "This is a Made-by-Request product.

Estimated delivery time: 4 - 6 Weeks" for some product but i dont find a soluction. can you help me?

I want to look like this discount text in my store.

Captura de ecrã 2022-11-21, às 11.20.43.png

 

Thank you