Using Shopify shipping notifications

JoeNes
Visitor
2 0 1

I'm trying to set up shipping notification emails for different products that ship differently to each other, but I'm not having any luck when testing these. 

 

I am using the code below, but whenever the specialised products are purchased, the customer just gets the normal email rather than the one that is for their specific product.

 

Wondering if someone else has a similar experience? And how did you resolve it? 

 

 

<p>Oh hi there</p> 
  
<p>It's Dash here again with an update on your purchase &#128012;</p>

<p><strong>I've just followed the trail down to the post office and mailed your order.</strong></p>

{% if line.product.id == 7908089954545 %}

<p>You can expect your 5x greeting cards pack to arrive within 3-5 business days, depending on your location.</p>

{% elsif line.product.id == 7908880613617 %}

<p>You can expect your 10x greeting cards pack to arrive within 3-5 business days, depending on your location.</p>

{% else %}

<p>Since I'm a nostalgic kind of snail, I've used an Australia Post stamp rather than a prepaid envelope for the card(s) that you requested to be sent directly to the recipient's home. I think that makes it feel extra special to the person who receives it - I hope you agree!</p>

<p>You can expect your order to arrive within 2-8 business days.</p>
{% endif %}
<p>It would be faster if everyone could just carry their home on their back like I do!.</p>

<p>Anyway, I hope you're keeping well. Thanks again for being so thoughtful to the people in your life - the world needs more people like you.</p>

<p>Lots of love &#128156;</p>

<p>Dash &#128012;</p>

 

  

Replies 2 (2)

JoesIdeas
Shopify Expert
2220 201 591

You have to first access the line_items object to check each individual line_item.

 

For example:

{% for item in line_items %}
  {% if item.product.title contains "5x" %}
    <p>Info about these type of products</p>
  {% elsif item.variant.sku == "some_sku" %}
    <p>Example here for checking by product sku</p>
  {% endif %}
{% endfor %}

 

That will cycle through each line item in the order, and execute the code if the IF statement is true.

 

For reference on what variables you can use, see: https://help.shopify.com/en/manual/orders/notifications/email-variables#line-item

 

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Deal with Fraud / Chargebacks
JoeNes
Visitor
2 0 1

Thanks a lot for your advice. Much appreciated 🙂