Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
I have added a text + image section onto the product page with content pulling from product metafields, but still setting the section heading via 'customise' in the theme editor. But when the metafields are blank, the heading still shows. how can I ensure the heading is also hidden when the metafields are blank?
Solved! Go to the solution
This is an accepted solution.
Hi, @lana-mukti
Greetings from the Store Watchers Support Team! Happy to help you today.
You can put this condition:
{% if product.metafields.namespace.key != blank %}
// Put the heading tags within this condition
{% endif %}
Replace namespace with the actual namespace of the metafield and key with the key of the metafield.
You can use this code snippet within the relevant section of your product page template to control the visibility of metafields based on their values. Repeat this code for each metafield you want to conditionally display.
Remember to adjust the code to match the structure and naming of your metafields.
Let me know If need further assistance
Regards,
Store Watchers Support Team
This is an accepted solution.
Hi, @lana-mukti
Greetings from the Store Watchers Support Team! Happy to help you today.
You can put this condition:
{% if product.metafields.namespace.key != blank %}
// Put the heading tags within this condition
{% endif %}
Replace namespace with the actual namespace of the metafield and key with the key of the metafield.
You can use this code snippet within the relevant section of your product page template to control the visibility of metafields based on their values. Repeat this code for each metafield you want to conditionally display.
Remember to adjust the code to match the structure and naming of your metafields.
Let me know If need further assistance
Regards,
Store Watchers Support Team
Hi, this is not the first thread I encounter, you tell the code but where to put it most of the people can't find, so do I. Can you specify where this code should ho?