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
Save time & money ,Ask Questions The Smart Way
Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Buy Paul 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
Save time & money ,Ask Questions The Smart Way
Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Buy Paul 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!
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024