I have a clothing store and I want to hide ‘size chart’ field on certain product page. I’m using Dawn theme.
If it is a predefined block that uses a metafield definitions as a dynamic source then you will want to create an alternate template to use on the products that have no style guide.
If you are using a a custom-liquid block|section simply use a liquid if tag to conditionally check if the metafield exists {% if product.metafields.information.size_guide %}.
Or is blank {% if product.metafields.information.size_guide != blank %}.
https://shopify.dev/api/liquid/basics#truthy-and-falsy-example
Yes that worked. Thanks for your help!
Here is the best way I used to solve this problem:
Step 1: Add “Custom liquid/Custom HTML” block instead of Text block.
Step 2: Go to Dashboard → Settings → Custom data → Products
Step 3: See all the keys generated to access your metafields example: “product.metafields.custom.gemstone_size”
Step 4: Go to Dashboard → Customize
Step 5: Go to product or any other page where you are displaying metafields (in my case I need on product page)
Step 6: For individual metafields to display, just add “Custom liquid” block and put the conditions like this:
{%- if product.metafields.custom.gemstone_size != blank -%}
Gemstone size (cm): {{ product.metafields.custom.gemstone_size }}
{%- endif -%}
In your case the keys for displaying metafields will be different. For each metafield to display you need as many “Custom liquid” blocks and need to put conditions accordingly.
Hope! I answered the question.
Thanks
This is very heplful, thank you!