How can I limit a collapsible row to specific products only?

Oneg
Tourist
35 0 2

Hey

I added a collapsible row to add a size chart

But I noticed now all of my products have a collapsible row (only the ones I populated with metafield page have content in them, the rest are empty)

 

I want to have the collapsible row only for those 6 products I need it for, and have the collapsible row disappear from the other products. 

How can I do that?

 

Thank you 🙂

Replies 7 (7)

Sheesh_b
Shopify Partner
509 112 116

Hi @Oneg 

To fix this you can add a common tag on those 6 products and put the metafield code in the condition like below.

<!--   Extra info for custom tags   -->
{% for tag in product.tags %}
    {% if tag contains 'myTag' %}
       //Your metafield code here     
    {% endif %}
{% endfor %}

 

This code will prevent the metafield code to populate on all the products and will appear only on the products that have your added tag on 6 products.

 

Thanks

Sheesh B

We're here to simplify website creation for those looking to establish a strong online presence. Book a meeting slot if you want to discuss. It's FREE. BOOK NOW | Try Shopify for $1 for 3 Months: Shopify Trial | Shopify Web Store Developer |
LIKE or mark as ACCEPTED SOLUTION
Markslwn48
Visitor
1 0 0

Can you explain where we need to place this code? If I only want the collapsible rows for 1 product, do I put this code in the description of the product? And do I add 'myTag' to the product tags? What goes here: //Your metafield code here ? Thanks! 

Sheesh_b
Shopify Partner
509 112 116

Hi @Markslwn48 

The above code is to show the metafields on selected products and we can refine the products if we add a specific tag on products.
For ex. if we add mytag on 5 products then, the metafields will appear on 5 products only.

 

Let me know if anything I can help.

 

Thanks

Sheesh B

We're here to simplify website creation for those looking to establish a strong online presence. Book a meeting slot if you want to discuss. It's FREE. BOOK NOW | Try Shopify for $1 for 3 Months: Shopify Trial | Shopify Web Store Developer |
LIKE or mark as ACCEPTED SOLUTION

theycallmemakka
Shopify Partner
1476 336 359

Hi @Oneg ,

 

As collapsable rows are part of "main-product.liquid", you will have to update this file to achieve it. If you are using dawn theme, you can add bellow codes on the file.

 

On line number 193 add

{% unless block.settings.content == "" and block.settings.page == "" %}

 

On line number 211 add

{% endunless %}

 

The updated code should look like this [Text marked in red are code that i have added]

makkaomakka_0-1696616829144.png

If you require further help to add the code to your store, please don't hesitate to reach out. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!

 

Best Regards,
Mangit

Buy me a Coffee


Enjoy Shopify for $1. Sign up now


For quick response - Message Me


Ping me at: theycallmemakka@gmail.com

Oneg
Tourist
35 0 2

hey thank you for the reply, it didn't work for me, placed the codes exactly like your picture showed inside main-product.liquid.

To be clear, I want the whole drop down list in the picture to disappear. For this product in the picture, I didn't put a size chart, it's irrelevant. But I do want this size chart drop down to exist in other products where it's relevant.

Oneg_0-1697022641217.png

 

 

Sheesh_b
Shopify Partner
509 112 116

Hi @Oneg 

Did you added the tag to product where it's relevant?

In my code I'm using 'myTag', you can specify your tag and change that tag in the code as well where it says myTag.

<!--   Extra info for custom tags   -->
{% for tag in product.tags %}
    {% if tag contains 'myTag' %}
       //Your metafield code here     
    {% endif %}
{% endfor %}

 

I hope this explains.

 

Thanks

Sheesh B

We're here to simplify website creation for those looking to establish a strong online presence. Book a meeting slot if you want to discuss. It's FREE. BOOK NOW | Try Shopify for $1 for 3 Months: Shopify Trial | Shopify Web Store Developer |
LIKE or mark as ACCEPTED SOLUTION
Oneg
Tourist
35 0 2

hey, where do i paste this code?