paranoiac Posted September 22, 2010 Share Posted September 22, 2010 Hi,I'm trying to make my prestatshop to send a different email template, for example no shipping prices included, for a special user group. Because I will need to manage this customer's shipping cost manually and send a another shipping cost email.Please advise if this is possible or I need a custom module.Regards Link to comment Share on other sites More sharing options...
klubas Posted October 18, 2010 Share Posted October 18, 2010 I need this solution to. Please help. Link to comment Share on other sites More sharing options...
klubas Posted October 21, 2010 Share Posted October 21, 2010 no solution? can we make with {if $trade} in email templates? like in this post Link to comment Share on other sites More sharing options...
rocky Posted October 22, 2010 Share Posted October 22, 2010 No, you can't use Smarty code in mail templates. The only thing I can think of is to create a {shipping} variable that contains the shipping information for one customer group and is a blank variable for the other customer group. Link to comment Share on other sites More sharing options...
klubas Posted October 22, 2010 Share Posted October 22, 2010 My situation is a little bit different from "paranoiac" mentioned in first message.I have two groups and i need to send different Design emails (order_conf) after order complete.Maybe in PaymentModule.php we can change below "'// Send an e-mail to customer"" , then we can have two templates for different groups? Link to comment Share on other sites More sharing options...
rocky Posted October 22, 2010 Share Posted October 22, 2010 Yes, that would work. Create two separate mail templates order_conf1 and order_conf2 and add the following to classes/PaymentModule.php after line 83 (in PrestaShop v1.3.2): $customer = new Customer(intval($cart->id_customer)); then change line 376 from: Mail::Send(intval($order->id_lang), 'order_conf', 'Order confirmation', $data, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, $fileAttachment); to: Mail::Send(intval($order->id_lang), 'order_conf' . $customer->id_default_group, 'Order confirmation', $data, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, $fileAttachment); Link to comment Share on other sites More sharing options...
paranoiac Posted October 22, 2010 Author Share Posted October 22, 2010 No, you can't use Smarty code in mail templates. The only thing I can think of is to create a {shipping} variable that contains the shipping information for one customer group and is a blank variable for the other customer group. Would you please give me an example? like which file(s) I need to edit etc..Thanks in advance, rocky. Link to comment Share on other sites More sharing options...
klubas Posted October 22, 2010 Share Posted October 22, 2010 Thank you Rocky! This is exactly what I needed Link to comment Share on other sites More sharing options...
rocky Posted October 23, 2010 Share Posted October 23, 2010 Like above, add the following to classes/PaymentModule.php after line 83 (in PrestaShop v1.3.2): $customer = new Customer(intval($cart->id_customer)); then add the following before the $data array on line 324: $shipping = ' Shipping ' . Tools::displayPrice($order->total_shipping, $currency, false, false) . ' '; if (intval($customer->id_default_group) == 2) $shipping = ''; then in the $data array, change: '{total_shipping}' => Tools::displayPrice($order->total_shipping, $currency, false, false), to: '{shipping}' => $shipping, Then you can use {shipping} in order_conf.html and it will display the shipping total unless the customer is in group 2. Link to comment Share on other sites More sharing options...
paranoiac Posted October 27, 2010 Author Share Posted October 27, 2010 I really appreciate your response, rocky.I will give it a try and post a result. Link to comment Share on other sites More sharing options...
paranoiac Posted November 5, 2010 Author Share Posted November 5, 2010 Sorry for late response, I updated this thread to solved.Even though there is a slight html modification to make it perfect due to my personal preference. To rocky,Thank you very much once again.In addition, the {total_paid} , the biggest sum, still use the hidden {shipping} (if it is >= 1) to calculate.I thought we have put an empty string to it when the customer group is 2.Please advise. Link to comment Share on other sites More sharing options...
rocky Posted November 5, 2010 Share Posted November 5, 2010 I guess you will have to manually remove the shipping from the total_paid value: '{total_paid}' => Tools::displayPrice($order->total_paid - $order->total_shipping, $currency, false, false), Link to comment Share on other sites More sharing options...
adamus007p Posted January 14, 2011 Share Posted January 14, 2011 I am searching solution for different emails for different products.Please help Link to comment Share on other sites More sharing options...
Michele Cesaretti Posted July 20, 2020 Share Posted July 20, 2020 Hi, there is a similar solution for 1.6? Thanks in advance. Link to comment Share on other sites More sharing options...
PrestaServicePro Posted July 20, 2020 Share Posted July 20, 2020 Can you explain exactly what do you want? Link to comment Share on other sites More sharing options...
Michele Cesaretti Posted July 21, 2020 Share Posted July 21, 2020 Hi, thanks for reply. There is a solution to send different email to user from different customer groups? Link to comment Share on other sites More sharing options...
PrestaServicePro Posted July 21, 2020 Share Posted July 21, 2020 In this thread it has been explained for older version, but if you are using 1.6 current solutions must be work in your shop. Link to comment Share on other sites More sharing options...
heyho Posted September 7, 2021 Share Posted September 7, 2021 (edited) 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 Edited September 7, 2021 by heyho (see edit history) 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