If Statement on Cart Page

We’re using the Providence theme. We created a snippet called custom.cart.message that contains a message we want to display on our cart page when a certain product has been added to that page.

Using the following {% render ‘custom-cart-message’ %} we can successfully display the custom snippet on cart-template.liquid.

However, as soon as we attempt to wrap that render snippet in an “if” statement, it no longer displays. There are no syntax errors displayed in Shopify, and we’ve tried using product.handle, product.title, and product.id with no luck. Is there a specific syntax needed for IF statements on the cart page?

The product handle is as shown below.

{% if product.handle contains “cheese-of-course” %}
{% render ‘custom-cart-message’ %}
{% endif %}

Hi @wield

The Condition is correct but the object you are targeting is wrong it should use the Cart item like this code Try that if it works otherwise share your collaboration code I will check that

{% for item in cart.items %}
  {% if item.product.handle == "cheese-of-course" %}
    {% render 'custom-cart-message' %}
    {% break %}
  {% endif %}
{% endfor %}

Mehran_Ali - you are a hero! Thank you so much. That works exactly as expected!