diff --git a/admin-dev/pdf.php b/admin-dev/pdf.php index a8908b3a8..28688a1db 100644 --- a/admin-dev/pdf.php +++ b/admin-dev/pdf.php @@ -81,7 +81,9 @@ function generateInvoicePDFByIdOrder($id_order) if (!Validate::isLoadedObject($order)) die(Tools::displayError('Cannot find order in database')); - generatePDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE); + $order_invoice_list = $order->getInvoicesCollection(); + Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list)); + generatePDF($order_invoice_list, PDF::TEMPLATE_INVOICE); } function generateInvoicePDFByIdOrderInvoice($id_order_invoice) @@ -90,6 +92,7 @@ function generateInvoicePDFByIdOrderInvoice($id_order_invoice) if (!Validate::isLoadedObject($order_invoice)) die(Tools::displayError('Cannot find order invoice in database')); + Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => array($order_invoice))); generatePDF($order_invoice, PDF::TEMPLATE_INVOICE); } diff --git a/classes/pdf/PDF.php b/classes/pdf/PDF.php index e86d5da5d..115152731 100755 --- a/classes/pdf/PDF.php +++ b/classes/pdf/PDF.php @@ -48,7 +48,7 @@ class PDFCore $this->smarty = $smarty; $this->objects = $objects; - if (!is_array($objects)) + if (!($objects instanceof Iterator)) $this->objects = array($objects); } diff --git a/controllers/front/PdfInvoiceController.php b/controllers/front/PdfInvoiceController.php index 84cd9028f..ecf09836a 100644 --- a/controllers/front/PdfInvoiceController.php +++ b/controllers/front/PdfInvoiceController.php @@ -66,8 +66,11 @@ class PdfInvoiceControllerCore extends FrontController } public function display() - { - $pdf = new PDF($this->order, PDF::TEMPLATE_INVOICE, $this->context->smarty, $this->context->language->id); + { + $order_invoice_list = $this->order->getInvoicesCollection(); + Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list)); + + $pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty, $this->context->language->id); $pdf->render(); }