Hi,
Im trying to display a message when the user is at the cart that says ‘you could save more’ if the products in the cart match the targeted collection.
{% for item in cart.items %}
{% assign product_collections = item.product.collections | map: 'title' %}
{% if product_collections contains '5 for 20' and cart.item_count < 5 %}
<span>you can get 5 for 20</span>
{% endif %}
{% if product_collections contains '4 for 10' and cart.item_count < 4 %}
<span>you can get 4 for 10</span>
{% endif %}
{% if product_collections contains '3 for 10' and cart.item_count < 3 %}
<span>you can get 3 for 10</span>
{% endif %}
{% if product_collections contains '3 for 35' and cart.item_count < 3 %}
<span>you can get 3 for 35</span>
{% endif %}
{% if product_collections contains '3 for 20' and cart.item_count < 3 %}
<span>you can get 3 for 20</span>
{% endif %}
{% endfor %}
Essentially I have 5 collections that contain products and as long as the quantities match, they will be saving money. So if the user has 5 products in the cart that all have the ‘5 for 20’ collection, the total will be 20. The discounts are all working fine.
Problem is that if theres 2 products with the ‘5 for 20’ collection, and 2 products with the ‘4 for 10’ collection, the message only displays the ‘you can get 5 for 20’ since the cart total is more than 4.
Is there a way I can relate the cart items count to the collections count? Any pointers in the right direction would be great!