Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I have a clothing store and I want to hide ‘size chart’ field on certain product page. I’m using Dawn theme.
Solved! Go to the solution
This is an accepted solution.
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
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
This is an accepted solution.
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
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
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 -%}
<strong>Gemstone size (cm):</strong> {{ 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!
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024