Liquid error (product-price line 34): comparison of Integer with String failed

Solved
Excursionist
16 0 2

Hello all, 

 

Instead of a sale price I get that message under products where I have included a price and a compare at price. I read in other threads that it might be related to a filter but I can't find any filters in this liquid and don't know where else to look. The error message indicates that there's a conflict in line 34 of the product-price liquid, the relevant code of the product-price liquid is, with line 34 being {% if compare_at_price > price %}

 

 <div class="price__regular">
    <dt>
      <span class="visually-hidden visually-hidden--inline">{{ 'products.product.regular_price' | t }}</span>
    </dt>
    <dd>
      <span class="price-item price-item--regular" data-regular-price>
        {% if available %}
          {% if compare_at_price > price %}
            {{ compare_at_price | money }}
          {% else %}
            {{ money_price }}
          {% endif %}
        {% else %}
          {{ 'products.product.sold_out' | t }}
        {% endif %}
      </span>
    </dd>
  </div>
  <div class="price__sale">
    <dt>
      <span class="visually-hidden visually-hidden--inline">{{ 'products.product.sale_price' | t }}</span>
    </dt>
    <dd>
      <span class="price-item price-item--sale" data-sale-price>
        {{ money_price }}
      </span>
      <span class="price-item__label" aria-hidden="true">{{ 'products.product.on_sale' | t }}</span>
    </dd>
  </div>
</dl>

To be sure, I put the 'price' lower than the 'compare at price', so that can't be the issue. 

 

See www.umacantik.com, I have deliberately left one product with a 'compare at price' and the resulting error code (https://umacantik.com/collections/baskets?page=3).

 

I really hope someone can help me out with this. 

 

Thanks a lot, 

 

Bram

0 Likes
Shopify Expert
96 17 12

@Bram1987 - This error means that one of your variables is not coming through as an integer so there is no way for the argument to be validated.

 

Try replacing line 37:

{{ money_price }}

with:

{{ compare_at_price | money }}

If this outputs a value other than a #, that is the culprit and you will need to identify where the 'compare_at_price' variable is being assigned and update the formatting so it is numerical.  Let me know what the output is and I can help you go from there :)

1 Like
Excursionist
16 0 2

Hi @__cascadia thank you so much for your quick response. I have changed the code in accordance with your suggestion. The error remains as it was before, as can be seen on the website, so I guess that the output is not numerical. Would you have a suggestion for a next step?

0 Likes

Success.

Shopify Expert
96 17 12

@Bram1987 - Gotcha.  Let's try using the direct liquid variables to call the product standard price and sale price as opposed to assigned variables and see where that gets us.

 

Replace this code:

<span class="price-item price-item--regular" data-regular-price>
        {% if available %}
          {% if compare_at_price > price %}
            {{ compare_at_price | money }}
          {% else %}
            {{ money_price }}
          {% endif %}
        {% else %}
          {{ 'products.product.sold_out' | t }}
        {% endif %}
      </span>

With this:

<span class="price-item price-item--regular" data-regular-price>
{% if product.available %}
{% if product.compare_at_price_max > product.price %}
{{ product.compare_at_price_max | money }}
{% else %}
{{ product.price | money }}
{% endif %}
{% else %}
{{ 'products.product.sold_out' | t }}
{% endif %}
</span>
1 Like
Excursionist
16 0 2

Thank you again @__cascadia now the price shows up without an error but it's the 'old' price, not the sale price. In addition it seems that the position of the price is now a bit odd compared to the other product prices. 

0 Likes
Excursionist
16 0 2

UPDATE: It actually seems to work now! Perhaps I did not wait long enough before refreshing the page. Will test it out on some other products but it seems resolved :) Thanks so much @__cascadia 

0 Likes

Success.

Shopify Expert
96 17 12

@Bram1987 - Awesome!  If it worked, feel free to mark this thread as "solved" so the next person can gain value from the solution :)

0 Likes