Cart Message if Any Product Has High Tag - Maingate

Create a new snippet named cart_tag-message.liquid

cart_tag-message.liquid

{% assign foundCartMessage = false %}

{% for item in cart.items %}            
    {% for tag in item.product.tags %}
        {% comment %} {{tag}}{{tags}} {% endcomment %}
        {% if tag contains 'high' %}
            {% assign foundCartMessage = true %}
            {% break %}
        {% endif %}
    {% endfor %}    
{% endfor %}

{% if foundCartMessage == true %}                
    <h4 class="cart_found-message">There is a product in the cart with the tag high.</h4>
{% endif %}

Update the messaging.

In cart.liquid add the following code wherever you want the code to appear (usually below the title).

{% include 'cart_tag-message' %}
 

Leave a comment