Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello,
I am updating my site to Shopify 2.0 and taking advantage of the sections available on a product page. I need the same sections on all with the exception of a handful. Is there a way to hide sections based on a metafield value?
Karissa
Hi @KarissaN Hope you are doing Well
Yes, You need to Wrap Section Html Inside Liquid Condition
Hi @KarissaN,
You need to go to the file containing the sections and add the following code. Example for 'Collection list' section, located in sections/collection-list.liquid file of Dawn theme.
Code:
{%- assign check = true -%}
{%- if request.page_type == 'product' and product.metafields.my_fields.value == 'value'-%}
{%- assign check = false -%}
{%- endif -%}
{%- if check -%}
<!-- content section -->
{%- endif -%}
with 'product.metafields.my_fields.value == value' is the condition of metafields.
Hope it is clear to you.
This is great, but I have a follow up question.
If the section is like a text section, I assume it can't be hidden unless you hide *all* text sections based on a metafield, so how do you hide a specific text section? Can you do it in the json template?
In Canada, payment processors, like those that provide payment processing services t...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025