Handling Liquid Booleans with custom metafields

Handling Liquid Booleans with custom metafields

Drewsiphus
Shopify Partner
3 0 1

Domain: https://www.smithysdirect.com/
Item 1: 46295
Item 2: 33219

 

{% assign has_drawing = false %}
{% for variant in product.variants %}
  {% if variant.metafields.custom.product_finish != blank %}
    {% assign has_drawing = true %}
  {% endif %}
{% endfor %}
{% if has_drawing %}
<!--HTML to display custom metafiled goes here-->
{% endif %}

 


So, I've used this same method for multiple custom metafields, and they all appear to be working as expected, except for this particular metafield (and only in certain circumstances)

You can see in Item 1 that the only the one metafield with relevant data is displayed

Drewsiphus_0-1669799532536.png

However on Item 2, the Technical Drawing section is displayed (despite the metafield being blank)

Drewsiphus_1-1669799577470.png

 

I have checked in the products section of the dashboard and confirmed that there are no blank spaces or other any other characters which may be tricking the liquid conditional logic to flip has_drawing over to true....I'm just sort of stumped what could be causing it.

Any input would be greatly appreciated.  Thanks!

Replies 0 (0)