diff --git a/send-label-test.js b/send-label-test.js index 3a625f2..ea46d8a 100644 --- a/send-label-test.js +++ b/send-label-test.js @@ -29,15 +29,9 @@ 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/shipping-label-test.pdf b/shipping-label-test.pdf index 5aa0578..7041d1c 100644 Binary files a/shipping-label-test.pdf and b/shipping-label-test.pdf differ diff --git a/shippingLabelGenerator.js b/shippingLabelGenerator.js index 386529a..553edaa 100644 --- a/shippingLabelGenerator.js +++ b/shippingLabelGenerator.js @@ -23,11 +23,7 @@ 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') @@ -74,22 +70,14 @@ 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; @@ -105,11 +93,7 @@ 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') @@ -122,11 +106,7 @@ 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; @@ -136,32 +116,20 @@ 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; @@ -173,11 +141,7 @@ 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 || {}; @@ -191,10 +155,7 @@ 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') @@ -202,10 +163,7 @@ 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') @@ -214,10 +172,7 @@ 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); @@ -238,17 +193,11 @@ 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); @@ -262,11 +211,7 @@ 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; @@ -291,11 +236,7 @@ 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');