Jump to content

Module - Mail subject translation problem


Recommended Posts

I have the code in mymodule.php below
 

 $mail = (object)[
                "language" => $idLang, //  I get this from result from database  
                "template" => 'template',
                "product_link" => $product_link,
                "subject" => "$product_name {$this->l('IS BACK')}",
                "to" => $to
                "to_name" => $name,
                "from" => Configuration::get('the_email'),
                "from_name" => Configuration::get('the_from_email'),
            ];

            $tempVals = [
                '{shop_base_url}' => $base_dir,
                '{email}' => $mail->to,
                '{fullname}' => $mail->to_name,
                '{product_name}' => $product_name,
                '{product_link}' => $mail->product_link,
                '{image_link}' => $product_image ?? "",
                '{shop_name}' => $mail->from_name,
                '{base_dir}' => $base_dir,
                '{shop_email}' => Configuration::get('PS_SHOP_EMAIL'),
            ];

            Mail::Send(
                $mail->language,
                $mail->template,
                $mail->subject,
                $tempVals,
                $mail->to, $mail->to_name, $mail->from, $mail->from_name, NULL, NULL,
                _PS_MODULE_DIR_ . 'mymodule/mails/');

However when the email get send.
The subject takes always the back office language not the one that is passed in the code. I checked the $langId changes from 1 to 2 and the template changes the language but the subject always stays the same language as back office.
Also in the email translation it says "No Subject was found for template in the database."
I tried with Mail::l but then the translation wouldnt show up anywhere.
Any help?
Prestashop 1.7.6.7

Edited by feho1 (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...