Jump to content

Invoice PDF not in customers language


Recommended Posts

The invoice of an order is always in the language of the admin, not in the language the customer ordered in.

 

I had this problem since forever I started using prestashop, but I could always change the language in the admin quickly an get the right invoice language anyway.

 

I'm testing 1.4.5.1 before upgrading and noticed this is still the same. The invoice is not in the customers language.

 

Is there a fix for this, cannot find anything on this topic.

 

So if anyove orders in German, the invoice should be in German

 

I cannot print and send a dutch invoice to a German customer.

 

Please help.

Link to comment
Share on other sites

Do you have German translations for PDF invoice? If not the invoice will be in English even if customer's language is German.

 

All translations are in place. If I set my admin account to german, I get a german invoice.

If I set it to Dutch I get a dutch invoice and the sam for english.

 

The problem is I have to change the language in my admin account to get the invoice in the right language.

This is very time consuming if you have al lot of orders.

A second print invoice button to print in the customer language to send with the package would be ideal.

 

I'm suprised nobody has the same problem....

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 2 months later...
  • 2 years later...
  • 2 weeks later...

Local -> Translate -> PDF doesn't solve willemt's problem.

 

There is difference between the invoice created by the customer in Front Office and the administrator in Back Office.

I have the Version 1.6.0.6

 

I have the same problem.

Where in code i can change de pdf translation?

I will translate the EN for PT-PT.

 

Tks

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

Search for "lang" in /classes/pdf folder. It may quite challenging to do it reliably.

 

Anyway, the M4 PDF Extensions module has a switch under Orders - http://www.presta-addons.com/3-86/pdf-extensions.jpg

I don´t have that dir :o

I have try in the BO ( Translations > Pdf Translations ) change the vars of EN laguage fot PT,  becouse that the clients receive.

But after save, i dind´t receive more mails.

 

Do you know where i can find this file in code?

Tks

Link to comment
Share on other sites

Translations are the first part. When you have all texts translated PrestaShop uses translated text differently in Front Office and Back Office. In Back Office the invoice is always translated to admin's language.

Link to comment
Share on other sites

Translations are the first part. When you have all texts translated PrestaShop uses translated text differently in Front Office and Back Office. In Back Office the invoice is always translated to admin's language.

Ok tks.

I change the admin lang and is working now!

 

Tks  :)

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

  • 1 year later...

If anybody needs orders in only one language, different from admin`s, it helped for me:

protected function getTemplate($template_name)
{
$template = false;
$default_template = _PS_PDF_DIR_.'/'.$template_name.'.tpl';
$overriden_template = _PS_THEME_DIR_.'pdf/'.$template_name.'.tpl';
if (file_exists($overriden_template))
$template = $overriden_template;
else if (file_exists($default_template))
$template = $default_template;

// SELECT ORDER LANGUAGE FOR THE TEMPLATE
if ( $this->order )
Context::getContext()->language = new Language($this->order->id_lang);

return $template;
}

In this line:

Context::getContext()->language = new Language($this->order->id_lang);

Changed 

$this->order->id_lang

to my language ID (My needed language was 2, so changed for 2) and my invoices become in one language.

Context::getContext()->language = new Language(2);
Edited by Mr.SerikuS (see edit history)
Link to comment
Share on other sites

  • 2 months later...

My post

 

classes/pdf/PDF.php

 

But product names still in admin lang. I will think lates. Happy New Year :3

 

Product names are always in customer's language, because they are stored in the ps_orders table just in one language.

 

It is possible to retrieve the names from Products, in every language. It is a popular method in bi-language invoices (like Chinese-English).

Link to comment
Share on other sites

  • 4 years later...

For PS 1.7.7 in classes/pdf/HTMLTemplate.php footer can be translated in line 71, that is setting the line to:

            'free_text' => Configuration::get('PS_INVOICE_FREE_TEXT', (int) Context::getContext()->language->id, null, $this->order->id_lang),

However the suggested solution does not seem to work for template. In PS 1.7.7 the code is little different:

    protected function getTemplate($template_name)
    {
        $template = false;
        $default_template = rtrim(_PS_PDF_DIR_, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $template_name . '.tpl';
        $overridden_template = _PS_ALL_THEMES_DIR_ . $this->shop->theme->getName() . DIRECTORY_SEPARATOR . 'pdf' . DIRECTORY_SEPARATOR . $template_name . '.tpl';
        if (file_exists($overridden_template)) {
            $template = $overridden_template;
        } elseif (file_exists($default_template)) {
            $template = $default_template;
        }
        return $template;
    }

 

By adding code

if ( $this->order )

Context::getContext()->language = new Language($this->order->id_lang);

into the function does not result correct translation.  How to adjust this correctly for keeping the pdf files always in order language?

Link to comment
Share on other sites

  • 10 months later...

I solved this in PS 1.7 by modifying (creating an override) for /classes/pdf/HTMLTemplateInvoice.php, changing the __construct function to:

public function __construct(OrderInvoice $order_invoice, Smarty $smarty, $bulk_mode = false)
    {
        $this->order_invoice = $order_invoice;
        $this->order = new Order((int) $this->order_invoice->id_order);
        $this->smarty = $smarty;
        $this->smarty->assign('isTaxEnabled', (bool) Configuration::get('PS_TAX'));

        // If shop_address is null, then update it with current one.
        // But no DB save required here to avoid massive updates for bulk PDF generation case.
        // (DB: bug fixed in 1.6.1.1 with upgrade SQL script to avoid null shop_address in old orderInvoices)
        if (!isset($this->order_invoice->shop_address) || !$this->order_invoice->shop_address) {
            $this->order_invoice->shop_address = OrderInvoice::getCurrentFormattedShopAddress((int) $this->order->id_shop);
            if (!$bulk_mode) {
                OrderInvoice::fixAllShopAddresses();
            }
        }

        // header informations
        $this->date = Tools::displayDate($order_invoice->date_add);

        // switch language to order language
        Context::getContext()->language = new Language($this->order->id_lang);

        $id_lang = Context::getContext()->language->id;
        $id_shop = Context::getContext()->shop->id;
        $this->title = $order_invoice->getInvoiceNumberFormatted($id_lang, $id_shop);

        $this->shop = new Shop((int) $this->order->id_shop);
    }

 

  • Like 1
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...