If you would like to customize your notification emails to display variable content based on customer tags from a given order, you can add custom code to the email templates to display or hide discounts, text, images, or other content based on how the customer is tagged in your Shopify admin.

The most common emails this code is applied to are:

- Order Confirmation

- Shipping Confirmation

This guide will show you how to display the following variable content based on the customers tag in the given order:

- Discount Codes

- Images

- Text

- Product Recommendations

Using a common example to illustrate this, let's say you don't want to display discount codes to your customers tagged 'wholesale' but you do want to show a discount code to all of your other customers.

Once you're in the template builder, drag & drop the custom code component (it has an icon that looks like <>) on to the template above the desired location you want the content to dynamically show.

In the example below, we’re using the tag ‘wholesale’ but if you have a different tag, you can replace it with your own tag.

Insert this code into the custom code component (this code cannot be seen by customers on their notifications):

{% assign is_filteredOut = false %}
{% for tag in customer.tags %}
{% if tag == 'wholesale' %}
{% assign is_filteredOut = true %}
{% endif %}
{% endfor %}
{% if is_filteredOut == false %}

Then drag and drop the discount code component you want to include under the custom code component.

Finally, drag and drop a second custom code component below the variable content you want to include. Insert this code into the component:

```{% endif %}```

Here is a video of this process being done:

To make these changes effective, make sure you set the email templates live into Shopify again, and make sure to test an order to see if it's working as intended. Have fun!

Did this answer your question?