Add To Cart Popup - Conditional Tag

Solved
PortRobot
New Member
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

 

0 Likes
LitExtension
Shopify Partner
1200 154 215

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
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
0 Likes
PortRobot
New Member
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

 

0 Likes
LitExtension
Shopify Partner
1200 154 215

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
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
0 Likes
PortRobot
New Member
3 0 0

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

0 Likes