Related Product based on Products Tag

Highlighted
Shopify Partner
2 0 0

I am new to the whole shopify platform and so far it has been great. Still getting my head around the use of liquid, been stuck on how to achieve this one so thought I may as well try asking the community.

So, I followed the guide at: https://help.shopify.com/en/themes/customization/products/features/recommend-related-products

I'm using the Venture theme. I added the additional code and no problems recommend products is working.

My issue is that I was trying to edit the code to achieve what I wanted out of it but was struggling.

I basically want to show related products from one collection, but from that collection only if the current product viewed has a matching tag to something in the selected collection.

Something along the lines of:

If currently viewed product contains tag = to tag in (select collection), display as related product.

Any help I could get with this would be greatly appricated.

Cheers Cam

0 Likes
Highlighted
Shopify Staff
Shopify Staff
634 16 201

Hi Cam,

Great to see you're looking to optimize your product pages, so let's see how we could sort this out. I wrote a blog post last year on creating a recommended products section, which is based on the Debut theme. However, the basic idea should be the same. The critical control flow tag is:

{% if product.tags contains 'X' %} 

Which should be wrapped around where products are loading. 

I'd recommend that you take a look at the tutorial and see if you can use it as a guide for Venture.

Best of luck & let us know how you get on.

Liam

Liam Griffin
Shopify | Developer Community Manager
0 Likes
Highlighted
Shopify Partner
2 0 0

Thanks Liam for that, having troubles addapting that code to what I need to do but has defintly assited and developed my knowloedge of the language. Thank you for that and will continue to try and update the forum if I have any succes. 

Cheers Cam

0 Likes
Highlighted
New Member
3 0 0

Hi Liam,

 

Do you know if there is another solution for this? I would love to be able to show related products which have the same product tags.

 

The reason for this is that I have over 1000 products, but only around 4-5 products will be relevant to my customers. Is it possible to only display related products when the tags match 100%?

 

Thanks in advance

0 Likes
Highlighted
New Member
1 0 0

Sorry to bring this back up. I followed the steps to create a recommended product section created by tags, I gave four products a tag of 'related' which matches the code of if it contains:
{% if product.tags contains  'related' %}.

Then on my website I switched the number of products per row to 4 and number of rows to 1, however it only will show two of the four products with the tags. The only products with these tags show up on the section if the product is on the first page of my products (I have 3 or 4 pages of different products in the main admin hub). I have no problem showing 4 products though if they are on the first page of products. The photo below shows the page and how it is looking. How can I make it so I can show any product in this section that is not limited to the first page of products?

1.JPG

0 Likes
Highlighted
Shopify Partner
5 0 9

Hi Parker, Did you ever find a cause or solution for your issue?

I'm having a similar problem in that certain products with the appropriate tag don't display and others do.

I can't seem to find any difference between the products that do display in the section and the ones that don't.

Thanks

0 Likes