How can I exclude tagged products from free delivery qualification in main-cart.liquid?

To tell customers in the cart if they’ve qualified for free delivery or not, in main-cart.liquid I’ve added the below code:

{% assign shipping_value = 5000 %}
{% assign cart_total = cart.total_price %}
{% assign shipping_value_left = shipping_value | minus: cart_total %}

{% if shipping_value_left > 0 %} You are {{ shipping_value_left | money }} away from free standard delivery over £50 (exluding bespoke/ club orders). {% else %} You've got free standard delivery! {% endif %}

However, free shipping isn’t available on any products with the tag “TEAM RHINO”. How do I exclude these products from triggering this?

To exclude products with the tag “TEAM RHINO” from triggering the free shipping message in the cart, you can modify the existing code by adding an additional condition using the unless statement. Here’s an updated version of the code:

{% assign shipping_value = 5000 %}
{% assign cart_total = cart.total_price %}
{% assign shipping_value_left = shipping_value | minus: cart_total %}

{% assign exclude_tag = 'TEAM RHINO' %}
{% assign has_excluded_product = false %}

{% for item in cart.items %}
  {% if item.product.tags contains exclude_tag %}
    {% assign has_excluded_product = true %}
    {% break %}
  {% endif %}
{% endfor %}

  {% if shipping_value_left > 0 and not has_excluded_product %}
    You are **{{ shipping_value_left | money }}** away from free standard delivery over £50
     *(excluding bespoke/club orders)*.
  {% else %}
    You've got free standard delivery!
  {% endif %}

Hi,

Thanks for your help on this. Unfortunately the code didn’t work - I had the following error message:

Liquid syntax error (line 13): Expected end_of_string but found id in “shipping_value_left > 0 and not has_excluded_product”