Jump to content

Add the invoice number (formatted) in the credit slip


Recommended Posts

  • 1 year later...
  • 1 year later...

If this can help my solution, I sure it's no perfect but work for me.

Prestashop 8.1.

In the file \classes\pdf\HTMLTemplateOrderSlip.php about the line 168 into the function "public function getContent()" add the below

        $format = '%1$s%2$06d';

        if (Configuration::get('PS_INVOICE_USE_YEAR')) {
            $format = Configuration::get('PS_INVOICE_YEAR_POS') ? '%1$s/%3$s%2$06d' : '%1$s%2$06d/%3$s';
            /* %1$s -->prefix 'LV'
             * %3$s -->year
             * %2$06d --> invoice
             */
        }   
        $prefix = Configuration::get('PS_INVOICE_PREFIX', Context::getContext()->language->id);
        $order_invoice = sprintf(HTMLTemplateOrderSlip::l($format), $prefix, (int) $this->order->invoice_number, date('y', strtotime($this->order->date_add)));

After you need add the $order_invoice variable to smarty (same file about line 181)

        $this->smarty->assign([
            'order' => $this->order,
            'order_slip' => $this->order_slip,
            'order_details' => $order_details,
            'cart_rules' => $this->order_slip->order_slip_type == 1 ? $this->order->getCartRules() : false,
            'amount_choosen' => $this->order_slip->order_slip_type == 2 ? true : false,
            'delivery_address' => $formatted_delivery_address,
            'invoice_address' => $formatted_invoice_address,
            'addresses' => ['invoice' => $invoice_address, 'delivery' => $delivery_address],
            'tax_excluded_display' => $tax_excluded_display,
            'total_cart_rule' => $total_cart_rule,
            'order_invoice' => $order_invoice,
        ]);

With this you can call to the variable "$order_invoice" in the order-slip tpl's where you need. My example added to order-slip.summary-tab.tpl:

<td class="center small white">{$order_invoice|escape:'html':'UTF-8'}</td>

Regards

Raul

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...