Using product tags to show message in cart but only one time for multiple products with same tags

{% for item in cart.items %}
  {% if item.product.handle == 'your-product-handle' %}          
    

 Your test Message 

  {% endif %}
 {% endfor %}

Hi! Currently, I have this code in my cart page to show certain messages for products with a certain tag. I am running into a problem where the message will appear multiple times if the cart contains multiple products with the applicable tags.

How do I make sure that the message is only shown ONCE if at least one of the product contains the correct tag? Thank you!

Hi @tedchangeth ,

Please change code:

{% assign check = true %}
  {% for item in cart.items %}
    {% if item.product.handle == 'your-product-handle' and check %}          
      

 Your test Message 

  	  {% assign check = false %}
    {% endif %}
{% endfor %}

Hope it helps!