Shopify confirmation email message using tags

Hi there,

I am trying to customise my order confirmation message based on the product line_item tags that exist.

I want to show a messaged based on either one of the tags exist on any product, or if both tags exist.

The set up can be:

  • If only tree, show one message
  • If only biodiversity, show a different message
  • If both, then show another custom message

I currently have this which is only returning the tag on the last product:

{% assign tag_list = ' ' %}
{% for line in line_items %}
    {% for tag in line.product.tags %}
        {{ tag }}
        {% assign tag_list = tag | join ', ' %}
    {% endfor %}
{% endfor %}
<h5>{{ tag_list }}</h5>

Let me know if this doesn’t make enough sense and I can try explain a little more!

Thanks in advance.

---------- JUST ANSWERED MY OWN QUESTION -----------

Stupidly just worked it out myself!!

{% if line.product.tags contains 'tree' %}
  tree
{% elsif line.product.tags contains 'biodiversity' %}
  biodiversity
{% else %}
  both
{% endfor%}
1 Like

Thank you! This helps us a lot!

line.product.tags aren’t even showing in Shopify’s notification reference table. It’s such a trick and so helpful!