Check the complete article in Linkedin
Challenge
The PrestaShop Order detail page has a button to download Invoice Pdf.
But the customer wanted to add a button that downloads Delivery/ Printable Voucher PDF.
Solution
The solutions was to create a new controller called “PdfDeliveryController” and render the PDF in Order Detail page.
Check the code of the new “PdfDeliveryController:
“PdfDeliveryController” code:
class PdfDeliveryControllerCore extends FrontController { public $php_self = 'pdf-delivery'; protected $display_header = false; protected $display_footer = false; public $content_only = true; protected $template; public $filename; public function postProcess() { if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key')) { Tools::redirect('index.php?controller=authentication&back=pdf-delivery'); } $id_order = (int) Tools::getValue('id_order'); if (Validate::isUnsignedId($id_order)) { $order = new Order((int) $id_order); } $this->order = $order; } public function display() { $order_delivery_list = $this->order->getDeliverySlipsCollection(); $pdf = new PDF($order_delivery_list, PDF::TEMPLATE_DELIVERY_SLIP, $this->context->smarty); $pdf->render(); } }
Printable Voucher Download displayed in Order Details page

