Solved

Add To Cart Popup - Conditional Tag

PortRobot
Visitor
3 0 0

We sell two separate categories of products on our store. One has the tag 'Treatment Couches' the other doesn't.


We want to display one message if a customer adds a product with the 'Treatment Couches' tag to their cart, and a different one if they don't.

If they have a Treatment Couch, it should only display the 'Treatment Couch' message.


Currently the add to cart pop up is showing a message for each product.

 

This is the code that is there at the moment:

{% for item in cart.items %}
{% if item.product.tags contains 'Treatment Couches' %}
{% if forloop.first %}
<p><b><em><span style="color:#00AEEF;">A member of the team will contact you to arrange delivery of your couch to suit you. Please refer to the product page for more details.</span></em></b></p>
{%- else -%}
<p><b><em><span style="color:#00AEEF;">Orders placed before 1pm are dispatched the same day. Orders placed after 1pm on a Friday will be dispatched on the following Monday.</span></em></b></p>

{% endif %}
{%endfor%}

 

PortRobot_0-1623666778265.png

 

Accepted Solution (1)

LitExtension
Shopify Partner
4860 1001 1132

This is an accepted solution.

Hi @PortRobot,

You can try the following code:

{% assign check = 0 %}

{% for item in cart.items %}

{% if item.product.tags contains 'Treatment Couches' %}

  {% assign check = 1 %}

  {% break %}

{% endif %}

{% endfor %}

{% if check == 1 %}

<p><b><em><span style="color:#00AEEF;">A member of the team will contact you to arrange delivery of your couch to suit you. Please refer to the product page for more details.</span></em></b></p>

{% else %}

<p><b><em><span style="color:#00AEEF;">Orders placed before 1pm are dispatched the same day. Orders placed after 1pm on a Friday will be dispatched on the following Monday.</span></em></b></p>

{% endif %}

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify

View solution in original post

Replies 5 (5)

LitExtension
Shopify Partner
4860 1001 1132

This is an accepted solution.

Hi @PortRobot,

You can try the following code:

{% assign check = 0 %}

{% for item in cart.items %}

{% if item.product.tags contains 'Treatment Couches' %}

  {% assign check = 1 %}

  {% break %}

{% endif %}

{% endfor %}

{% if check == 1 %}

<p><b><em><span style="color:#00AEEF;">A member of the team will contact you to arrange delivery of your couch to suit you. Please refer to the product page for more details.</span></em></b></p>

{% else %}

<p><b><em><span style="color:#00AEEF;">Orders placed before 1pm are dispatched the same day. Orders placed after 1pm on a Friday will be dispatched on the following Monday.</span></em></b></p>

{% endif %}

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
PortRobot
Visitor
3 0 0

Thanks @LitExtension this worked perfectly!

 

Another semi-related question, how do I change the title of the cart pop up to "Shopping Basket", it is currently "Shopping Cart"

PortRobot_0-1623840874711.png

 

LitExtension
Shopify Partner
4860 1001 1132

Hi @PortRobot

Can you send me the name of the theme you are using or your store link. I will check it. 

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
PortRobot
Visitor
3 0 0

Hi @LitExtension, I managed to find it, but thanks

Yuliya_K
Shopify Partner
26 0 2

Hello,

If you want to solve this issue without any changes in the theme try to use 

Product Warnings on Checkout . It would be great to show the warning only for products that are different from others. There is also  a line item property in the app that is displayed on the cart page after the warning was accepted.