Using Liquid Code to Customize Order Confirmation Emails

Highlighted
Tourist
9 0 0

Hi,

Our client wants us to customize the "Order Confirmation" notification email so that when different products are purchased, the message that received is slightly different.

I'm not too familiar with liquid code so I was wondering if anyone could assist. Based on the product that is purchased, the message received will have to vary slightly. I believe this can be done with if-then statements, but I'm not sure where to start. 

Basically, it would be "if the product purchased was "x", then the message received would read "y". X and Y would change based on the product, but other than that it would be very simple.

Appreciate any help,

Rachel

0 Likes
Highlighted
Shopify Partner
833 127 141

Hi Rachel,

I see your point, how many products are we talking about here? The code to change is in "Settings" -> "Notifications" -> "Order Confirmation"

- Did we solve your issue? Like & Mark As Solution to help the community
- Should you need any direct help: contact@jhkconsultancy.com
K&J
0 Likes
Highlighted
Tourist
9 0 0

Hi @JHKC,

Thanks for the response. I have found where to edit the email, I just need to figure out how to edit it to make it work for me now.

There would be 5 different scenarios in total, but numerous products linked to each email.

We sell software. So if the customer purchases CS, CN, L1, L2, US, or R licenses from our shop, we would need to send them one email.

If the customer purchases EL1, EL2, or ELL licenses we would need to send them a different notice.

Does that make a little more sense? I saw on a plugin I was going to use that if you were to type in something like this:

{% assign product_ids = order.cart.cart_items | map: 'product' | map: 'id' %}
{% if product_ids contains 1234 %} Message for product 1234 {% endif %}
{% if product_ids contains 4321 %} Message for product 4321 {% endif %}

 then different emails would go out to the customers for different products. But I don't know that that transfers over to Shopify exactly. This was an example from SendOwl, I was not sure if liquid code would be the same. I would need to achieve something similar to what is in that example though.

Thanks,

Rachel

0 Likes
Highlighted
Shopify Partner
833 127 141

This is what I usually use for case scenarios like, works flawlessly: 

{% assign ContainsProduct1 = 0 %}

{% for line in subtotal_line_items %}
      
{% if line.product.id == 64681818615591 %}
{% assign ContainsProduct1 = 1 %}
{%endif%}

{%endfor%}
- Did we solve your issue? Like & Mark As Solution to help the community
- Should you need any direct help: contact@jhkconsultancy.com
K&J
0 Likes
Highlighted
Tourist
9 0 0

Thanks @JHKC,

I see where line.product.id is I would input MY product id, but with the code you provided is there somewhere where you input the custom messages?

 

0 Likes
Highlighted
Shopify Partner
833 127 141

Here's an example:

 

{% assign ContainsProduct1 = 0 %}

{% for line in subtotal_line_items %}
      
{% if line.product.id == 64681818615591 %}
{% assign ContainsProduct1 = 1 %}
{%endif%}

{% if ContainsProduct1 == 1 %}
CUSTOM CODE
{%endif%}

{%endfor%}

 

- Did we solve your issue? Like & Mark As Solution to help the community
- Should you need any direct help: contact@jhkconsultancy.com
K&J
0 Likes