Liquid, JavaScript, themes, sales channels
Hi there -
I've used Custom Fields for the last year to add metafields to my site. Now I'm trying Shopify's built in metafields, but I'm having trouble with the code. My product template is very customized, so I need to do this manually.
1) I added a new metafield called new_tab in Shopify.
2) I typed the word New! into that field on a product page.
3) Now I need to display the field... but I'm stuck. The below code isn't working. What have I got wrong?
{% if product.metafields["new_tab"] != blank %}
<div class="sale_banner_product">
{{ product.metafields["new_tab"] }}
</div>
{% endif %}
Solved! Go to the solution
This is an accepted solution.
I realized my main mistake... I hadn't included the full namespace and key... but there were others. Here's the working code.
{% if product.metafields.my_fields.new_tab != blank %}
<div class="sale_banner_product">
{{ product.metafields.my_fields.new_tab }}
</div>
{% endif %}
This is an accepted solution.
I realized my main mistake... I hadn't included the full namespace and key... but there were others. Here's the working code.
{% if product.metafields.my_fields.new_tab != blank %}
<div class="sale_banner_product">
{{ product.metafields.my_fields.new_tab }}
</div>
{% endif %}
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