Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Bruno

Can't generate barcode in smarty

Recommended Posts

Hi guys,

I made a customisation in prestashop 1.6.15, in delivery-slip.tpl to write a barcode with order id: 

{assign var=black value=[0,0,0]}{assign var=white value=[255,255,255]}
{assign var=stuff value=['position'=>'S', 'border'=>false, 'padding'=>3, 'fgcolor'=>$black, 'bgcolor'=>$white, 'text'=>true, 'font'=>'helvetica', 'fontsize'=>20, 'stretchtext'=>4]}
{assign var=params value=TCPDF::serializeTCPDFtagParameters(array("{$order->id}", 'C128', '', '', '0', 40, 0.4, $stuff, 'N'))}
 

<tcpdf method="write1DBarcode" params="{$barcode_params}" />

 

This doesn't work in TB 1.1.x (from github). First it crashes at TCPDF::serializeTCPDFtagParameters but if I move the function call in the controller it still doesn't run write1DBarcode.

This is a critical feature, needed to print carrier labels.

How can I fix it?

Share this post


Link to post
Share on other sites
14 hours ago, Bruno said:

Hi guys,

I made a customisation in prestashop 1.6.15, in delivery-slip.tpl to write a barcode with order id: 

{assign var=black value=[0,0,0]}{assign var=white value=[255,255,255]}
{assign var=stuff value=['position'=>'S', 'border'=>false, 'padding'=>3, 'fgcolor'=>$black, 'bgcolor'=>$white, 'text'=>true, 'font'=>'helvetica', 'fontsize'=>20, 'stretchtext'=>4]}
{assign var=params value=TCPDF::serializeTCPDFtagParameters(array("{$order->id}", 'C128', '', '', '0', 40, 0.4, $stuff, 'N'))}
 

<tcpdf method="write1DBarcode" params="{$barcode_params}" />

 

This doesn't work in TB 1.1.x (from github). First it crashes at TCPDF::serializeTCPDFtagParameters but if I move the function call in the controller it still doesn't run write1DBarcode.

This is a critical feature, needed to print carrier labels.

How can I fix it?

 

Class TCPDF doesn't contain static method serializeTCPDFtagParameters, there is only an instance method with the same name. You will need to instantiate the TCPDF object and run the method on it, ie:

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$barcodeParams = TCPDF::serializeTCPDFtagParameters([$order->id, 'C128', '', '', '0', 40, 0.4, $stuff, 'N']);

 

Share this post


Link to post
Share on other sites

That was the first thing I did. Still, with $barcodeParams generated, this is not running: 

<tcpdf method="write1DBarcode" params="{$barcode_params}" />

Share this post


Link to post
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...