Basic string comparison in Liquid

AVR1
Tourist
6 1 1

I have a metafield called hot_offers_condition. I am trying to show an icon on the product in gallery if this metafield is set to one of several supported values.

 

{%- if product.metafields.custom.hot_offers_condition.value contains "New" -%}
  <img class="condition-icon offer-icon" alt="New" src="https://cdn.shopify.com/s/files/1/0320/1699/0267/files/new-icon.png">
{%- elsif product.metafields.custom.hot_offers_condition.value contains "Open Box" -%}
  <img class="condition-icon offer-icon" alt="Open Box" src="https://cdn.shopify.com/s/files/1/0320/1699/0267/files/ex-demo-icon.png">
{%- elsif product.metafields.custom.hot_offers_condition.value contains "Refurbished" -%}
  <img class="condition-icon offer-icon" alt="Refurbished" src="https://cdn.shopify.com/s/files/1/0320/1699/0267/files/refurb-icon.png">
{%- endif -%}

 

When, for example,

{{ product.metafields.custom.hot_offers_condition.value }}

outputs New (as expected) the image is not showing. Is there something wrong with my string comparison? I have tried both == and contains operators.

 

Thanks for your help!

 

Reply 1 (1)

AVR1
Tourist
6 1 1

I withdraw the question. It has mysteriously started working after no intervention on my part other than going away for a while and writing a forum post. Maybe some cache was broken.