Max Clee Posted April 25, 2021 Share Posted April 25, 2021 Hello I use Prestashop 1.7.6 I would like extend variables in e-mail templates gender invoice number because exist global variable for {$customer.gender.name[$customer.gender.id]} Client Gender (example: Ms, Mr, etc.) I trying to add gender to file to classes/PaymentModule.php and email template in diverse form but without success (code below ) but what is with Invoice Number ? i look forward to your help // Send an e-mail to customer (one order = one email) if ($id_order_state != Configuration::get('PS_OS_ERROR') && $id_order_state != Configuration::get('PS_OS_CANCELED') && $this->context->customer->id) { $invoice = new Address((int) $order->id_address_invoice); $delivery = new Address((int) $order->id_address_delivery); $delivery_state = $delivery->id_state ? new State((int) $delivery->id_state) : false; $invoice_state = $invoice->id_state ? new State((int) $invoice->id_state) : false; $data = array( '{gender}' => $this->context->customer->gender, '{firstname}' => $this->context->customer->firstname, '{lastname}' => $this->context->customer->lastname, Link to comment Share on other sites More sharing options...
cavipres Posted April 26, 2021 Share Posted April 26, 2021 Think you should dig in to the email template file. Have a look at root(public_html?)/mails/en/ where /en can differ as be your selected language Link to comment Share on other sites More sharing options...
heyho Posted September 5, 2021 Share Posted September 5, 2021 Create a Module and add the Hook "sendMailAlterTemplateVars": Here you can add variables to all E-Mail-Templates like this: /* * $this->registerHook('sendMailAlterTemplateVars'); */ /** * @param $param * @return string */ public function hooksendMailAlterTemplateVars($params) { $context = Context::getContext(); if ($params['template'] == 'order_conf') { $reference = $params['template_vars']['{order_name}']; $sql = 'SELECT * FROM '._DB_PREFIX_.'orders WHERE reference = "'.$reference.'" Limit 1 '; $orderRow = Db::getInstance()->executeS($sql); if (!empty($orderRow)) { $id_order = reset($orderRow)['id_order']; $order = new Order ($id_order ); $params['template_vars']['{firstmessage}'] = "<strong>Nachricht</strong><br>".trim($order->getFirstMessage())?:''; $params['template_vars']['{id_order}'] = $id_order ; $id_customer = reset($orderRow)['id_customer']; $customer = new Customer ($id_customer ); $gender = new Gender ($customer->id_gender ); $params['template_vars']['{genderByLang}'] = $gender->name[$context->language->id]?:""; /* * Custom Text only on specific paymenttype * $order->module == "stripe_official" **/ if($order->module == "ps_wirepayment") { $params['template_vars']['{wirepaymentSpecialText}'] = "<p>Some Information about payment...</p>"; } } } if ($params['template'] == 'bankwire') { // do something... } } In your Mail-Template: {id_order}<br> {genderByLang}<br> <div> {firstmessage} </div> {wirepaymentSpecialText} Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now