I'm new to Shopify Liquid Theme language and trying to find my way. I have the following products in my Shopify store with their tags:
CATEGORY CLOTHING
t-shirt-A
- Tags: t, -dog1-
t-shirt-B
- Tags: t, cat2
CATEGORY MUG
mug-A
- Tags: m, -dog1-
mug-B
- Tags: m, cat2
CATEGORY PHONECASE
phonecase-A
- Tags: p, -dog1-
phonecase-B
- Tags: p, cat2
From the above products you can see that t-shirt-A
and t-shirt-B
have similar tag "t", mug-A
and mug-B
have similar tag "m", etc...
You could also see that t-shirt-A, mug-A and Phonecase-A
have a common second tag -dog1-. Though they belong to different collections/categories yet they have that -dog1- tag in addition to their specific first tags. I gave them additional -dog1- tag because they have the same dog image on them.
t-shirt-A, mug-A and Phonecase-A
have the same dog image on them.
Now what I want to achieve is when a user is in the product detail page of t-shirt-A
, I want to display other products (from different categories) which have the same image on them. In this case I want my liquid theme to display mug-A
and Phonecase-A
so that the user will see that the image on the t-shirt is also on the mug and the phonecase.
I have followed all the tutorials of Liquid and also the filters but I can't find any filter that can help me to select the tag of the current product with pattern matching like -[a-zA-Z]-.
The reason I say pattern matching is that other t-shirts, mugs, and phonecases are going to have -dog2- image on them.
So I think with pattern matching you can select a particular tag from the current product tag arrays that matches for instance -[a-zA-Z]- and when you have this particular tag you can compare it to all the tags in all the categories and select products that have the same tag.