Hi,
As the title of the topic, I would like to save the PDF invoices automatically when order is complete.
I overrided the 2 PDF classes :
<?php
class PDF extends PDFCore
{
public function render($display = true)
{
if($this->template == PDF::TEMPLATE_INVOICE)
parent::render('F', true); //This renders to automatic save
return parent::render($display);
}
}
?>
and PDFGenerator
class PDFGenerator extends PDFGeneratorCore
{
public function render($filename, $display = true)
{
if (empty($filename)) {
throw new PrestaShopException('Missing filename.');
}
$this->lastPage();
if ($display === true) {
$output = 'D';
} elseif ($display === false) {
$output = 'S';
} elseif ($display == 'D') {
$output = 'D';
} elseif ($display == 'S') {
$output = 'S';
} elseif ($display == 'F') {
$output = 'F';
$filename = _PS_ROOT_DIR_.'/Compta/tva-new/invoices/'.$filename;
} else {
$output = 'I';
}
return $this->output($filename, $output);
}
Then : the files are saved in the folder, but if a customer (or from admin) wants to download his invoice, the file is blank.
So how it's possible to have both : invoices downloadable from admin or frontend AND automatically saved in the folder.
Many thanks in advance.