Check if your product in cart is in a specific collection, if no then hide checkout?

New Member
1 0 0



I'm trying to hide my 'checkout' button on cart page and display the message "You must select a delivery slot, click here" if a product from the "sample" collection is not in the basket.


To help I found this on Stack overflow, it works at displaying the message if a product IS in the basket, but I need it to display if the product IS NOT in the basket, and then if it is not found, hide the checkout button.


Any help would be greatly appreciated!!


{% for item in cart.items %}  
  {% assign found_collection = false %}
  {% for collection in item.product.collections %}
    {% if found_collection == false and collection.title == 'SampleProduct' %}
      {% assign found_collection = true %}
    {% endif %}
  {% endfor %}
  {% if found_collection %}
    <p>Enjoy your Product</p>
  {% endif %}
{% endfor %}


Replies 0 (0)