Benoit.ndr Posted October 22, 2015 Share Posted October 22, 2015 Hey there. I'm opening this subject cause i have two questions : 1) I'd like to know why the fiels available in templates mails are in OrderHistory.php and not in a file who's closer like order states or payment modules 2)When an user is paying with bankwire, prestashop'll send 2 mails : 1 with my bank informations (bankwire.html) and 1 with the products list he ordered (order_conf.html). But, i'd like to do only 1 mail with those 2 (my bank informations + order recap) So, modifying PaymentModule.php, I succeed to block the sending of order_conf.html mail when bankwire payment is chosen. Now I'm changing the bankwire.html template trying to add the order_conf.html fields in it ( not easy, some fields are not recognized, i think that's because they're not declared in the same class ) My move is pretty bad no ?! Is that an easier way to do that ? Thanks a lot, best regards PS : Sorry for my bad english guys Link to comment Share on other sites More sharing options...
innovacy Posted October 22, 2015 Share Posted October 22, 2015 1) eeeeeeeh... 2) You could, if you extended the bankwire module to create this list too, edit the email to contain the additional order_conf and submit these details through validateOrder() ... wait, that's too much work... If you have only bankwire, add the details in the order_conf literally, much simpler, but more limited. Btw, you are doing it on the wrong places. Don't edit the core files, you have to edit the payment controller of the bankwire module. Link to comment Share on other sites More sharing options...
Benoit.ndr Posted October 22, 2015 Author Share Posted October 22, 2015 Hey, thanks for your answer You could, if you extended the bankwire module You mean overriding the module ? I was thinking this is possible only with tpl, css and js files ?! If you have only bankwire, add the details in the order_conf literally, much simpler, but more limited. We have payment by credit cards too, and maybe more later.. The problem is, the order_conf mail is sent with many states and i'd like to change only the bankwire template mail for now Don't edit the core files I'm working in override/classes/order/OrderHistory.php to don't edit the core files you have to edit the payment controller of the bankwire module. Yeah, at first I was thinking about changing the module bankwire files, but there is no fields like : $data = array( '{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int)$this->id_order, ...... So you're saying I have to modify payment.php ( modules\bankwire\controllers\front ) ? Thanks for you help, sorry i'm just a presta newbie Link to comment Share on other sites More sharing options...
innovacy Posted October 23, 2015 Share Posted October 23, 2015 (edited) Well yes, the $data which defines the variables is exactly the one you should extend to contain the additional variables for the email template. Have a look on the code that sends the order_conf.html and copy it from there. That is, the $data in the bankwire controller, where validateOrder is called afterwards with additional variables for the email, as the code you posted looks like the generic one. Edited October 23, 2015 by innovacy (see edit history) Link to comment Share on other sites More sharing options...
Benoit.ndr Posted October 23, 2015 Author Share Posted October 23, 2015 Good morning Well yes, the $data which defines the variables is exactly the one you should extend to contain the additional variables for the email template Yes, but right now, I'm doing it in OrderHistory.php and you saying that's not the right place to do that Have a look on the code that sends the order_conf.html and copy it from there. Am I right : - classes/PaymentModule.php that sends datas to order_conf.html - classes/order/OrderHistory.php that sends datas to bankwire.html ? That is, the $data in the bankwire controller, where validateOrder is called afterwards with additional variables for the email In the modules/bankwire/controllers/front/validation.php file, I found this line $this->module->validateOrder($cart->id, Configuration::get('PS_OS_BANKWIRE'), $total, $this->module->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key); that is the only one I have with validateOrder, so I think I can modify $mailVars from $mailVars = array( '{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'), '{bankwire_details}' => nl2br(Configuration::get('BANK_WIRE_DETAILS')), '{bankwire_address}' => nl2br(Configuration::get('BANK_WIRE_ADDRESS')) ); to $mailVars = array( '{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'), '{bankwire_details}' => nl2br(Configuration::get('BANK_WIRE_DETAILS')), '{bankwire_address}' => nl2br(Configuration::get('BANK_WIRE_ADDRESS')), '{newVar}' => $anything, '{newVar2}' => $anything2, ........ ); Am I right? That's what I understood from you're advices ^^ Sorry if I'm not understanding well, I'm beginner in prestashop and I'm fucking bad in English :s I'm trying hard to understand prestashop ! Thanks for all anyway Link to comment Share on other sites More sharing options...
innovacy Posted October 23, 2015 Share Posted October 23, 2015 (edited) You are on the right way with modules/bankwire/controllers/front/validation.php and $mailVars Edited October 23, 2015 by innovacy (see edit history) Link to comment Share on other sites More sharing options...
Benoit.ndr Posted October 23, 2015 Author Share Posted October 23, 2015 (edited) Hey again ! So.. I tried to add something in the validation.php file like that : public function postProcess() { $cart = $this->context->cart; if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) Tools::redirect('index.php?controller=order&step=1'); // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process $authorized = false; foreach (Module::getPaymentModules() as $module) if ($module['name'] == 'bankwire') { $authorized = true; break; } if (!$authorized) die($this->module->l('This payment method is not available.', 'validation')); $customer = new Customer($cart->id_customer); if (!Validate::isLoadedObject($customer)) Tools::redirect('index.php?controller=order&step=1'); $currency = $this->context->currency; $total = (float)$cart->getOrderTotal(true, Cart::BOTH); $mailVars = array( '{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'), '{bankwire_details}' => nl2br(Configuration::get('BANK_WIRE_DETAILS')), '{bankwire_address}' => nl2br(Configuration::get('BANK_WIRE_ADDRESS')), '{hello}' => 'HELLO WORLD' ); $this->module->validateOrder($cart->id, Configuration::get('PS_OS_BANKWIRE'), $total, $this->module->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key); Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key); } and in the bankwire.html a {hello} field, but that doesn't work :/ Was it the right way to do that ? Thanks Edited October 23, 2015 by Benoit.ndr (see edit history) Link to comment Share on other sites More sharing options...
ronniee Posted October 11, 2016 Share Posted October 11, 2016 Hi, I want to customize bankwire.html email to be a Proforma Invoice. I need some data, like order_conf.html mail: {invoice_block_html} {delivery_block_html} {products} {discounts} {total_products} {total_discounts} {total_shipping} {total_tax_paid} Somebody has made this kind of mail template? thanks ronn {total_products} 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