Different order confirmation emails based on ordered products

I am trying to make product specific order confirmation emails by using Liquid code. I know that Liquid code is the only way to do this, since Shopify still does not offer product specific order confirmation emails. I looked around a bit already and found this very helpful thread, but my usecase is a bit different.

Here is my case: Assume a webshop that sells the following three products:

  1. Car (shipping time: 1 week)

  2. Yacht (shipping time: 2 months)

  3. Private Jet (shipping time: 12 months)

I would like the order confirmation emails to do the following:

  • If there is a private jet among the ordered items display this text: Shipping will take 12 months.
  • If there is a yacht among the ordered items, but not a private jet, display this text: shipping will take 2 months.
  • If there is a car among the ordered items, but no private jet nor yacht, display this text: shipping will take 1 week.

Could anyone transform that into Liquid?

1 Like

Hi, I think this should work. You were not specific in your post, so I just assumed your products listed would match your product type. There are other properties you can play around with as well, such as tags or title.

You should replace the top part of your order confirmation email with below:


{% capture email_title %}Thank you for your purchase! {% endcapture %}
{% for line in subtotal_line_items %}
{% case line.product.type %}
{% when ‘Private Jet’%}
{% assign privateJet = true %}
{% when ‘Yacht’%}
{% assign yacht = true %}
{% endcase %}
{% endfor%}
{% capture shipping_message %}
{% if privateJet %}
Hi {{ customer.first_name }}, shipping will take 12 months.
{% elsif yacht %}
Hi {{ customer.first_name }}, shipping will take 2 months.
{% else %}
Hi {{ customer.first_name }}, shipping will take 1 week.
{% endif %}
{% endcapture %}
{% capture email_body %}
{% if requires_shipping %}
{% case delivery_method %}
{% when ‘pick-up’ %}
You’ll receive an email when your order is ready for pickup.
{% when ‘local’ %}
Hi {{ customer.first_name }}, we’re getting your order ready for delivery.
{% else %}
{{shipping_message}}
{% endcase %}
{% if delivery_instructions != blank %}

Delivery information: {{ delivery_instructions }}

{% endif %} {% endif %} {% endcapture %}
2 Likes