Filtering a liquid array to remove specific product tags from the output

Solved
Highlighted
Excursionist
27 3 2

Hello,

I currently use product tags to list food allergens on my order printer template, like this:

{{ line_item.product.tags | join: ', ' }}

I have a few product tags that aren't allergens, so I'd like to ensure they are not shown. Is there a method of doing that with an array filter?

Example: I have a product with the tag 'Gluten' but also the tag 'retail-only', I only want to show 'Gluten' on my order printout.

Thanks in advance for any pointers you can give.

Chris

0 Likes
Highlighted
Excursionist
27 3 2

This is an accepted solution.

Found a solution.

{% assign tags_string = line_item.product.tags | join: ', ' %}
{{ tags_string | remove: 'retail-only' | remove: ', retail-only' }}
0 Likes