V8x How to insert barcode on the delivery slip

mymate20

Well-known member
Master
Diamond
Elite
XNullUser
Joined
Jan 9, 2021
Messages
226
Reaction score
858
Points
93
NullCash
1,910
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?

{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}" />
 

Ponas

Well-known member
Diamond
Elite
XNullUser
Joined
Jan 17, 2022
Messages
1,386
Reaction score
130
Points
63
NullCash
2
image

$barcodeobj = new TCPDFBarcode($order->order_barcode, 'C128');
$barcode = base64_encode($barcodeobj->getBarcodePNG(1, 30, array(255,255,255)));
$content = file_get_contents(_PS_ROOT_DIR_.'/your_img_barcode_folder/'.$barcode.'.png');

or pdf:

$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));
 
Last edited:
Top