How do I hide a rich text block from product pages based on condition

Hello there!

I am using a Symmetry template and would like to show / hide a block of rich text that contain dynamic elements. The condition to show or hide is based on the category the product belongs to.

Where do I put the conditional statement? I am new to Shopify and Liquid in general and don’t know where to find the file where I can edit this. The logic is simple. Hide the rich elements marked on the screenshot when the product is part of certain categories or contain certain tags.

Thanks in advance.

Hi @hamadax
In this case you can hide or show the block, but it needs add some custom liquid code,
If you cannot do that by your self, you need to hire an expert, they can help you add the code and give you solution to fix that.

1 Like

Hi @hamadax ,

Thank you for reaching out to the Shopify Community!

Please share your store URL here so that we can check and provide a solution to you.

Thanks & Regards,
Ahsan ANC

1 Like

@hamadax - this will need liquid code editing, liquid code to check category and tags needs to be added to product page and based on result the content will be shown

1 Like

Thank you for the reply. Understood. Where do I find this code? I am new to Shopify Liquid and the overall structure of Templates. I can manage the conditional statements if I can pinpoint where that code is. Any hints?

Hi @hamadax
Base on your requirement. It require to add some custom liquid code.
If you cannot do that by your self, you need to hire an expert, they can help you add the code and give you solution to fix that.

I figured it out on my own. In that specific template, it allows for custom Liquid Code on the products pages. I think other templates have the same options as well. Simple. No need to mess around with the templates liquid or json files. :grin:

The code here looks for the Eyewear product type and if it gets a hit, it displays the Size and Condition Metafield values. Will refine a little bit more…

{% if product.type == "Eyewear" %}
<p><strong>Size</strong>: {{ product.metafields.my_fields.frame_measurement.value }} ({{ product.metafields.my_fields.size.value }}) | <strong>Condition</strong>: {{ product.metafields.my_fields.condition.value }}</p>
{% endif %}
1 Like