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