both contact number display
This commit is contained in:
parent
89218f5fb7
commit
4e1b3b8963
17
mailer.js
17
mailer.js
@ -74,11 +74,8 @@ 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 || {};
|
||||||
const contactNumber = orderData.note_attributes?.find?.((attr) => attr.name === 'Contact Number')?.value
|
const whatsappNumber = orderData.note_attributes?.find?.((attr) => attr.name === 'WhatsApp Number')?.value;
|
||||||
|| orderData.attributes?.['Contact Number']?.contact_phone
|
const contactNumber = billing.phone || orderData.phone;
|
||||||
|| orderData.attributes?.['Contact Number']
|
|
||||||
|| orderData.contact_phone
|
|
||||||
|| orderData.attributes?.contact_phone;
|
|
||||||
|
|
||||||
let billingAddressHtml = '';
|
let billingAddressHtml = '';
|
||||||
if (billing.first_name || billing.last_name) {
|
if (billing.first_name || billing.last_name) {
|
||||||
@ -90,12 +87,12 @@ const sendEmailWithAttachment = async (toEmail, orderData, pdfBuffer, shippingLa
|
|||||||
billingAddressHtml += `${billing.city || ''} ${billing.province || ''} ${billing.zip || ''}<br/>`;
|
billingAddressHtml += `${billing.city || ''} ${billing.province || ''} ${billing.zip || ''}<br/>`;
|
||||||
}
|
}
|
||||||
if (billing.country) billingAddressHtml += `${billing.country}<br/>`;
|
if (billing.country) billingAddressHtml += `${billing.country}<br/>`;
|
||||||
if (contactNumber) {
|
if (whatsappNumber) {
|
||||||
billingAddressHtml += `WhatsApp: ${contactNumber}`;
|
billingAddressHtml += `WhatsApp: ${whatsappNumber}`;
|
||||||
}
|
}
|
||||||
if (billing.phone || orderData.phone) {
|
if (contactNumber) {
|
||||||
if (contactNumber) billingAddressHtml += `<br/>`;
|
if (whatsappNumber) billingAddressHtml += `<br/>`;
|
||||||
billingAddressHtml += `Contact Number: ${billing.phone || orderData.phone}`;
|
billingAddressHtml += `Contact Number: ${contactNumber}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const paymentMethod = orderData.gateway || 'Request Quote';
|
const paymentMethod = orderData.gateway || 'Request Quote';
|
||||||
|
|||||||
@ -132,11 +132,7 @@ const generateInvoicePDF = async (orderData) => {
|
|||||||
|
|
||||||
// Bill To (Left)
|
// Bill To (Left)
|
||||||
const billing = orderData.billing_address || {};
|
const billing = orderData.billing_address || {};
|
||||||
const customContactNumber = orderData.note_attributes?.find?.((attr) => attr.name === 'Contact Number')?.value
|
const whatsappNumber = orderData.note_attributes?.find?.((attr) => attr.name === 'WhatsApp Number')?.value;
|
||||||
|| orderData.attributes?.['Contact Number']?.contact_phone
|
|
||||||
|| orderData.attributes?.['Contact Number']
|
|
||||||
|| orderData.contact_phone
|
|
||||||
|| orderData.attributes?.contact_phone;
|
|
||||||
|
|
||||||
doc.fontSize(11)
|
doc.fontSize(11)
|
||||||
.font('Helvetica-Bold')
|
.font('Helvetica-Bold')
|
||||||
@ -172,8 +168,8 @@ const generateInvoicePDF = async (orderData) => {
|
|||||||
doc.text(orderData.email || orderData.contact_email, 40, billTextY);
|
doc.text(orderData.email || orderData.contact_email, 40, billTextY);
|
||||||
billTextY += 13;
|
billTextY += 13;
|
||||||
}
|
}
|
||||||
if (customContactNumber) {
|
if (whatsappNumber) {
|
||||||
doc.text(`WhatsApp: ${customContactNumber}`, 40, billTextY);
|
doc.text(`WhatsApp: ${whatsappNumber}`, 40, billTextY);
|
||||||
billTextY += 13;
|
billTextY += 13;
|
||||||
}
|
}
|
||||||
if (billing.phone || orderData.phone) {
|
if (billing.phone || orderData.phone) {
|
||||||
|
|||||||
@ -210,11 +210,12 @@ app.post('/create-order', async (req, res) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (customerData.contact_phone || customerData.contactNumber || customerData.contact_number) {
|
const whatsappNumber = customerData.whatsapp_number || customerData.contact_phone || customerData.contactNumber;
|
||||||
|
if (whatsappNumber) {
|
||||||
orderPayload.order.note_attributes = [
|
orderPayload.order.note_attributes = [
|
||||||
{
|
{
|
||||||
name: 'Contact Number',
|
name: 'WhatsApp Number',
|
||||||
value: customerData.contact_phone || customerData.contactNumber || customerData.contact_number
|
value: whatsappNumber
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user