customizing email notification issue

Solved
Highlighted
Excursionist
16 0 3

Hi There!

Hope you can help me. I need to send specific instructions for customers buying different products from my shop. I want to include the specifications on the order notification email, but of course it has to be set up on a way people buying certain items gets the right specification.  so I tried adding conditional content using liquid operators ( shopify blog developer help) "It’s possible to display specific content for individual products on an email, using conditional Liquid operators. With if statements you can add text, or images, that will appear when a product fulfills criteria that you set up." 

{% if line.title contains 'Book' %}
<p>These are the instructions for the Book</p>
{% endif %}

 Unfortunately this did not work on my email template see bellow: ( the highlighted area is what I inserted) Please help as I am struggling with this for a while. Much appreciated 

Nats

shopify email issue.JPG

0 Likes
Highlighted

Hey @Naty1 

I think the 'contains' operator is case sensitive. Which means that most probably your logic doesn't work because the value returned from 'line.title' has a capital letter e.g. 'Farm' instead of 'farm'.

A solution would be:

{% assign line_title_value = line.title | handleize %}
{% if line_title_value contains 'farm' %}
    // Your code here
{% endif %}


I prefer 'handleize' instead of 'downcase' as it will replace also any spaces with dashes https://shopify.dev/docs/themes/liquid/reference/filters/string-filters#handle-handleize 

Hope that will help!

Best,

Deni

0 Likes
Highlighted
Excursionist
16 0 3

Hi Deni

Thanks so much for your help! I did try what you suggested but still dosnt work :/ perhaps I am not doing right? this is what I did:

 

Hi {{ customer.first_name }}, we're getting your order ready to be shipped. We will notify you when it has been sent.
{% assign line_title_value = line.title | handleize %}
{% if line_title_value contains 'farm' %}
// In the meantime, you can download your set’s audio files from the following link. You can download them one at a time or choose the Zip-file to get them all at once.

<a href=http://files.differentisgood.co.za/>Link to Farm animal set audio file</a>

0 Likes
Highlighted

@Naty1 

Replace 'handelize' with 'downcase' and check if that works.

0 Likes
Highlighted
Excursionist
16 0 3

Hi dany

ok... this is just not working! :( I realized I was inserting the info in the wrong cell. so I did exactly as they show us on the example for the blog developer (  bellow the line.variant.title)  but still doesn't work! I am having an error when saving (as per picture shopify email issue 01.JPG) ...and then if I change to %endorf% as suggested... I get another message saying ...use %endif% ...makes no sense...

Here is what I did...please please, could you tell me exactly what  to do to make it work? this is something that I will be implementing with at least 3 products and I really need this "customize-product email" to work 

Here what I did:

{% if line.variant_title != 'Default Title' %}
<span class="order-list__item-variant">{{ line.variant_title }}</span><br/>
{% endif %}
{% assign line_title_value = line.title | handleize %} {% if line_title_value contains 'farm' %} // In the meantime, you can download your set’s audio files from the following link. You can download them one at a time or choose the Zip-file to get them all at once
<a href=http://files.differentisgood.co.za/>Link to Farm animal set audio file</a>
{% endorf %}

 

 

 

0 Likes
Highlighted

This is an accepted solution.

Hi @Naty1 

Just copy/paste the code below and see how it goes

 

 

{% if line.variant_title != 'Default Title' %}
<span class="order-list__item-variant">{{ line.variant_title }}</span><br/>
{% endif %}
{% assign line_title_value = line.title | downcase %} {% if line_title_value contains 'farm' %} In the meantime, you can download your set’s audio files from the following link. You can download them one at a time or choose the Zip-file to get them all at once <a href=http://files.differentisgood.co.za/>Link to Farm animal set audio file</a> {% endif %}

'endfor' if the closing element of 'for', and 'endif' is the closing element of 'if'. So you can't close the {% if %} statement with {% endfor %}. Also you've got a spelling mistake  {% endorf %}

Let me know how it goes

 

1 Like
Highlighted
Excursionist
16 0 3

you are a super star! it works! :) and I did the same with another product and also works like a charm! Thanks so much for your help! 

1 Like
Highlighted

You are welcome @Naty1 

0 Likes
Highlighted
New Member
1 0 0

Hello @MladenGorchev @Naty1 

 

I am trying to do the same thing, except for every product in my store. Any ideas on streamlining this process?

 

BH

0 Likes