Number

All ACF custom fields are stored as strings - even numeric types like Number to allow for decimal points. Liquid handles this quite nicely with one exception: you cannot do a direct comparison between a number and a string So while this is possible:

<p>We have {{ product.metafields.accentuate.stock | plus: 100 }} in stock</p>

You need to convert it to a number if you want to do a numeric comparison with the field's value beforehand, like this:

{% assign in_stock = product.metafields.accentuate.stock | plus: 0 %} 

{% if in_stock < 5 %}
  <p>Product is low on stock</p>
{% endif %}

the " | plus: 0 " converts the string into a number type in Liquid

Last updated