mail number fixed
This commit is contained in:
parent
95fd8fefa1
commit
000b1ce970
70
mailer.js
70
mailer.js
@ -72,42 +72,58 @@ const sendEmailWithAttachment = async (toEmail, orderData, pdfBuffer, shippingLa
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- 3. Billing Address Details HTML ---
|
// --- 3. Billing Address Details HTML ---
|
||||||
const billing = orderData.billing_address || {};
|
const billing = orderData.billing_address || {};
|
||||||
|
|
||||||
// Get separate numbers
|
// Contact Number (from Contact field only)
|
||||||
const contactNumber = orderData.contact_number || orderData.phone;
|
const contactNumber =
|
||||||
|
orderData.note_attributes?.find?.(
|
||||||
|
(attr) => attr.name === 'Contact Number'
|
||||||
|
)?.value ||
|
||||||
|
orderData.attributes?.['Contact Number']?.contact_phone ||
|
||||||
|
orderData.attributes?.['Contact Number'];
|
||||||
|
|
||||||
const whatsappNumber =
|
// WhatsApp Number
|
||||||
orderData.whatsapp_number ||
|
const whatsappNumber =
|
||||||
orderData.attributes?.['Whatsapp Number'];
|
orderData.note_attributes?.find?.(
|
||||||
|
(attr) => attr.name === 'Whatsapp Number'
|
||||||
|
)?.value ||
|
||||||
|
orderData.attributes?.['Whatsapp Number'] ||
|
||||||
|
billing.phone ||
|
||||||
|
orderData.phone;
|
||||||
|
|
||||||
let billingAddressHtml = '';
|
|
||||||
|
|
||||||
if (billing.first_name || billing.last_name) {
|
let billingAddressHtml = '';
|
||||||
billingAddressHtml += `${billing.first_name || ''} ${billing.last_name || ''}<br/>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (billing.address1) billingAddressHtml += `${billing.address1}<br/>`;
|
if (billing.first_name || billing.last_name) {
|
||||||
if (billing.address2) billingAddressHtml += `${billing.address2}<br/>`;
|
billingAddressHtml += `${billing.first_name || ''} ${billing.last_name || ''}<br/>`;
|
||||||
|
}
|
||||||
|
|
||||||
if (billing.city || billing.province || billing.zip) {
|
if (billing.address1) {
|
||||||
billingAddressHtml += `${billing.city || ''} ${billing.province || ''} ${billing.zip || ''}<br/>`;
|
billingAddressHtml += `${billing.address1}<br/>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (billing.country) {
|
if (billing.address2) {
|
||||||
billingAddressHtml += `${billing.country}<br/>`;
|
billingAddressHtml += `${billing.address2}<br/>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show contact number
|
if (billing.city || billing.province || billing.zip) {
|
||||||
if (contactNumber) {
|
billingAddressHtml += `${billing.city || ''} ${billing.province || ''} ${billing.zip || ''}<br/>`;
|
||||||
billingAddressHtml += `Contact: ${contactNumber}<br/>`;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Show WhatsApp number separately
|
if (billing.country) {
|
||||||
if (whatsappNumber) {
|
billingAddressHtml += `${billing.country}<br/>`;
|
||||||
billingAddressHtml += `WhatsApp: ${whatsappNumber}`;
|
}
|
||||||
}
|
|
||||||
|
// Show WhatsApp
|
||||||
|
if (whatsappNumber) {
|
||||||
|
billingAddressHtml += `<strong>WhatsApp:</strong> ${whatsappNumber}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show Contact Number
|
||||||
|
if (contactNumber) {
|
||||||
|
billingAddressHtml += `<br/><strong>Contact Number:</strong> ${contactNumber}`;
|
||||||
|
}
|
||||||
|
|
||||||
const paymentMethod = orderData.gateway || 'Request Quote';
|
const paymentMethod = orderData.gateway || 'Request Quote';
|
||||||
const shippingMethod = orderData.shipping_lines?.[0]?.title || 'Economy';
|
const shippingMethod = orderData.shipping_lines?.[0]?.title || 'Economy';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user