Email order confirmation - varying message by product selected

Highlighted
New Member
3 0 0

Hi there,

 

I'm am trying to modify my order confirmation email depending on the type of product selected. 

 

For most prints I only need a short 'thanks for your order' message. But for personalised prints I want to include more info on the next steps.

 

I've tweaked the email liquid to include a line.title contains logic, to identify if the additional paragraph is added.

 

{% capture email_title %}Thank you so much for your purchase! {% endcapture %}
{% capture email_body %}

<p>Hi {{ customer.first_name }}, 

<p>Thank you for ordering our from our print shop!</p>

{% for line in line_items %}
{% if line.title contains 'Personalised' %}

<p>Our designers will be getting your design started shortly from the info you've supplied. </p>
<p>Once they've got your draft ready we'll send it to you for approval, let us know if there are any tweaks you'd like us to make, and once you're happy we can start the printing process.</p>

<p>We aim to get our draft to you within 48 hours so keep an eye on your inbox!</p>

{% endif %}
{% endfor %}
<p>All the best,</p>

<p>Lorcan from Illustratif</p>



{% endcapture %}

However, I'm running into an issue whereby if someone orders 2 personalised products in their order the email shows the same paragraph twice, as below:

 

double paragraph.JPG

 

Can anyone give any insight into how to only show the extra text once, regardless of the number of personalised products added to cart?

 

Many thanks,

 

Lorcan

0 Likes
Highlighted
Shopify Partner
31 1 13

Hi Lorcan,

 

Probably best to set a variable the first time the message is printed and then check for that variable before printing again:

 

{% assign messageprinted = false %}
{% for line in line_items %}
{% if line.title contains 'Personalised' and messageprinted == false %}

<p>Our designers will be getting your design started shortly from the info you've supplied. </p>
<p>Once they've got your draft ready we'll send it to you for approval, let us know if there are any tweaks you'd like us to make, and once you're happy we can start the printing process.</p>

<p>We aim to get our draft to you within 48 hours so keep an eye on your inbox!</p>
{% assign messageprinted = true %}
{% endif %}
{% endfor %}

* I've not tested the code, but hopefully you get the idea.

0 Likes