Jump to content
Sickboards

How to set the invoice language to always be English

Recommended Posts

Hello

 

I am running Prestashop 1.6.1.4 and I have 10 languages installed, 

The issue I am now facing is if someone orders in for instance Spanish, we will have to translate the invoice back to Dutch or English to be able to see which (for instance) color options the person has chosen.

 

Is there a way that when a customer makes an order in Spanish, the invoice will be in a specific (shop default) language?

Share this post


Link to post
Share on other sites

Thanks but I can only find some folders that hold an ru.php (some modules and the filemanager), 

which folder are you referring to?

There are some gzip files in the root\translation folder but I guess they are not being used?

 

ps love your triple edit module :) 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks but I can only find some folders that hold an ru.php (some modules and the filemanager), 

which folder are you referring to?

 

As far as I can see the translations for your pdf's are stored in \themes\yourtheme\pdf\lang\ru.php. With instead of ru.php also other languages.

 

But as I suppose that these language files may also contain translations for pdf's that you do want to keep it might be better not to delete them.

 

In the face of that shared translations problem (that other pdf's contain the same string) you could also choose to adapt the form in \pdf\invoice.tpl. If you make tiny changes in the strings they are no longer recognized for the translations.

Share this post


Link to post
Share on other sites

Hi,

 

I think it is more complex,

The folder \themes\yourtheme\pdf\lang only contains an index file.

The invoice.tpl and invoice.product-tab.tpl only contain translation for the tabel heading not for the products, they are pulled from the database as stored.

So basically I need to make sure that when the order is made the ps_order_detail contains the English/default descriptions not the translated ones.  

Share this post


Link to post
Share on other sites

The folder \themes\yourtheme\pdf\lang only contains an index file.

Then the default translations from under the main directory \translations are used.

 

The invoice.tpl and invoice.product-tab.tpl only contain translation for the tabel heading not for the products, they are pulled from the database as stored.

So basically I need to make sure that when the order is made the ps_order_detail contains the English/default descriptions not the translated ones.  

Good point. Invoice.tpl is called from the file \classes\pdf\HTMLTemplateInvoice.php. For getting the products that file call the function order_invoice::getProducts() that can be found in the file \classes\Order\OrderInvoice.php, that calls Product::getAllCustomizedDatas() in classes\Product.php where the actual query is done.

 

You could do some experiments with those files. Near the top of HTMLTemplateInvoice.php is a line

$id_lang = Context::getContext()->language->id;

Maybe changing that to an assignment of the id for English will be enough. Maybe you should also change the context language.

Share this post


Link to post
Share on other sites

Is there a way that when a customer makes an order in Spanish, the invoice will be in a specific (shop default) language?

 

Yes, there are patches around as well as modules. Just note that the product name and all combinations are stored in customer's language so it doesn't help to change the language of the invoice.

 

You also need to show the real product name from the ps_product table, not only from ps_order_detail table.

 

I have already solved it using the M4 PDF Extensions module where you can easily show the product name in several languages at once (for example English and Chinese).

Share this post


Link to post
Share on other sites

I had the same issue on PS 1.7.3. 

I just added two overrides:

class AdminPdfController extends AdminPdfControllerCore
{
    public function postProcess()
    {
        if (Context::getContext()->employee != null) {
            if (Tools::getIsset('id_order')) {
                $order = new Order(Tools::getValue('id_order'));
            }

            if (Tools::getIsset('id_order_invoice')) {
                $orderInvoice = new OrderInvoice(Tools::getValue('id_order_invoice'));
                $order = $orderInvoice->getOrder();
            }

            if ($order->id) {
                Context::getContext()->language = new Language($order->id_lang);
                Context::getContext()->shop = new Shop($order->id_shop);
                Context::getContext()->setTranslatorFromLocale(Context::getContext()->language->locale);
            }
        }

        parent::postProcess();
    }
}

and

class Context extends ContextCore
{
    public function setTranslatorFromLocale($locale)
    {
        $translator = $this->getTranslatorFromLocale($locale);
        // In case we have at least 1 translated message, we return the current translator.
        if (count($translator->getCatalogue($locale)->all())) {
            $this->translator = $translator;
        }

        $this->translator = $translator;
    }
}

Hope it will help somebody. It works perfectly for me, but it is not the best solution.

Share this post


Link to post
Share on other sites

@denysbezu could you elaborate how you made those changes exactly? ... and what they´re doing? Wouldn´t it be easier to find the place where Presta is taking the language information from the Admin from and inject a variable or fixed language? Or maybe thats what your overrides are doing and i just don´t understand them? Where do you define the fixed language?

 

I´m on Presta 1.7.5.1 and just figured out that for all invoices (customer and BO) ALWAYS (edit: i have to correct me -> attached invoice to payment accepted emails. FO if user is logged in works fine) to  the language of the Admin is used. How Awkward.

 

Edited by holle75 (see edit history)

Share this post


Link to post
Share on other sites
On 2/23/2019 at 7:42 PM, holle75 said:

I´m on Presta 1.7.5.1 and just figured out that for all invoices (customer and BO) ALWAYS (edit: i have to correct me -> attached invoice to payment accepted emails. FO if user is logged in works fine) to  the language of the Admin is used. How Awkward. 

 

 

PrestaShop works this way from version 1.0.

Share this post


Link to post
Share on other sites

Thanks Tuk66. Could you tell me if just i´m crazy about it? i mean this is simply not logical, right?

Share this post


Link to post
Share on other sites

Why? It is logical. The customer gets the invoice in her language and you get it in your languge (one for all invoices).

Share this post


Link to post
Share on other sites

For example you have a Shop in the netherlands but your BO is set to english (because Admin is living in the UK?).

-> Dutch Customer gets invoice attached to "payment accepted"- eMail in english.

-> BO invoices are in english for a dutch shop. You might get a problem with the Dutch taxoffice.

seems not logic to me ....

Edited by holle75 (see edit history)

Share this post


Link to post
Share on other sites

OK. Everyone wants it differently. That's why the M4 PDF Extensions module can print invoices in every language you choose (in the Back Office).

Share this post


Link to post
Share on other sites

Yes, you created an awesome Module .... but it´s hard to convince yourself to pay 99,- for a needed core functionality.

But thank you anyways for elaborate on this subject. First i thought it´s a bug.

Share this post


Link to post
Share on other sites

For others:

I tried this idea from denysbezu

https://www.prestashop.com/forums/topic/524070-how-to-set-the-invoice-language-to-always-be-english/?tab=comments#comment-2997118

What it does: when downloading Invoices in BO, they are generated in the language the customer used for the order. But still attached invoice to payment-accepted-eMail is in BO language.

If anyone finds a solution for the payment-accepted-eMail-Problem .... heres the place to elaborate ;)

Share this post


Link to post
Share on other sites
Posted (edited)

in /pdf/ folder  edit all tpl files.... remove transalations syntac use only english text. 

 

example if u found {l s='text' d='trans-location'} make it to  ->       text

thrive

 

 

 

Edited by thrive (see edit history)

Share this post


Link to post
Share on other sites

Yes thrive, that´s a way, thank you for writing your thoughts  .....  but then also customer invoices are only in english. It´s crazy that you have to fiddle around for such a core functionality. If you use a multilanguage shop, the shop should offer necessary settings for multilanguage!

I simply want Presta to behave in a logic/configurable way. i opened an Issue here -> https://github.com/PrestaShop/PrestaShop/issues/12686

which follows to -> https://github.com/PrestaShop/PrestaShop/issues/10258

 

what bothers me the most is the attached invoice to "payment-accepted-mail" in Admin language.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More