Prestashop 1.7.7
To use different E-Mail Templates by Group, Carrier, User, or what ever:
Use the Hook sendMailAlterTemplateVars in your Module...
Dont forget to create the templates in /themes/xxxx/mails/xx/order_confsomethingother.html
$this->registerHook('actionEmailSendBefore');
public function hookActionEmailSendBefore(&$params) { if($params["template"] == "order_conf") { # or bankwire or ,..... $reference = $params['templateVars']['{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); if($order->id_carrier == "36") { $params['template'] = "order_confsomethingother"; } /* For User Groups you can use something like this: $customer = new Customer ($order->id_customer); if($customer->id_group == "36") { $params['template'] = "order_confsomethingother2222"; } */ } # do something more... if (is_array($params['bcc'])) { $params['bcc'][] = "[email protected]"; } else { $params['bcc'] = ["[email protected]"]; } } }
If you want to add variables, use: sendMailAlterTemplateVars