VBLED Posted November 4, 2023 Share Posted November 4, 2023 Hello, I want to show order number as a barcode on the delivery slip, there are some posts from prestashop forum, but all does not work on PS8. Can someone help? Here is the code I tried to add to pdf/delivery-slip.tpl {assign var=black value=[0,0,0]}{assign var=white value=[255,255,255]} {assign var=stuff value=['position'=>'S', 'border'=>false, 'padding'=>4, 'fgcolor'=>$black, 'bgcolor'=>$white, 'text'=>false, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4]} {assign var=params value=TCPDF::serializeTCPDFtagParameters(array($order->getUniqReference(), 'C39', '', '', 40, 15, 0.4, $stuff, 'N'))} <tcpdf method="write1DBarcode" params="{$params}" /> Link to comment Share on other sites More sharing options...
VBLED Posted November 5, 2023 Author Share Posted November 5, 2023 Can you tell me the details how to add Barcode on the delivery slip? I changed the file vendor/tecnickcom/tcpdf/config/tcpdf_config.php: define('K_TCPDF_CALLS_IN_HTML', true); I also changed the file controllers/admin/AdminPdfController.php public function generatePDF($object, $template) { $pdf = new PDF($object, $template, Context::getContext()->smarty); $this->context->smarty->assign("tcpdf", $pdf->pdf_renderer); $pdf->render(); } then I add these code to pdf/delivery-slip.tpl <tr> <td style="width: 17%"></td> <td style="width: 83%"> {assign var=black value=[0,0,0]}{assign var=white value=[255,255,255]} {assign var=stuff value=['position'=>'S', 'border'=>false, 'padding'=>4, 'fgcolor'=>$black, 'bgcolor'=>$white, 'text'=>false, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4]} {assign var=params value=TCPDF::serializeTCPDFtagParameters(array($order->getUniqReference(), 'C39', '', '', 40, 15, 0.4, $stuff, 'N'))} <tcpdf method="write1DBarcode" params="{$params}" /> </td> </tr> But still does not work, do you have a solution? Link to comment Share on other sites More sharing options...
VBLED Posted November 5, 2023 Author Share Posted November 5, 2023 Here I made screenshot for the PDF delievery slip, I want to put the barcode on the PDF like this. The barcode is CODE128, it it the order number when you scan it. Link to comment Share on other sites More sharing options...
VBLED Posted November 5, 2023 Author Share Posted November 5, 2023 Hello, Question 1: I use PDFGenerator class in classes/pdf/HTMLTemplateDeliverySlip.php $pdf = new PDFGenerator((bool)Configuration::get('PS_PDF_USE_CACHE')); $barcode_params = $pdf->serializeTCPDFtagParameters(array('CODE 39', 'C39', '', '', 80, 30, 0.4, array('position'=>'S', 'border'=>true, 'padding'=>4, 'fgcolor'=>array(0,0,0), 'bgcolor'=>array(255,255,255), 'text'=>true, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4), 'N')); $this->smarty->assign(array('barcode_params' => $barcode_params)); Questions 2. I would like to gernerate an barcode image with base64 and add it to the delievery slip template. Link to comment Share on other sites More sharing options...
VBLED Posted November 5, 2023 Author Share Posted November 5, 2023 I don't want to create a new module, can I just put this function getEanImageBase64 inside the file: controllers/admin/AdminPdfController.php Is this OK? Link to comment Share on other sites More sharing options...
VBLED Posted November 5, 2023 Author Share Posted November 5, 2023 Yes, I already tried to use this module generator, but my PS is 8.0.4, and this tool only compitable with 1.7.x Link to comment Share on other sites More sharing options...
QuickUpdate.net Posted November 5, 2023 Share Posted November 5, 2023 (edited) You can change the compliancy level manually in the generated module code - and there is a good chance the module you generate is compatible with PS8 also Edited November 5, 2023 by QuickUpdate.net (see edit history) Link to comment Share on other sites More sharing options...
VBLED Posted November 6, 2023 Author Share Posted November 6, 2023 Thank you very much. I will wait for your module, and install it. Link to comment Share on other sites More sharing options...
VBLED Posted November 6, 2023 Author Share Posted November 6, 2023 I just installed the module, but it shows: Oops! An Error Occurred The server returned a "500 Internal Server Error". Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused. Link to comment Share on other sites More sharing options...
VBLED Posted November 7, 2023 Author Share Posted November 7, 2023 I reinstalled the module, but still the same 500 internal error. Link to comment Share on other sites More sharing options...
VBLED Posted November 8, 2023 Author Share Posted November 8, 2023 (edited) My prestashop version 8.0.4, I already installed two times, all failed. I don't know what is the reason, my php version 8.1. I changed the core file order.php for customizing the order number, the function code like this: public static function generateReference() { $last_id = Db::getInstance()->getValue(' SELECT MAX(id_order) FROM '._DB_PREFIX_.'orders'); $newRef=(int)$last_id + 1; $prefix = 'VE'; return $prefix.str_pad($newRef, 7, '0000000', STR_PAD_LEFT); } Edited November 8, 2023 by VBLED (see edit history) Link to comment Share on other sites More sharing options...
VBLED Posted November 8, 2023 Author Share Posted November 8, 2023 The reason is many modules only support to 8.0.4, they still not support 8.1.0. Actually Prestashop always lots of bugs, every new version fixed some bugs and then create some other bugs, endless.... I just want to stay with one version and fix these bugs by myself when I found the bugs. Link to comment Share on other sites More sharing options...
VBLED Posted November 10, 2023 Author Share Posted November 10, 2023 I tried many times to update from 8.0.4 to 8.0.5, always show errors. But I upgrade to 8.1.2, it shows successfully, but actually not sucess. All modules are disabled after upgrade, and front end all page show no page found. I have to roll back to 8.0.4. Link to comment Share on other sites More sharing options...
VBLED Posted November 17, 2023 Author Share Posted November 17, 2023 When debug and generate delivery slip, it shows error: Non-static method TCPDF::serializeTCPDFtagParameters() cannot be called statically Link to comment Share on other sites More sharing options...
dnk.hack Posted November 17, 2023 Share Posted November 17, 2023 Hello, I'll try to help you this weekend. 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