Contact Number - add in the invoice

This commit is contained in:
vidhya 2026-06-20 17:17:04 +05:30
parent 842e9441dd
commit d0a274dabe
3 changed files with 28 additions and 0 deletions

View File

@ -74,6 +74,12 @@ 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;
let billingAddressHtml = '';
if (billing.first_name || billing.last_name) {
billingAddressHtml += `${billing.first_name || ''} ${billing.last_name || ''}<br/>`;
@ -87,6 +93,9 @@ const sendEmailWithAttachment = async (toEmail, orderData, pdfBuffer, shippingLa
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';

View File

@ -132,6 +132,12 @@ 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;
doc.fontSize(11)
.font('Helvetica-Bold')
.fillColor(primaryColor)
@ -168,6 +174,10 @@ const generateInvoicePDF = async (orderData) => {
}
if (billing.phone || orderData.phone) {
doc.text(billing.phone || orderData.phone, 40, billTextY);
billTextY += 13;
}
if (customContactNumber) {
doc.text(`Contact: ${customContactNumber}`, 40, billTextY);
}
// Order Details (Right)

View File

@ -206,6 +206,15 @@ app.post('/create-order', async (req, res) => {
}
};
if (customerData.contact_phone || customerData.contactNumber || customerData.contact_number) {
orderPayload.order.note_attributes = [
{
name: 'Contact Number',
value: customerData.contact_phone || customerData.contactNumber || customerData.contact_number
}
];
}
const shopifyResponse = await fetch(`https://${process.env.SHOPIFY_STORE_DOMAIN}/admin/api/2024-01/orders.json`, {
method: 'POST',
headers: {