Jump to content

Insert barcode(order number) on the delivery slip


VBLED

Recommended Posts

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

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

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

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

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 by VBLED (see edit history)
Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...