| Hook | actionGetPdfTemplateObject |
|---|---|
| Locations | BO |
| Type | action |
| Origin | core |
| Aliases | |
| Description | This hook allows modules to override the default PDF template object used for generating PDFs like invoices, delivery slips, and order returns. |
This hook has an $array_return parameter set to true (module output will be set by name in an array, see explaination here).
| Origin | File |
|---|---|
| core | classes/pdf/PDF.php |
[
'object' => $object, // The source object (Order, OrderReturn, etc.)
'smarty' => $smarty, // Smarty template engine instance
'send_bulk_flag' => $send_bulk_flag, // Boolean indicating bulk PDF generation
'template' => $template, // Template type string (e.g., 'Invoice', 'OrderReturn')
]
Return an HTMLTemplate instance to override the default template, or false to use the default behavior.
$templateObjects = Hook::exec(
'actionGetPdfTemplateObject',
[
'object' => $object,
'smarty' => $smarty,
'send_bulk_flag' => $send_bulk_flag,
'template' => $template,
],
null,
true
);
public function hookActionGetPdfTemplateObject($params)
{
// Only handle invoices
if ($params['template'] !== 'Invoice') {
return false;
}
// Return a custom template object
return new MyCustomInvoiceTemplate(
$params['object'],
$params['smarty'],
$params['send_bulk_flag']
);
}