feat: Redesign email to match screenshot - dark header banner, order link, Product/Qty/Price table

This commit is contained in:
Alaguraj0361 2026-05-18 23:13:10 +05:30
parent 62a135dc85
commit f18a018a38

View File

@ -36,32 +36,20 @@ const sendEmailWithAttachment = async (toEmail, orderData, pdfBuffer) => {
// --- 1. Generate Order Summary Rows HTML --- // --- 1. Generate Order Summary Rows HTML ---
let orderRowsHtml = ''; let orderRowsHtml = '';
if (orderData.line_items && orderData.line_items.length > 0) { if (orderData.line_items && orderData.line_items.length > 0) {
orderData.line_items.forEach(item => { orderData.line_items.forEach((item, index) => {
// Shopify stores product image under item.image (object with src) or item.featured_image.url const itemPrice = parseFloat(item.price).toFixed(2);
const itemImageUrl = (item.image && item.image.src) const rowBg = index % 2 === 0 ? '#ffffff' : '#f8fafc';
|| (item.image && typeof item.image === 'string' ? item.image : '')
|| (item.featured_image && item.featured_image.url)
|| '';
const imageHtml = itemImageUrl
? `<td style="padding: 15px 0; width: 60px; vertical-align: middle;">
<img src="${itemImageUrl}" alt="${item.title}" style="width: 50px; height: 50px; border-radius: 6px; border: 1px solid #e2e8f0; object-fit: cover;" />
</td>`
: `<td style="padding: 15px 0; width: 60px; vertical-align: middle;">
<div style="width: 50px; height: 50px; border-radius: 6px; border: 1px solid #e2e8f0; background: #f8fafc;"></div>
</td>`;
const variantText = item.variant_title ? `<span style="font-size: 12px; color: #64748b; display: block; margin-top: 2px;">${item.variant_title}</span>` : '';
const itemTotal = (parseFloat(item.price) * item.quantity).toFixed(2);
orderRowsHtml += ` orderRowsHtml += `
<tr style="border-bottom: 1px solid #f1f5f9;"> <tr style="background-color: ${rowBg};">
${imageHtml} <td style="padding: 10px 12px; font-family: Helvetica, Arial, sans-serif; font-size: 13px; color: #1e293b; border: 1px solid #e2e8f0;">
<td style="padding: 15px 10px; vertical-align: middle; font-family: Helvetica, Arial, sans-serif; font-size: 14px; color: #1e293b;"> ${item.title || item.name}
<span style="font-weight: bold;">${item.title || item.name}</span> &times; ${item.quantity} ${item.variant_title ? `<br/><span style="font-size: 11px; color: #64748b;">${item.variant_title}</span>` : ''}
${variantText}
</td> </td>
<td style="padding: 15px 0; text-align: right; vertical-align: middle; font-family: Helvetica, Arial, sans-serif; font-size: 14px; font-weight: bold; color: #1e293b; width: 120px;"> <td style="padding: 10px 12px; text-align: center; font-family: Helvetica, Arial, sans-serif; font-size: 13px; color: #1e293b; border: 1px solid #e2e8f0; width: 80px;">
${currencySymbol}${itemTotal} ${item.quantity}
</td>
<td style="padding: 10px 12px; text-align: right; font-family: Helvetica, Arial, sans-serif; font-size: 13px; color: #1e293b; border: 1px solid #e2e8f0; width: 100px;">
${currencySymbol}${itemPrice}
</td> </td>
</tr> </tr>
`; `;
@ -118,55 +106,40 @@ const sendEmailWithAttachment = async (toEmail, orderData, pdfBuffer) => {
<td align="center"> <td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px; background-color: #ffffff; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03); overflow: hidden; padding: 30px;"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px; background-color: #ffffff; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03); overflow: hidden; padding: 30px;">
<!-- Header Logo & Order number --> <!-- DARK HEADER BANNER -->
<tr> <tr>
<td style="padding-bottom: 25px;"> <td style="background-color: #3d3d3d; padding: 24px 30px; border-radius: 8px 8px 0 0; margin-bottom: 0;">
<table border="0" cellpadding="0" cellspacing="0" width="100%"> <h1 style="font-family: Helvetica, Arial, sans-serif; font-size: 26px; font-weight: bold; color: #ffffff; margin: 0;">New Order: #${orderNumber}</h1>
<tr>
<td style="font-family: Helvetica, Arial, sans-serif;">
<img src="data:${logoMimeType};base64,${logoBase64}" alt="rayaarishop" style="height: 60px; width: auto; display: block;" />
</td>
<td align="right" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; color: #94a3b8; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px;">
Order #${orderNumber}
</td>
</tr>
</table>
</td> </td>
</tr> </tr>
<!-- GREETINGS --> <!-- INTRO TEXT & ORDER LINK -->
<tr> <tr>
<td style="font-family: Helvetica, Arial, sans-serif; padding-bottom: 20px;"> <td style="padding: 25px 0 20px 0;">
<h1 style="font-size: 22px; font-weight: bold; color: #1e293b; margin: 0 0 10px 0;">Thank you for your order!</h1> <p style="font-family: Helvetica, Arial, sans-serif; font-size: 14px; color: #475569; margin: 0 0 15px 0;">
<p style="font-size: 14px; line-height: 1.5; color: #475569; margin: 0;"> You've received the following order from
We're getting your order ready to be shipped. We have attached your custom PDF invoice directly to this email. <strong style="color: #1e293b;">${orderData.billing_address ? `${orderData.billing_address.first_name || ''} ${orderData.billing_address.last_name || ''}`.trim() : (orderData.contact_email || 'a customer')}</strong>:
</p>
<p style="font-family: Helvetica, Arial, sans-serif; font-size: 14px; color: #475569; margin: 0;">
${orderData.order_status_url
? `<a href="${orderData.order_status_url}" target="_blank" style="color: #1d4ed8; font-weight: bold; text-decoration: none;">[Order #${orderNumber}]</a>`
: `<strong>[Order #${orderNumber}]</strong>`
}
<strong> (${new Date(orderData.created_at || Date.now()).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' })})</strong>
</p> </p>
</td> </td>
</tr> </tr>
<!-- ACTION BUTTON --> <!-- ORDER SUMMARY TABLE with HEADER ROW -->
${orderData.order_status_url ? `
<tr> <tr>
<td style="padding: 10px 0 30px 0;"> <td style="padding-bottom: 20px;">
<a href="${orderData.order_status_url}" target="_blank" style="display: inline-block; background-color: #0284c7; color: #ffffff; font-family: Helvetica, Arial, sans-serif; font-size: 14px; font-weight: bold; text-decoration: none; padding: 12px 24px; border-radius: 6px; box-shadow: 0 2px 4px rgba(2, 132, 199, 0.2);"> <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse; border: 1px solid #e2e8f0;">
View your order <!-- Table Header -->
</a> <tr style="background-color: #f1f5f9;">
<span style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; color: #64748b; margin-left: 15px;">or <a href="https://rayaarishop.myshopify.com" target="_blank" style="color: #0284c7; text-decoration: none;">Visit our store</a></span> <td style="padding: 10px 12px; font-family: Helvetica, Arial, sans-serif; font-size: 13px; font-weight: bold; color: #1e293b; border: 1px solid #e2e8f0;">Product</td>
</td> <td style="padding: 10px 12px; text-align: center; font-family: Helvetica, Arial, sans-serif; font-size: 13px; font-weight: bold; color: #1e293b; border: 1px solid #e2e8f0; width: 80px;">Quantity</td>
</tr> <td style="padding: 10px 12px; text-align: right; font-family: Helvetica, Arial, sans-serif; font-size: 13px; font-weight: bold; color: #1e293b; border: 1px solid #e2e8f0; width: 100px;">Price</td>
` : ''} </tr>
<!-- ORDER SUMMARY HEADER -->
<tr>
<td style="padding-bottom: 10px; border-bottom: 2px solid #e2e8f0;">
<h2 style="font-family: Helvetica, Arial, sans-serif; font-size: 15px; font-weight: bold; color: #1e293b; margin: 0; text-transform: uppercase; letter-spacing: 0.5px;">Order summary</h2>
</td>
</tr>
<!-- LINE ITEMS TABLE -->
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
${orderRowsHtml} ${orderRowsHtml}
</table> </table>
</td> </td>