diff --git a/mailer.js b/mailer.js
index a6534ca..ce921a3 100644
--- a/mailer.js
+++ b/mailer.js
@@ -36,32 +36,20 @@ const sendEmailWithAttachment = async (toEmail, orderData, pdfBuffer) => {
// --- 1. Generate Order Summary Rows HTML ---
let orderRowsHtml = '';
if (orderData.line_items && orderData.line_items.length > 0) {
- orderData.line_items.forEach(item => {
- // Shopify stores product image under item.image (object with src) or item.featured_image.url
- const itemImageUrl = (item.image && item.image.src)
- || (item.image && typeof item.image === 'string' ? item.image : '')
- || (item.featured_image && item.featured_image.url)
- || '';
- const imageHtml = itemImageUrl
- ? `
-
- | `
- : `
-
- | `;
-
- const variantText = item.variant_title ? `${item.variant_title}` : '';
- const itemTotal = (parseFloat(item.price) * item.quantity).toFixed(2);
-
+ orderData.line_items.forEach((item, index) => {
+ const itemPrice = parseFloat(item.price).toFixed(2);
+ const rowBg = index % 2 === 0 ? '#ffffff' : '#f8fafc';
orderRowsHtml += `
-
- ${imageHtml}
- |
- ${item.title || item.name} × ${item.quantity}
- ${variantText}
+ |
+
+ ${item.title || item.name}
+ ${item.variant_title ? ` ${item.variant_title}` : ''}
|
-
- ${currencySymbol}${itemTotal}
+ |
+ ${item.quantity}
+ |
+
+ ${currencySymbol}${itemPrice}
|
`;
@@ -118,55 +106,40 @@ const sendEmailWithAttachment = async (toEmail, orderData, pdfBuffer) => {
-
+
-
-
-
-
-
- |
-
- Order #${orderNumber}
- |
-
-
+ |
+ New Order: #${orderNumber}
|
-
+
-
- Thank you for your order!
-
- We're getting your order ready to be shipped. We have attached your custom PDF invoice directly to this email.
+ |
+
+ You've received the following order from
+ ${orderData.billing_address ? `${orderData.billing_address.first_name || ''} ${orderData.billing_address.last_name || ''}`.trim() : (orderData.contact_email || 'a customer')}:
+
+
+ ${orderData.order_status_url
+ ? `[Order #${orderNumber}]`
+ : `[Order #${orderNumber}]`
+ }
+ (${new Date(orderData.created_at || Date.now()).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' })})
|
-
- ${orderData.order_status_url ? `
+
- |
-
- View your order
-
- or Visit our store
- |
-
- ` : ''}
-
-
-
-
- Order summary
- |
-
-
-
-
-
-
+
+
+
+
+ | Product |
+ Quantity |
+ Price |
+
${orderRowsHtml}
|
| |