diff --git a/mailer.js b/mailer.js
index 59cc28d..a07a747 100644
--- a/mailer.js
+++ b/mailer.js
@@ -74,27 +74,39 @@ const sendEmailWithAttachment = async (toEmail, orderData, pdfBuffer, shippingLa
// --- 3. Billing Address Details HTML ---
const billing = orderData.billing_address || {};
- const contactNumber = orderData.note_attributes?.find?.((attr) => attr.name === 'Contact Number')?.value
- || orderData.attributes?.['Contact Number']?.contact_phone
- || orderData.attributes?.['Contact Number']
- || orderData.contact_phone
- || orderData.attributes?.contact_phone;
+
+ // Get separate numbers
+ const contactNumber = orderData.contact_number || orderData.phone;
+
+ const whatsappNumber =
+ orderData.whatsapp_number ||
+ orderData.attributes?.['Whatsapp Number'];
let billingAddressHtml = '';
+
if (billing.first_name || billing.last_name) {
billingAddressHtml += `${billing.first_name || ''} ${billing.last_name || ''}
`;
}
+
if (billing.address1) billingAddressHtml += `${billing.address1}
`;
if (billing.address2) billingAddressHtml += `${billing.address2}
`;
+
if (billing.city || billing.province || billing.zip) {
billingAddressHtml += `${billing.city || ''} ${billing.province || ''} ${billing.zip || ''}
`;
}
- if (billing.country) billingAddressHtml += `${billing.country}
`;
- if (billing.phone || orderData.phone) {
- billingAddressHtml += `${billing.phone || orderData.phone}`;
+
+ if (billing.country) {
+ billingAddressHtml += `${billing.country}
`;
}
+
+ // Show contact number
if (contactNumber) {
- billingAddressHtml += `
Contact: ${contactNumber}`;
+ billingAddressHtml += `Contact: ${contactNumber}
`;
+ }
+
+ // Show WhatsApp number separately
+ if (whatsappNumber) {
+ billingAddressHtml += `WhatsApp: ${whatsappNumber}`;
}
const paymentMethod = orderData.gateway || 'Request Quote';