alldz Posted September 28, 2016 Share Posted September 28, 2016 (edited) Hello, To generate an barcode in pdf i user this code: $pdf = new PDFGenerator((bool)Configuration::get('PS_PDF_USE_CACHE')); $barcode_params = $pdf->serializeTCPDFtagParameters(array($this->order->invoice_number, 'C128', '', '', 0, 0, 0.2, array('position'=>'S', 'border'=>false, 'padding'=>0, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>0), 'N')); $this->smarty->assign(array('barcode_params' => $barcode_params)); The problem is that the bar code generated with "$ this-> order-> INVOICE_NUMBER," uses the invoice number without the prefix, eg: 100 in places of IN000100 Do you have an idea on what to do to have the full invoice number? Edited September 28, 2016 by alldz (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted September 30, 2016 Share Posted September 30, 2016 Try changing it to: $pdf = new PDFGenerator((bool)Configuration::get('PS_PDF_USE_CACHE')); $barcode_params = $pdf->serializeTCPDFtagParameters(array(Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number), 'C128', '', '', 0, 0, 0.2, array('position'=>'S', 'border'=>false, 'padding'=>0, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>0), 'N')); $this->smarty->assign(array('barcode_params' => $barcode_params)); Link to comment Share on other sites More sharing options...
ietax Posted September 22, 2017 Share Posted September 22, 2017 How can I generate orders number barcode for mailalert module? thanks Link to comment Share on other sites More sharing options...
ietax Posted September 25, 2017 Share Posted September 25, 2017 I found solution for convert order number to BARCODE image with this script https://www.codeproject.com/Articles/146336/Creating-a-Code-39-Barcode-using-HTML-CSS-and-Java But i have problems to insert it inside a mail on Mailalert. I tried to insert script directly mail but probabily is should modifiy mailalert.php <script type="text/javascript" src="code39.js"></script> <style type="text/css"> #barcode {font-weight: normal; font-style: normal; line-height:normal; sans-serif; font-size: 12pt} </style> </head> <body> Input : {order_name}<br /> <div id="externalbox" style="width:5in"> <div id="inputdata" >{order_name}</div> </div> <br /> <script type="text/javascript"> /* <![CDATA[ */ function get_object(id) { var object = null; if (document.layers) { object = document.layers[id]; } else if (document.all) { object = document.all[id]; } else if (document.getElementById) { object = document.getElementById(id); } return object; } get_object("inputdata").innerHTML=DrawCode39Barcode(get_object("inputdata").innerHTML,0); /* ]]> */ </script> Can anyone help me please? thanks Link to comment Share on other sites More sharing options...
tuk66 Posted September 26, 2017 Share Posted September 26, 2017 Do you mean to put the barcode directly in Mailalert's emails? Emails are text/HTML "pages" and you can't run JavaScript code there. Link to comment Share on other sites More sharing options...
ietax Posted September 26, 2017 Share Posted September 26, 2017 Thanks There is any way to insert barcode (order reference) directly in Mailalert's emails? thanks Link to comment Share on other sites More sharing options...
tuk66 Posted September 26, 2017 Share Posted September 26, 2017 Try https://github.com/picqer/php-barcode-generator to generate an image and use it in the email. Link to comment Share on other sites More sharing options...
ietax Posted September 26, 2017 Share Posted September 26, 2017 ok thanks. I had seen the PHP script but I have a problem: order confirmation email is sent as soon as we receive the order, so I should place that script to generate the images at the end of the order process to get the picture available for the mail .. can you suggest which route to take? thank you Link to comment Share on other sites More sharing options...
rygar Posted August 30, 2018 Share Posted August 30, 2018 On 30/09/2016 at 4:20 AM, rocky said: Try changing it to: $pdf = new PDFGenerator((bool)Configuration::get('PS_PDF_USE_CACHE')); $barcode_params = $pdf->serializeTCPDFtagParameters(array(Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number), 'C128', '', '', 0, 0, 0.2, array('position'=>'S', 'border'=>false, 'padding'=>0, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>0), 'N')); $this->smarty->assign(array('barcode_params' => $barcode_params)); Where do I add this code and would it work with PS 1.7? Link to comment Share on other sites More sharing options...
jerome_08 Posted April 27, 2019 Share Posted April 27, 2019 up, i would like to do same in PS 1.7 anyone knows? Link to comment Share on other sites More sharing options...
ebdeuslave Posted June 14, 2022 Share Posted June 14, 2022 SOLVED - Hello guys , i've been searching many times and tried to use TCPDFBarcode module i wrote the code as mentioned in the TCPDF Documentation but did not work i got an idea, which is to convert text to barcode using only html and css, i found it using a font family, and tried many times to include it in prestashop and finally found a solution , TCPDF can't recognize new fonts we have to convert it to its supported formats, so follow those steps : A : Generate font by CLI (if there is a command line interface in your server otherwise read A steps and go to B steps) 1 - download woff2 file from : https://fonts.gstatic.com/s/librebarcode39/v19/-nFnOHM08vwC6h8Li1eQnP_AHzI2G_Bx0g.woff2 2 - convert it to .ttf format using this link : https://cloudconvert.com/woff2-to-ttf 3 - put .ttf file to this path \vendor\tecnickcom\tcpdf\tools (optionally: rename it because you will use that name as font-family name, Ex : barcodefont) 4 - use this command line to convert/add font by TCPDF : php tcpdf_addfont.php -i barcodefont.ttf (php required in your local host if you use B steps) then 3 files will be generating to this path : \vendor\tecnickcom\tcpdf\fonts including font name barcodefont.php barcodefont.ctg.z barcodefont.z B : convert font to TCPDF formats using your local machine 1 - install prestashop to your local host using xampp with compatible php version to prestashop 1.7 (xampp V3.3.0) Google that if you are not familiar with local host server 2 - after doing A steps , put those 3 files to \vendor\tecnickcom\tcpdf\fonts in your server 3 - use this in *.tpl file : <p style="font-family: 'barcodefont';font-size: 30px;text-align:center">*{$YOUR_VAR} or your text*</p> NOTE : * is required before and after text, it's an encode technique of 'C39 type' if you want to include some variables in invoice.tpl follow those steps: 1 - go to classes/pdf/HTMLTemplateInvoice.php 2 - search for getContent function 3 - and add your variables before Data array ($data) Ex : $phone_mobile= $invoice_address->phone_mobile; $phone= $invoice_address->phone; $nb_orders = count(Order::getCustomerOrders((int)$this->order->id_customer)); // this is total orders of a client 4 - then add them below to Data array : 'phone_mobile' => $phone_mobile, 'phone' => $phone, 'nb_orders' => $nb_orders, 5 - then insert your variable to invoice.tpl like this : {$phone_mobile) if you want to convert it to barcode use this : <p style="font-family: 'barcodefont';font-size: 30px;text-align:center">*{$phone_mobile}*</p> // do not forget * before and after variable DONE, if you find this useful share it ^^ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now