diff --git a/send-label-test.js b/send-label-test.js index bf5506f..3a625f2 100644 --- a/send-label-test.js +++ b/send-label-test.js @@ -29,9 +29,15 @@ async function sendTestShippingLabelEmail() { }, email: process.env.SMTP_USER, line_items: [ +<<<<<<< HEAD { name: 'Flat Bangle 4 Cut - Each Box', quantity: 1, price: '130.00' }, { name: 'Glue Stick pencil - 1 piece', quantity: 3, price: '35.00' }, { name: 'E-8000 - 50ML - 1 Piece', quantity: 2, price: '60.00' } +======= + { name: 'Flat Bangle 4 Cut - Each Box', quantity: 1, price: '130.00', image_url: 'https://picsum.photos/200' }, + { name: 'Glue Stick pencil - 1 piece', quantity: 3, price: '35.00', image_url: 'https://picsum.photos/200' }, + { name: 'E-8000 - 50ML - 1 Piece', quantity: 2, price: '60.00', image_url: 'https://picsum.photos/200' } +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 ] }; diff --git a/shippingLabelGenerator.js b/shippingLabelGenerator.js index 60c68ac..386529a 100644 --- a/shippingLabelGenerator.js +++ b/shippingLabelGenerator.js @@ -23,7 +23,11 @@ function drawBarcode(doc, x, y, width, height, text) { currentX += lineWidth + spacing; } +<<<<<<< HEAD // Barcode number text below bars +======= + // Barcode number text below bars (with extra vertical gap and letter spacing) +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 doc.fontSize(8.5) .font('Helvetica-Bold') .fillColor('#000000') @@ -70,14 +74,22 @@ const generateShippingLabelPDF = async (orderData) => { // --- BACKGROUND --- doc.rect(0, 0, W, H).fill('#ffffff'); +<<<<<<< HEAD // --- OUTER BORDER --- +======= + // --- OUTER BORDER (Thicker, professional frame) --- +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 doc.rect(6, 6, W - 12, H - 12) .lineWidth(2) .strokeColor('#1e293b') .stroke(); // ============================================================ +<<<<<<< HEAD // SECTION 1: HEADER STRIP +======= + // SECTION 1: HEADER STRIP (FROM shop info) +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 // ============================================================ const headerY = 6; const headerH = 58; @@ -93,7 +105,11 @@ const generateShippingLabelPDF = async (orderData) => { } catch (e) { /* silent fail */ } } +<<<<<<< HEAD // Shop name text +======= + // Shop name text (right side of header) +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 doc.fontSize(12.5) .font('Helvetica-Bold') .fillColor('#ffffff') @@ -106,7 +122,11 @@ const generateShippingLabelPDF = async (orderData) => { .text('Madurai 625016, Tamil Nadu, India | Ph: 9994333548', logoLoaded ? 95 : PAD, headerY + 38, { width: W - (logoLoaded ? 111 : PAD * 2) }); // ============================================================ +<<<<<<< HEAD // SECTION 2: ORDER INFO STRIP +======= + // SECTION 2: ORDER INFO STRIP (Left-Right Aligned) +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 // ============================================================ const orderStripY = headerY + headerH; const orderStripH = 30; @@ -116,20 +136,32 @@ const generateShippingLabelPDF = async (orderData) => { const orderDate = new Date(orderData.created_at || Date.now()).toLocaleDateString('en-GB'); const shippingMethod = orderData.shipping_lines?.[0]?.title || 'Standard Courier'; +<<<<<<< HEAD // Order Number +======= + // Order Number on Left +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 doc.fontSize(9.5) .font('Helvetica-Bold') .fillColor('#0f172a') .text(`ORDER: #${orderNumber}`, PAD, orderStripY + 10); +<<<<<<< HEAD // Date | Courier Method +======= + // Date | Courier Method on Right +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 doc.fontSize(8) .font('Helvetica-Bold') .fillColor('#475569') .text(`${orderDate} | ${shippingMethod}`, PAD, orderStripY + 11, { width: W - PAD * 2, align: 'right' }); // ============================================================ +<<<<<<< HEAD // SECTION 3: SHIP TO SECTION HEADER +======= + // SECTION 3: SHIP TO SECTION +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 // ============================================================ const shipToLabelY = orderStripY + orderStripH; const shipToLabelH = 18; @@ -141,7 +173,11 @@ const generateShippingLabelPDF = async (orderData) => { .text('SHIP TO', PAD, shipToLabelY + 5, { width: W - PAD * 2, align: 'center' }); // ============================================================ +<<<<<<< HEAD // SECTION 4: CUSTOMER ADDRESS +======= + // SECTION 4: CUSTOMER ADDRESS (Clean typesetting) +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 // ============================================================ const addressStartY = shipToLabelY + shipToLabelH + 12; const shipping = orderData.shipping_address || orderData.billing_address || {}; @@ -155,6 +191,10 @@ const generateShippingLabelPDF = async (orderData) => { const toZip = shipping.zip || ''; const toCountry = shipping.country || 'India'; +<<<<<<< HEAD +======= + // Customer Name +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 doc.fontSize(14) .font('Helvetica-Bold') .fillColor('#0f172a') @@ -162,6 +202,10 @@ const generateShippingLabelPDF = async (orderData) => { let currentY = addressStartY + 18; +<<<<<<< HEAD +======= + // Customer Phone (Clean phone icon fallback) +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 if (toPhone) { doc.fontSize(9.5) .font('Helvetica-Bold') @@ -170,6 +214,10 @@ const generateShippingLabelPDF = async (orderData) => { currentY += 14; } +<<<<<<< HEAD +======= + // Customer Address lines combined with consistent spacing +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 const addressParts = []; if (toAddr1) addressParts.push(toAddr1); if (toAddr2) addressParts.push(toAddr2); @@ -190,9 +238,17 @@ const generateShippingLabelPDF = async (orderData) => { .fillColor('#334155') .text(addressText, PAD, currentY, { width: W - PAD * 2, lineGap: 3.5 }); +<<<<<<< HEAD const addressHeight = doc.heightOfString(addressText, { width: W - PAD * 2, lineGap: 3.5 }); currentY += addressHeight + 10; +======= + // Calculate height of the address block to dynamically place the separator + const addressHeight = doc.heightOfString(addressText, { width: W - PAD * 2, lineGap: 3.5 }); + currentY += addressHeight + 10; + + // Ensure the separator doesn't overflow if address is short or long +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 const minSeparatorY = 250; const sepY = Math.max(currentY, minSeparatorY); @@ -206,7 +262,11 @@ const generateShippingLabelPDF = async (orderData) => { .stroke(); // ============================================================ +<<<<<<< HEAD // SECTION 6: FROM ADDRESS (Return address) +======= + // SECTION 6: FROM ADDRESS (Ray Aari Shop - Return address) +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 // ============================================================ const fromY = sepY + 10; @@ -231,7 +291,11 @@ const generateShippingLabelPDF = async (orderData) => { .text(shopAddressText, PAD, fromY + 24, { width: W - PAD * 2, lineGap: 2 }); // ============================================================ +<<<<<<< HEAD // SECTION 7: BARCODE STRIP +======= + // SECTION 7: BARCODE STRIP (Locked to Bottom) +>>>>>>> a15558d565f56829553c2991c516ac93d4428ff5 // ============================================================ const barcodeAreaY = H - 75; doc.rect(6, barcodeAreaY, W - 12, 1).fill('#cbd5e1');