Customizing Shopify Order Confirmation Emails for Preorder Products
This guide specifically addresses how to modify your Shopify email templates to highlight preorder items in your customers' orders. We'll walk you through the steps to not only flag products that are preordered but also to add a custom message in the email, ensuring that your customers are well-informed about the status of their preorder items.
To modify the Shopify order confirmation emails to display products as preorders and to add custom text for preorders, you need to edit the Liquid template code. Here's a step-by-step guide to help you achieve this:
Step 1: Access the Email Template
- Login to Shopify Admin: Sign in to your Shopify store admin.
- Navigate to Settings: At the bottom left of the admin page, click on 'Settings'.
- Go to Notifications: In the settings menu, click on 'Notifications'.
- Find Order Confirmation Email: Scroll to find the 'Order confirmation' email template.
Step 2: Identify the Preorder Products
To identify if a product is a preorder, you'll need to check if the _preorder
key is present in the product variant line item property. You can do this using Liquid's for
loop and if
statements.
Step 3: Add Custom Text for Preorders
You'll need to add an if
condition to check if any product in the order is a preorder. If yes, display the custom text.
Step 4: Modify the Liquid Template
Here's how you can modify the template:
Detect Preorder Items
{% assign preorder_exists = false %}
{% for item in line_items %}
{% if item.properties['_preorder'] %}
{% assign preorder_exists = true %}
{% endif %}
{% endfor %}
Display Custom Text if Preorders are Present
Right before the "Order Summary" section (before <h3>Order summary</h3>
), add:
{% if preorder_exists %}
<p>Preorders are present in this order. Will ship when available.</p>
{% endif %}
Mark Individual Items as Preorder
In the section where each line item is displayed ({% for line in subtotal_line_items %}
), modify the display of each item to show if it's a preorder:
{% for line in subtotal_line_items %}
...
{% if line.properties['_preorder'] %}
<span class="order-list__item-title">{{ line_title }} × {{ line_display }} (Preorder)</span><br/>
{% else %}
<span class="order-list__item-title">{{ line_title }} × {{ line_display }}</span><br/>
{% endif %}
...
{% endfor %}
Step 5: Test Your Changes
After making these changes:
- Preview the Email: Use the 'Preview' option in Shopify to see how the email looks.
- Send Test Email: Send a test email to yourself to ensure everything is working as expected.
Step 6: Save Changes
Once you are satisfied with the changes, click on 'Save' to apply these modifications to the live email template.
Final Notes
- Make sure to test thoroughly with different scenarios (orders with and without preorders).
- The exact placement of the code may vary based on your current template structure.
- Always backup the current email template before making changes.