Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi all, I use some liquid conditional statements that hides empty metafields from rendering and wish to build it into a JSON metafield in order to add it as a dynamic source in a template.
Is this possible at all? I have attempted to follow some forum suggestions but get error messages on save.
The code is:
<div>
{% if product.metafields.custom.brand != blank %}
<div> <B>Brand:</B> {{ product.metafields.custom.brand }}</div>
{% endif %}
</div>
<div>
{% if product.metafields.custom.model != blank %}
<div> <B>Model:</B> {{ product.metafields.custom.model }}</div>
{% endif %}
</div>
and so on. Or is there another way to add conditional logic to metafields added in a template so as not to leave blank spaces?
H
Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025