Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I am using metafields but I don't want all the metafields coming up for all the products. ie measurements for dresses vs measurements for shorts (remove bust measurement). Is there a way of selecting what metafields appear for different products?
Thank you.
I'm working on something similar. I use a custom liquid block (Turbo Theme) and if statements. So basically, I have a heading called CONTENT & CARE and then two metafields, one for fabric content and one for care instructions. So, in its simplest form, if the fields are single-line text and are called product.metafield.custom.content and product.metafield.custom.care, you have...
{% if product.metafield.custom.content %}
<p>Fabric Content: {{ product.metafield.custom.content }}</p>
{% endif %}
{% if product.metafield.custom.care %}
<p>Care Instructions: {{ product.metafield.custom.care }}</p>
{% endif %}
It checks to see if there is anything in the fabric content field, and, if so, prints that info. It then checks to see if there is anything in the care instructions field, and, if so, prints that info. You can have either one, both, or nothing, determined by which metafields have text in them.
Let me know if any of that isn't clear. Glad to help when I can.
One side note: The reason I came here is an issue for which I'll be placing a separate post: While I can conditionalize each piece of data, it doesn't appear that you can clear metafields. So if I fill in the fabric content field accidentally, the clear link doesn't work. Although it clears the field on the product card, the info originally entered continues to show on the customer-facing page.
Good luck!
Jason Roberts
This is a bit to complicated for me, but thank you for replying.
Gwen
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