Best way to get list of all available tags in a filtered collection

medlingtonQPS
Shopify Partner
27 0 8

Hi,

Im trying to recreate the filter by tags functionailty that Shopify have so brilliantly removed.

I need to get a list of all the available tags within the current filtered collection but not sure on the best way to do this.

collection.all_tags - gets all the available tags but this includes tags from products which have been filtered.

current_tags - gets all the active filters

 

I thought Id be able to test if the tag was in collection.all_tags and then test if it wasnt in current_tags but this doesnt work as I need because some of the avilable filters should be removed when certain products are filtered but they still seem to appear.

 

eg, I have 3 products with the following tags

product 1 - Tag A, Tag B, Tag C

product 2 - Tag A, Tag B, Tag D

product 3 - Tag C, Tag D, Tag E

 

If I click on my filter to select only the products which have Tag A it displays product 1 and 2 in the list but still has the option to filter by Tag E which is no longer a valid filter as none of the displayed products have Tag E.

collection.all_tags will contain: Tag A, B, C, D, and E

currrent_tags will contain: Tag A

Is there an equivilant that will contain only: Tag A,B,C,and D as these will be the remaining valid tags which are assigned to the visible products?

Hope Ive managed to eamplain that clearly

Thanks

 

 

 

Replies 2 (2)

medlingtonQPS
Shopify Partner
27 0 8

After no help from Shopify Pro support (other than advice to buy a paid app) I found an external website that told me to use this which seems to work.

collection.tags

Hope that helps sombody else

nicolewhitley
Tourist
10 0 23

Thanks for the fix!