How to use a custom developed section to be different on each template i include.

JunaidT
New Member
5 0 0

Hi,

I have made a custom Shopify section that I want to include in some custom product templates. But when I include it in template 1 e.g (product-temp1) it works for 1 time and when I add it to template 2 it shows the data of template 1 which I don't want. 

 

Anyone who can help me out to make it unique for each template?

0 Likes
Mircea_Piturca
Shopify Partner
1484 42 306

That is a real bummer with sections. Only on the homepage, you can have this behavior.

You can duplicate the file, e.g.: section-1.liquid, section-2.liquid... and conditionally include those based on the product handle.

{% if product.handle == 'foo' %}
  {% section 'section-1' %}
{% elsif product.handle == 'fee' %}
  {% section 'section-2' %}
{% endif %}

Of course, this is painfully and unmaintainable but will work.

Shopify announced 3 years ago that they are working on a new solution. I am waiting for eversince. 

Finally—Add variant descriptions to your products
0 Likes