fabi_k Posted November 2, 2012 Share Posted November 2, 2012 Hi Prestashop-Forum, I'd like to introduce myself. My name is Fabian. I'm new to Presta*. But not new to programming. I've in business now for several years. And have following question: how would I hook into confirmation email, send to customers after successfully buying a product? At http://doc.prestasho...+PrestaShop+1.5 I didn't found any apropriate Hook. hookOrderConfirmation sounds good, but IMHO only works in http. Is there another hook I can use? I'm using Presta 1.5.1.0 on Debian 6.0.5 and have fullaccess to the server. Thank you Fabian *I want to setup Presta as a portal for software-downloads. In detail the software-download will be free available. To run the software a license-key will be send by E-Mail to customers. Link to comment Share on other sites More sharing options...
bellini13 Posted November 2, 2012 Share Posted November 2, 2012 you want to be able to add content to the order conf email? Or you just need to execute some arbitrary code after receiving a new order? You can use newOrder hook for the latter. To include additional information in the order conf email would require an override to the PaymentModule class. Link to comment Share on other sites More sharing options...
fabi_k Posted November 3, 2012 Author Share Posted November 3, 2012 Hi bellini, thanks for your answer. Maybe I need booth solutions. Overriding PaymentModule to put the license-key into E-Mail and saving that license-key into database. I'll have a look. Can you tell me, where I can get some more information about newOrder-hook? e.g. which parameters it has. Regards Fabian Link to comment Share on other sites More sharing options...
bellini13 Posted November 3, 2012 Share Posted November 3, 2012 the hook used to be executed from within the PaymentModule validateOrder function. It appears to have been deprecated in v1.5. Instead there is a new hook called actionValidateOrder that is executed by the PaymentModule validateOrder function. this hook is executed after the order is created, but before the email is sent. Hook::exec('actionValidateOrder', array( 'cart' => $this->context->cart, 'order' => $order, 'customer' => $this->context->customer, 'currency' => $this->context->currency, 'orderStatus' => $order_status )); Link to comment Share on other sites More sharing options...
fabi_k Posted November 8, 2012 Author Share Posted November 8, 2012 Alright. I'm finished. Using a hook was the wrong way, but you took me to right one, though. I've overwrote method PaymentModuleCore::validateOrder with abstract class PaymentModule. Here a only added a new entry to parameter $extra_vars. $extra_vars is used by Prestashops E-Mail-Engine and only stores values for E-Mail-Templates. Therefor I've must edit the E-Mail Template, also. There are two possible locations. I've only needed to change first on. Default is `_PS_MAIL_DIR_/$lang/order_conf.html'. I guess the other one is this `$theme_path/modules/$module_name/mails/order_conf.html'. Don't know what values where in $theme_path and $module_name. However. If you like to see, here is the Code for PaymentModule: abstract class PaymentModule extends PaymentModuleCore { /** * Overrides Method validateOrder() (found in classes/PaymentModule.php). * * It is needed to generate PIN and put that PIN into Order-Confirmation E-Mail * and stores PIN in Database. * * The E-Mail template (in my case ATM found at mails/$lang/order_conf.html, but may be found * in templates mail-Folder) needs a new placeholder for that PIN. The value of that placeholder * will be defined in parameter $extra_vars. * * Because validateOrder() is called by every Payment-Method itself there is AFAIK no common * way to put extra values in parameter $extra_vars, except overriding validateOrder() aka * this method. */ public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null) { // Generate PIN $pin = ...; // Saving PIN in Database Db::getInstance()->insert('PIN_TABLE', array( ... 'pin' => $pin )); // Putting PIN into E-Mail $extra_vars['{MY_PIN_PLACEHOLDER}'] = $pin; return parent::validateOrder( $id_cart, $id_order_state, $amount_paid, $payment_method, $message, $extra_vars, $currency_special, $dont_touch_amount, $secure_key, $shop ); } } Regards // Fabian 2 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