Jump to content

Edit History

feho1

feho1

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

feho1

feho1

I have the code in mymodule.php below
 

 $mail = (object)[
                "language" => $idLang, //  I take this from admin hook 
                "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

×
×
  • Create New...