wolfib Posted June 8, 2012 Share Posted June 8, 2012 Hello, I'm developping a module for my website and I need to use the newOrder hook. But it doesn't work. Trying to test the hook by sending an email when a new order is done, I've written someting really simple. Here's my code : <?php class Nicotest extends Module { function __construct() { $this->name = 'nicotest'; $this->tab = 'Nico'; $this->version = 0.1; $this->author = 'Nico'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Nico test'); $this->description = $this->l('Description du module à Nico'); parent::__construct(); } function install() { if ( parent::install() == false OR !$this->registerHook( 'newOrder' ) ) return false; return true; } public function uninstall() { if (!parent::uninstall()) return false; } /* Test newOrder hook*/ function hookNewOrder($params) { Mail::Send(2,'test','Test de mail','Salut','[email protected]','My name'); } } ?> I never receive any email (it works for standard prestashop emails like orders). I've checked in the position module tab and my module is well known by my prestashop website. Does this hook some special code to work ? Tried to find some help on Google but it seems that it's not the most used hook... Thanks for any help ! Wolfib Link to comment Share on other sites More sharing options...
bellini13 Posted June 8, 2012 Share Posted June 8, 2012 the 4th parameter is the template variables which needs to be an array otherwise the Send function will return false if (!is_array($templateVars)) { Tools::dieOrLog(Tools::displayError('Error: parameter "templateVars" is not an array'), $die); return false; } 2 Link to comment Share on other sites More sharing options...
wolfib Posted June 8, 2012 Author Share Posted June 8, 2012 Hi, Ok thanks ! It's working now. So much wasted time for something easy... Sorry to disturb, hope it helps someone else ! Thanks again ! Wolfib Link to comment Share on other sites More sharing options...
brunomizu Posted September 18, 2012 Share Posted September 18, 2012 Please'm having the same problem this hook does not work and did not understand the explanation above! Link to comment Share on other sites More sharing options...
bellini13 Posted September 18, 2012 Share Posted September 18, 2012 can you be more specific about what does not work? I assume you are talking about the newOrder hook, but what specifically is not working? Link to comment Share on other sites More sharing options...
Undisconnected Posted January 15, 2016 Share Posted January 15, 2016 Hi ! I got a problem on this newOrder hook. It seems to never be executed. Here's the code I use to test the execution of the hook : public function install() { if (!parent::install() OR !$this->alterTable('add') OR !$this->registerHook('footer') OR !$this->registerHook('actionCartSave') OR !$this->registerHook('newOrder')) return false; return true; } public function hookActionCartSave($params){ error_log("Cart saved"); } public function hookNewOrder($params) { error_log("Order created"); } So if I add a product to the cart, I can see "Cart saved" in my error_log If I check after an order creation like with Paypal sandbox I never get anything. I check that the IPN is sent and the order is created ... Which should have executed the newOrder hook right ? Thanks for your help in advance Link to comment Share on other sites More sharing options...
bellini13 Posted January 15, 2016 Share Posted January 15, 2016 This may depend on the version of Prestashop. This post is a few years old now. I believe newOrder hook is now called actionValidateOrder, so you need to register 'actionValidateOrder' and have a function hookActionValidateOrder 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