Adapt content of notification emails based on products purchased

Hi everyone,

for quite a while now, I have tried to get some custom content in my Order Confirmation notification email but it won’t work. I need to include some special information and a link to a PDF, if a customer purchased certain products. It’s three different products and three different PDFs. Here is the code:

{% capture email_title %}Thanks for your purchase!{% endcapture %}
{% capture email_body %}
Hi {{ customer.first_name }},

we are preparing the next steps to get your purchase ready.
{% if line.title contains 'gift card' %}
You will receive your gift card code in a separate email shortly.
{% endif %}
{% if line.title contains 'Workshop' %}
Thanks for booking our workshop. You will find all the information in the PDF linked below. If you booked the workshop for someone else, you can also forward or print the PDF.

[Click here to access the PDF.](https://cdn.shopify.com/s/XXX.pdf)
{% endif %}
{% if line.title contains 'Workshop2' %}
Thanks for booking our workshop2. You will find all the information in the PDF linked below. If you booked the workshop for someone else, you can also forward or print the PDF.

[Click here to access the PDF.](https://cdn.shopify.com/s/XXX2.pdf)
{% endif %}
{% endcapture %}

I also already tried this with if in combination with elsif, as well as variations of line_title, line.product.title etc. Can anyone enlighten me, why this isn't working? Every Order Confirmation email just prints the stuff written before the first if statement.

I read through some threads here and through the documentation but I can't find a solution. I am not familiar with programming.

Looking forward to get this solved. Thanks!

Hi, just checking to see if you were able to solve this issue with your order notifications yet?

Just from a glance, I’d try cutting down everything out of the email except for your ifs and building it back up from there.

There could be something very subtle occurring here - of course it could also be something obvious which we hasn’t passed our minds yet :slightly_smiling_face:


If you’re looking to sell digital products, you might find some value in our blog - we’ll be focusing on bringing even more content there in the near future.