M Iqbal Posted March 30, 2022 Share Posted March 30, 2022 Hello Developers, I am using event "actionCustomerAccountUpdate" in my custom module to get the user updated information. But this event is not working for version 1.6.1.24. Somebody can help me ? Link to comment Share on other sites More sharing options...
endriu107 Posted March 30, 2022 Share Posted March 30, 2022 I'm not sure but this hook might not exist in 1.6 Link to comment Share on other sites More sharing options...
M Iqbal Posted March 30, 2022 Author Share Posted March 30, 2022 14 minutes ago, endriu107 said: I'm not sure but this hook might not exist in 1.6 What should i do to achieve the customer update hook thing ? Link to comment Share on other sites More sharing options...
Ress Posted March 31, 2022 Share Posted March 31, 2022 In 1.6 doesn't exist. You can use: actionObjectCustomerUpdateAfter 1 1 Link to comment Share on other sites More sharing options...
knacky Posted April 1, 2022 Share Posted April 1, 2022 I'll just add information on how to get the id_customer: $id_customer = (int)$params['object']->id; 1 Link to comment Share on other sites More sharing options...
M Iqbal Posted April 5, 2022 Author Share Posted April 5, 2022 On 3/31/2022 at 9:42 PM, Ress said: In 1.6 doesn't exist. You can use: actionObjectCustomerUpdateAfter Will this work on customer address update as well ? Link to comment Share on other sites More sharing options...
knacky Posted April 5, 2022 Share Posted April 5, 2022 (edited) And why shouldn't it work? It's easy! public function hookActionObjectCustomerUpdateAfter($params) { $id_customer = (int)$params['object']->id; $customer = new Customer((int)$id_customer); $gender = new Gender((int)$customer->id_gender, (int)$customer->id_lang, (int)$customer->id_shop); $group = new Group((int)$customer->id_default_group, (int)$customer->id_lang, (int)$customer->id_shop); $firstname = $customer->firstname; $lastname = $customer->lastname; $company = $customer->company; $genderName = $gender->name; $groupName = $group->name; .... } Edited April 5, 2022 by knacky (see edit history) 1 Link to comment Share on other sites More sharing options...
M Iqbal Posted April 5, 2022 Author Share Posted April 5, 2022 (edited) Upon saving or updating customer address, the hook actionObjectCustomerUpdateAfter is not working. I want to get the event of Customer update address as well. For 1.7.X i am using actionValidateCustomerAddressForm to catch customer address update event. Edited April 5, 2022 by M Iqbal (see edit history) 1 Link to comment Share on other sites More sharing options...
knacky Posted April 5, 2022 Share Posted April 5, 2022 (edited) actionObjectAddressUpdateAfter public function hookActionObjectAddressUpdateAfter($params) { $id_address = (int)$params['object']->id; $address = new Address((int)$id_address); $company = $address->company; $lastname = $address->lastname; .... } actionObjectAddressAddAfter public function hookActionObjectAddressAddAfter($params) { $id_address = (int)$params['object']->id; $address = new Address((int)$id_address); $company = $address->company; $lastname = $address->lastname; .... } Edited April 5, 2022 by knacky (see edit history) 1 Link to comment Share on other sites More sharing options...
M Iqbal Posted April 5, 2022 Author Share Posted April 5, 2022 Yes it is working like a charm . Thank you so much, can you please tell me about uninstall event hook as well for prestashop 1.6 ? 1 Link to comment Share on other sites More sharing options...
knacky Posted April 5, 2022 Share Posted April 5, 2022 /* install */ public function install() { if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } if (!parent::install()) { return false; } $this->registerHook('actionObjectAddressAddAfter'); return true; } /* uninstall */ public function uninstall() { $this->unregisterHook('actionObjectAddressAddAfter'); if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } if (!parent::uninstall()) { return false; } return true; } Link to comment Share on other sites More sharing options...
M Iqbal Posted April 5, 2022 Author Share Posted April 5, 2022 Yes i have created this uninstall function in my module and it is working fine with 1.7.X but, when i uninstall the module from 1.6.X like in mentioned image this uninstall function not works. Link to comment Share on other sites More sharing options...
knacky Posted April 5, 2022 Share Posted April 5, 2022 When you have multiple hooks, it can be used recursively. E.g: class MyModule extends Module { public $hooks = array('actionObjectAddressAddAfter', 'header', 'actionFrontControllerSetMedia'); ... ... /* install */ public function install() { if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } if (!parent::install()) { return false; } foreach ($this->hooks as $hook) { $this->registerHook($hook); } return true; } /* uninstall */ public function uninstall() { foreach ($this->hooks as $hook) { $this->unregisterHook($hook); } if (Shop::isFeatureActive()) { Shop::setContext(Shop::CONTEXT_ALL); } if (!parent::uninstall()) { return false; } return true; } Link to comment Share on other sites More sharing options...
knacky Posted April 5, 2022 Share Posted April 5, 2022 (edited) 3 minutes ago, M Iqbal said: Yes i have created this uninstall function in my module and it is working fine with 1.7.X but, when i uninstall the module from 1.6.X like in mentioned image this uninstall function not works. Turn on debug mode and enter an error message here, or make screen errors. I don't see your installation and uninstallation feature, so I can't give targeted advice. Edited April 5, 2022 by knacky (see edit history) Link to comment Share on other sites More sharing options...
M Iqbal Posted April 5, 2022 Author Share Posted April 5, 2022 /** * On uninstall event * * @return bool */ public function uninstall() { if(!$this->getIntegrationID()) { $curlData = array( "event" => "Uninstall", "uuid" => $this->getIntegrationID(), "data" => new stdClass() ); Configuration::deleteByName('module'); Configuration::deleteByName('module_username'); Configuration::deleteByName('module_password'); Configuration::deleteByName('integrationId'); $this->unsetEvents(); $this->request($this->eventUrl, $curlData, "POST"); } return parent::uninstall(); } This is what i am doing and it is working fine with Prestashop 1.7 but not for 1.6 Link to comment Share on other sites More sharing options...
M Iqbal Posted April 5, 2022 Author Share Posted April 5, 2022 There was a problem in my function conditions. It is fixed now, Thank you so much for your time. 1 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