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 ---
|
||||
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;
|
||||
const whatsappNumber = orderData.note_attributes?.find?.((attr) => attr.name === 'WhatsApp Number')?.value;
|
||||
const contactNumber = billing.phone || orderData.phone;
|
||||
|
||||
let billingAddressHtml = '';
|
||||
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/>`;
|
||||
}
|
||||
if (billing.country) billingAddressHtml += `${billing.country}<br/>`;
|
||||
if (contactNumber) {
|
||||
billingAddressHtml += `WhatsApp: ${contactNumber}`;
|
||||
if (whatsappNumber) {
|
||||
billingAddressHtml += `WhatsApp: ${whatsappNumber}`;
|
||||
}
|
||||
if (billing.phone || orderData.phone) {
|
||||
if (contactNumber) billingAddressHtml += `<br/>`;
|
||||
billingAddressHtml += `Contact Number: ${billing.phone || orderData.phone}`;
|
||||
if (contactNumber) {
|
||||
if (whatsappNumber) billingAddressHtml += `<br/>`;
|
||||
billingAddressHtml += `Contact Number: ${contactNumber}`;
|
||||
}
|
||||
|
||||
const paymentMethod = orderData.gateway || 'Request Quote';
|
||||
|
||||
@ -132,11 +132,7 @@ const generateInvoicePDF = async (orderData) => {
|
||||
|
||||
// Bill To (Left)
|
||||
const billing = orderData.billing_address || {};
|
||||
const customContactNumber = 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;
|
||||
const whatsappNumber = orderData.note_attributes?.find?.((attr) => attr.name === 'WhatsApp Number')?.value;
|
||||
|
||||
doc.fontSize(11)
|
||||
.font('Helvetica-Bold')
|
||||
@ -172,8 +168,8 @@ const generateInvoicePDF = async (orderData) => {
|
||||
doc.text(orderData.email || orderData.contact_email, 40, billTextY);
|
||||
billTextY += 13;
|
||||
}
|
||||
if (customContactNumber) {
|
||||
doc.text(`WhatsApp: ${customContactNumber}`, 40, billTextY);
|
||||
if (whatsappNumber) {
|
||||
doc.text(`WhatsApp: ${whatsappNumber}`, 40, billTextY);
|
||||
billTextY += 13;
|
||||
}
|
||||
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 = [
|
||||
{
|
||||
name: 'Contact Number',
|
||||
value: customerData.contact_phone || customerData.contactNumber || customerData.contact_number
|
||||
name: 'WhatsApp Number',
|
||||
value: whatsappNumber
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user