Shopify themes, liquid, logos, and UX
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!
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.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024