Jump to content

How to set the invoice language to always be English


Sickboards

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?

Link to comment
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
Link to comment
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.

Link to comment
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.  

Link to comment
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.

Link to comment
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).

Link to comment
Share on other sites

  • 2 years later...

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.

Link to comment
Share on other sites

  • 3 months later...

@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)
Link to comment
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.

Link to comment
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)
Link to comment
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 ;)

Link to comment
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.

Link to comment
Share on other sites

  • 1 year later...

Hello Holle 75, i have same issues, Prest 1.7.6 crazy to see how Prestashop can get bugged as soon as you get more and more into it. I tend more and more to believe that they do it to oblige us to buy the half done modules that populate their addons....

On my side i just would like to send invoice with email (payment accepted) in the customer's language... In my case, the invoice sent by email is always in the shop language, not customer's language... Completely stupid !... 🥴

Wandering around the forum and NO SOLUTION (except like everytime, the 100euros ones) !  

If u have any clues since your last post, please tell me 

Thx mate

Link to comment
Share on other sites

14 hours ago, superskyman100 said:

Hello Holle 75, i have same issues, Prest 1.7.6 crazy to see how Prestashop can get bugged as soon as you get more and more into it. I tend more and more to believe that they do it to oblige us to buy the half done modules that populate their addons....

On my side i just would like to send invoice with email (payment accepted) in the customer's language... In my case, the invoice sent by email is always in the shop language, not customer's language... Completely stupid !... 🥴

Wandering around the forum and NO SOLUTION (except like everytime, the 100euros ones) !  

If u have any clues since your last post, please tell me 

Thx mate

Sorry Mate, kind of abandoned Presta. The shop is up and running, but the next little spare time i have will be used to switch to another shopsystem. Presta is rotten at it´s core.

Haven´t found a solution for the invoice thing (besides other minor annoyances)

best

H.

Link to comment
Share on other sites

  • 5 months later...
On 3/16/2020 at 5:29 PM, superskyman100 said:

...

On my side i just would like to send invoice with email (payment accepted) in the customer's language... In my case, the invoice sent by email is always in the shop language, not customer's language... Completely stupid !... 🥴

...

Hello :)

Just fount this thread cause having the same problems.

Just recognized: as soon as the payment is registered as done in your BO, the incoice that the cutomer can see if he is registered is in his language. Kind of misleading if one is not sure if he/she (customer) does get it in what they understand! :(

Link to comment
Share on other sites

21 hours ago, Jean Gangolf said:

Hello :)

Just fount this thread cause having the same problems.

Just recognized: as soon as the payment is registered as done in your BO, the incoice that the cutomer can see if he is registered is in his language. Kind of misleading if one is not sure if he/she (customer) does get it in what they understand! :(

You'll have same problem with customer contact formular, PS doesn't gives back answers in the customer's language but in BO language... Lots of mis-functional stuff that cost hours and hours to figure out how to fix. I had to buy service(s) to fix plenty of little stuff like that, there is no way out if you are not programmer.

Link to comment
Share on other sites

Hello superskyman100

Thanks for your reply! :) Even if you have bad news...

I am not a programmer, but since we (my son and me) are starting to set up a shop for him (son) we are about to learn every day a bit more of doing "handicraft" to make things work... But i have to admit that we started about mid april, and still it is not as we want to have it! :o

Hope ypour's is working :)

Kind regards :)

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