Solved

Create dynamic section based on product tags within my product section

Archalia
Tourist
5 0 1

Within my product template which includes my section, I would like to add a slider of a new dynamic section based on my product tags that will show information regarding its ingredients.

let's say I have 3 tags like ingredient:foo & ingredient:bar & foobar on my product.

I can pick only the ones prefixed with ingredient , that's fine.

I can render a snippet with that tag. That's fine.

But for every tag I render inside the snippet, I would like to add new specific data to show: an image, a title, a description and so on.

I wanted to create a {% schema %} for this, but I can't do that inside a snippet element. And I can't render a section within a section.

Is there a way for me to configure an image, a title, a description for every tag I have retrieved, and display them dynamically on all my products that contain those tags, using section and snippets ?

 

 

Accepted Solution (1)
AlexHodzitsky
Shopify Partner
72 19 27

This is an accepted solution.

But unless I am mistaken, by doing this I will have to manually add all the ingredients one by one for every product and set the image, the body content etc

You will not need to configure settings in this section for each product. If you specify settings in a section, they will be used everywhere (except for "presets" on the Home Page). In your case, you will place information about ingredients in the product section settings and with regard to product tags you will get the information you need from the blocks and render the section. I hope I explained it clearly. This method should be sufficient, so there is no point in using the third method.

Alex

I didn't choose the Shopify, the Shopify chose me.
Linkedin: alex-hodzitsky

View solution in original post

Replies 4 (4)

AlexHodzitsky
Shopify Partner
72 19 27

Hi Archalia! Hope you are doing well!

There are several options for how you can achieve the desired result:

1. Metafields App that have the repeatable blocks/sections. For example: https://apps.shopify.com/accentuate

2. Why not add the settings you need to an existing product section? For example, in the form of blocks.

3. Render section via JavaScript. Create alternative product template, then put into it your section with settings. And from your product page you need to do the request into this alternative template to grab the settings, then you can do some magic with that data and render your ingredient section. If you are interested in this method, then let me know and I will sign you in more detail with screenshots.

Hope this helps.

Alex

I didn't choose the Shopify, the Shopify chose me.
Linkedin: alex-hodzitsky
Archalia
Tourist
5 0 1

Hello Alex, thank you for the quick reply.

 

2. That was my first thought. But unless I am mistaken, by doing this I will have to manually add all the ingredients one by one for every product and set the image, the body content etc.., regardless of their tags. My idea was if I use tags, whenever I add a new product and correctly set the tags, it will render the ingredient section accordingly.

3. Had no idea we could do this in JS. Hard to see how it really works. Yeah if you think it suits my requirements I am interested to see some screenshots 😄

AlexHodzitsky
Shopify Partner
72 19 27

This is an accepted solution.

But unless I am mistaken, by doing this I will have to manually add all the ingredients one by one for every product and set the image, the body content etc

You will not need to configure settings in this section for each product. If you specify settings in a section, they will be used everywhere (except for "presets" on the Home Page). In your case, you will place information about ingredients in the product section settings and with regard to product tags you will get the information you need from the blocks and render the section. I hope I explained it clearly. This method should be sufficient, so there is no point in using the third method.

Alex

I didn't choose the Shopify, the Shopify chose me.
Linkedin: alex-hodzitsky
Archalia
Tourist
5 0 1

You absolutely right, thank you very much !