Jump to content

Prestashop 1.7 : Argument 1 passed to PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision::getPrecision()


Recommended Posts

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;
    }

 

Edited by MOUAZZAZ Zineb (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...