Contact Number - add in the invoice
This commit is contained in:
parent
842e9441dd
commit
d0a274dabe
@ -74,6 +74,12 @@ 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
|
||||||
|
|| orderData.attributes?.['Contact Number']?.contact_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) {
|
||||||
billingAddressHtml += `${billing.first_name || ''} ${billing.last_name || ''}<br/>`;
|
billingAddressHtml += `${billing.first_name || ''} ${billing.last_name || ''}<br/>`;
|
||||||
@ -87,6 +93,9 @@ const sendEmailWithAttachment = async (toEmail, orderData, pdfBuffer, shippingLa
|
|||||||
if (billing.phone || orderData.phone) {
|
if (billing.phone || orderData.phone) {
|
||||||
billingAddressHtml += `${billing.phone || orderData.phone}`;
|
billingAddressHtml += `${billing.phone || orderData.phone}`;
|
||||||
}
|
}
|
||||||
|
if (contactNumber) {
|
||||||
|
billingAddressHtml += `<br/>Contact: ${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';
|
||||||
|
|||||||
@ -132,6 +132,12 @@ 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
|
||||||
|
|| 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')
|
||||||
.fillColor(primaryColor)
|
.fillColor(primaryColor)
|
||||||
@ -168,6 +174,10 @@ const generateInvoicePDF = async (orderData) => {
|
|||||||
}
|
}
|
||||||
if (billing.phone || orderData.phone) {
|
if (billing.phone || orderData.phone) {
|
||||||
doc.text(billing.phone || orderData.phone, 40, billTextY);
|
doc.text(billing.phone || orderData.phone, 40, billTextY);
|
||||||
|
billTextY += 13;
|
||||||
|
}
|
||||||
|
if (customContactNumber) {
|
||||||
|
doc.text(`Contact: ${customContactNumber}`, 40, billTextY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Order Details (Right)
|
// Order Details (Right)
|
||||||
|
|||||||
@ -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`, {
|
const shopifyResponse = await fetch(`https://${process.env.SHOPIFY_STORE_DOMAIN}/admin/api/2024-01/orders.json`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user