Liquid Error: comparison of Integer with String failed

Highlighted
New Member
3 0 0

Hello,

I am trying to count the cart quantity of all products but I keep getting the below error

comparison of Integer with String failed.

on this line: {% if cartcount >= '4' and cartcountsample >= '1' %}

The numbers are correctly being added, when I display {{ cartcount }}, but when it comes time to display the button is when i get the error.

 

 

 

 {% assign cartcount = 0 %}
{% assign cartcountsample = 0 %}
{% for item in cart.items %}
{% if item.product.tags contains 'Non-Sample' %}
{% assign cartcount = cartcount | plus:1 %}
{% endif %}
{% if item.product.tags contains 'Sample' %}
{% assign cartcountsample = cartcountsample | plus:1 %}
{% endif %}
{% endfor %}
{% if cartcount >= '4' and cartcountsample >= '1' %}
<button type="submit" name="checkout" class="Cart__Checkout Button Button--primary Button--full">{{ 'cart.general.checkout' | t }}</button>
{% elsif cartcount >= '4' and cartcountsample == '0' %}
<button type="submit" name="checkout" class="Cart__Checkout Button Button--primary Button--full">{{ 'cart.general.checkout' | t }}</button>
{% elsif cartcount == '0' and cartcountsample >= '2' %}
<button type="submit" name="checkout" class="Cart__Checkout Button Button--primary Button--full">{{ 'cart.general.checkout' | t }}</button>
{% else %}
<span style="color: red;">please add more.</span>
{% endif %} 

 

 

 

 

 

 

0 Likes