Jump to content

Edit History

MOUAZZAZ Zineb

MOUAZZAZ Zineb

Hello, I am coding a module to send a PDF invoice of a purchase on Google Drive. 
However, when I want to create a PDF, it sends me this error (it always comes up when I want to make the render):

context.thumb.png.0d798dc80c9f872dfbbcdb74fb4d14eb.png

I specify that it worked on version 1.6 of Prestashop but when I made the update to 1.7 I found myself with this problem.
 

Here is my code

public function saveInvoiceToDrive(int $id_order)
    {
        $context = Context::getContext();
        $result = false;

        $order = new Order($id_order);
        $invoice_collection = $order->getInvoicesCollection();

        // Retrieves the name of the invoice

        /** @var OrderInvoice $invoice */
        foreach ($invoice_collection as $invoice) {
            $file_name = $invoice->getInvoiceFilename($id_order);
            $filename = $file_name['invoice'];
            $nameInvoice = $filename['name'];
            $order_file = _PS_MODULE_DIR_ . $this->name . '/invoices/files/' . $nameInvoice;

            // Create the invoice in pdf
            $pdf = new PDF($invoice, PDF::TEMPLATE_INVOICE, $this->context->smarty);
            $invoice_content = $pdf->render(false);

            // Save the invoice as a pdf file in the desired folder
            file_put_contents($order_file, $invoice_content);

            // Send to drive
            if (is_file($order_file)) {
                $result = $this->toGoogleDrive($order_file, 'pdf');
            }
        }
        return $result;
    }

 

MOUAZZAZ Zineb

MOUAZZAZ Zineb

Hello, I am coding a module to send a PDF invoice of a purchase on Google Drive. 
However, when I want to create a PDF, it sends me this error (it always comes up when I want to make the render):

context.thumb.png.0d798dc80c9f872dfbbcdb74fb4d14eb.png

 

I specify that it worked on version 1.6 of Prestashop but when I made the update to 1.7 I found myself with this problem.
 

Here is my code

public function saveInvoiceToDrive(int $id_order)
    {
        $context = Context::getContext();
        $result = false;

        $order = new Order($id_order);
        $invoice_collection = $order->getInvoicesCollection();

        // Retrieves the name of the invoice

        /** @var OrderInvoice $invoice */
        foreach ($invoice_collection as $invoice) {
            $file_name = $invoice->getInvoiceFilename($id_order);
            $filename = $file_name['invoice'];
            $nameInvoice = $filename['name'];
            $order_file = _PS_MODULE_DIR_ . $this->name . '/invoices/files/' . $nameInvoice;

            // Create the invoice in pdf
            $pdf = new PDF($invoice, PDF::TEMPLATE_INVOICE, $this->context->smarty);
            $invoice_content = $pdf->render(false);

            // Save the invoice as a pdf file in the desired folder
            file_put_contents($order_file, $invoice_content);

            // Send to drive
            if (is_file($order_file)) {
                $result = $this->toGoogleDrive($order_file, 'pdf');
            }
        }
        return $result;
    }

 

×
×
  • Create New...