I have 4 variant for a single product. but all of them may not be available. some variants will have pre order option. i want to customize the email template that is when a user order an item with an available variant the email should show “thankyou for your purchase” and when a user purchase an item with a pre order variant it should show “thankyou for your pre order”. what i did right now is i have created meta fields for the product and set is pre order true for the variant which is not available. and edited the email template as below
{% assign delivery_method_types = delivery_agreements | map: ‘delivery_method_type’ | uniq %}
{% if delivery_method_types.size > 1 %}
{% assign has_split_cart = true %}
{% else %}
{% assign has_split_cart = false %}
{% endif %}
{% assign is_preorder = false %}
{% for line in order.line_items %}
{% if line.variant.metafields.custom.preorder == true %}
{% assign is_preorder = true %}
{% endif %}
{% endfor %}
{% capture email_title %}
{% if is_preorder %}
Thank you for your pre-order!
{% elsif has_pending_payment %}
Thank you for your order!
{% else %}
Thank you for your purchase!
{% endif %}
{% endcapture %}
{% capture email_body %}
{% if has_pending_payment %}
{% if buyer_action_required %}
You’ll get a confirmation email after completing your payment.
{% else %}
Your payment is being processed. You’ll get an email when your order is confirmed.
{% endif %}
{% else %}
{% 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 %}
We're getting your order ready to be shipped. We will notify you when it has been sent.
{% endcase %}
{% if delivery_instructions != blank %}
<p><b>Delivery information:</b> {{ delivery_instructions }}</p>
{% endif %}
{% if consolidated_estimated_delivery_time %}
{% if has_multiple_delivery_methods %}
<h3 class="estimated_delivery__title">Estimated delivery</h3>
<p>{{ consolidated_estimated_delivery_time }}</p>
{% else %}
<p>
Estimated delivery <b>{{ consolidated_estimated_delivery_time }}</b>
</p>
{% endif %}
{% endif %}
{% endif %}
{% endif %}
But this is not working as expected. still when a customer order a pre order product. the default email is sending which shows “Thankyou for your purchase”