Custom Message in Confirmation Email Notification Based on Product Tag

Solved

Custom Message in Confirmation Email Notification Based on Product Tag

Carver_Junk_Com
Excursionist
12 1 7

I am trying to customize the Email Confirmation sent to customers, based on whether the order contains a product with the tag "pre-order." I have found various posts around this topic, and have tried every variation posted (that others claim to work for them) without any luck. Here is what I have currently. I have seen different variations on the "line.product.tags" and don't even know if I'm using the correct snytax here. Any help is appreciated!

 

{% capture email_title %}Thank you for your purchase! {% endcapture %}
{% capture email_body %}
{% if requires_shipping %}
{% if line.product.tags contains "pre-order" %}
Your order contains a pre-order item. All items in this order will ship with the pre-order, based on the timing provided on the item's product details. 
{% else%}
Hi {{ customer.first_name }}, we're getting your order ready. Our current shipping/pickup time is approximately 2-3 days. We will notify you when it has been sent or is ready for pickup (along with curbside pickup time slot options), based on your selection.

{% endif %}
{% endif %}
{% endcapture %}

Accepted Solution (1)
Carver_Junk_Com
Excursionist
12 1 7

This is an accepted solution.

THANK YOU! This worked when I ordered one item, but printed multiple messages when I ordered multiple items. I resolved that by further editing with a count:

{% capture email_title %}Thank you for your purchase! {% endcapture %}
{% capture email_body %}
{% if requires_shipping %}
{% assign count = 0 %}
{% for line in line_items %}
{% if line.product.tags contains "pre-order" %}
{% if count < 1 %}
{% assign count = count | plus: 1 %}
Your order contains a pre-order item. All items in this order will ship with the pre-order, based on the timing provided on the item's product details. 

{% elsif count == 1 %}
Hi {{ customer.first_name }}, we're getting your order ready. Our current shipping/pickup time is approximately 2-3 days. We will notify you when it has been sent or is ready for pickup (along with curbside pickup time slot options), based on your selection.
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endcapture %}

View solution in original post

Replies 4 (4)

Avi_choudhary
Shopify Partner
49 4 6

can you replace your code and check please

{% for line in line_items %}
{% if line.product.tags contains "pre-order" %}
Your order contains a pre-order item. All items in this order will ship with the pre-order, based on the timing provided on the item's product details. 
{% else%}
Hi {{ customer.first_name }}, we're getting your order ready. Our current shipping/pickup time is approximately 2-3 days. We will notify you when it has been sent or is ready for pickup (along with curbside pickup time slot options), based on your selection.
{% endif %}
{% endfor %}

 

it's should be work because line. product work in for loop only

 

Carver_Junk_Com
Excursionist
12 1 7

This is an accepted solution.

THANK YOU! This worked when I ordered one item, but printed multiple messages when I ordered multiple items. I resolved that by further editing with a count:

{% capture email_title %}Thank you for your purchase! {% endcapture %}
{% capture email_body %}
{% if requires_shipping %}
{% assign count = 0 %}
{% for line in line_items %}
{% if line.product.tags contains "pre-order" %}
{% if count < 1 %}
{% assign count = count | plus: 1 %}
Your order contains a pre-order item. All items in this order will ship with the pre-order, based on the timing provided on the item's product details. 

{% elsif count == 1 %}
Hi {{ customer.first_name }}, we're getting your order ready. Our current shipping/pickup time is approximately 2-3 days. We will notify you when it has been sent or is ready for pickup (along with curbside pickup time slot options), based on your selection.
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endcapture %}

Miza
Shopify Partner
1 0 0

Didn't work for me.
The less than operator "<" was the culprit in: {% if count < 1 %}.
Replaced statement with:
{% unless count >= 1 %}
  . . .
{% else %}
  . . . 
{% endunless %}

Pair_of_Squares
Excursionist
16 0 4

Can you explain exactly where to insert this code? I have the same issue but I'm not that familliar with coding. Does it go in the email notification template HTML editor or in the theme editor? Thank you