iam using Meta fields to show ingredients, shipping details and how to use the product. But for some there are no such informations i looked for a solution to hide the empty meta fields in the frontend. From a different Disscusion i found this code from this discussion Solved: How to hide blank metafields. - Shopify Community
I implemented the code and it worked perfectly fine but one day later it didnt worked but i didnt changed anthing on the code.
Can I ask why youâre using javascript and not liquid?
With liquid, you can wrap the html that you donât want to show if itâs empty with an if statement -
eg:
{% if product.metafield.namespace.key != blank %}
Here is a metafield bit
{{ product.metafield.namespace.key }}
{% endif %}
If itâs one block containing multiple metafield references and you want to remove it if there is nothing there, you can just use or in the if statement
eg
{% if product.metafield.namespace.key != blank or product.metafield.namespace2.key2 != blank%}
Here is a metafield bit
{{ product.metafield.namespace.key }}
{{ product.metafield.namespace2.key2 }}
{% endif %}
This means it will only show if metafield 1 or metafield 2 (or both) exists.
Hi Mellowsilcbd,
No, sorry I mean in the main-product.liquid (or similar, not sure what theme youâre using)
The bit on your product page where you reference the ingredients metafield
Hey i think iam pretty stupid right now haha but this is the only thing i can find with {{product.metafields but rating isnt what my ingridents metafield is called
Iam pretty desperate. Iam sorry iam acting so stupid right now haha