Rissinko Posted June 7, 2018 Share Posted June 7, 2018 (edited) Hello, Any one who can help me with the problem... Is there any way how to exec action hook on onepage checkout for example when i will click on PAYMENT METHOD ? My scenario : i have checkbox and when it is checked i need to insert value to the database. In normal 5 step checkout i used hookactionCarrierProcess but onepage checkout doesn't use this actionhook. Edited June 7, 2018 by Rissinko (see edit history) Link to comment Share on other sites More sharing options...
phinq1910 Posted June 11, 2018 Share Posted June 11, 2018 You can add your custom hook to controller/template file before/after the event Link to comment Share on other sites More sharing options...
Rissinko Posted June 11, 2018 Author Share Posted June 11, 2018 @phinq1910 Yes i tried this solution before but i was not successful. I tried exec hook in OrderOpcController.php in _assignPayment but it didn't work. I wanted to add hook exec after choosing the payment method. So you will choose payment then actionhook will save data and then you will be redirect to the execution payment page where is button "i confirm my order". Link to comment Share on other sites More sharing options...
phinq1910 Posted June 11, 2018 Share Posted June 11, 2018 You need $this->registerHook('your-custom-hook') in your module befire call it. Link to comment Share on other sites More sharing options...
Rissinko Posted June 11, 2018 Author Share Posted June 11, 2018 hmm ok look at it maybe you will see problem because i don't have a clue what is wrong. OrderOPCController.php - here iam calling exec of my new actionhook –> hookactionbeforesummary protected function _assignPayment() { if ((bool)Configuration::get('PS_ADVANCED_PAYMENT_API')) { $this->context->smarty->assign(array( 'HOOK_TOP_PAYMENT' => ($this->isLogged ? Hook::exec('displayPaymentTop') : ''), 'HOOK_PAYMENT' => $this->_getPaymentMethods(), 'HOOK_ADVANCED_PAYMENT' => Hook::exec('advancedPaymentOptions', array(), null, true), 'link_conditions' => $this->link_conditions )); } else { $this->context->smarty->assign(array( 'HOOK_TOP_PAYMENT' => ($this->isLogged ? Hook::exec('displayPaymentTop') : ''), 'HOOK_PAYMENT' => $this->_getPaymentMethods() )); } Hook::exec('hookactionbeforesummary',array()); } And my modul php file. public function install() { if (!parent::install() . . . || !$this->registerHook('displayGdprOrder') || !$this->registerHook('actionbeforesummary')) { return false; } } public function hookdisplayGdprOrder($params) { $this->smarty->assign('heureka_message', $this->l('checkbox text')); return $this->display(__FILE__, 'orderprocess.tpl', $this->getCacheId()); } public function hookactionbeforesummary($params) { if(Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) { if (Tools::getValue('heureka_checkbox') == '1') { $data = array( 'id_cart' => $params['cart']->id, 'id_customer' => $params['cart']->id_customer, 'value' => $suhlas, ); Db::getInstance()->insert('heureka_suhlas', $data); } } } orderprocessheureka.tpl file which is hooked to hookdisplayGdprOrder and this hook is showed under checkbox for terms and conditions . <div class="error_customerprivacy" style="color:red;"></div> <fieldset class="account_creation heureka"> <div style="width:21px; float:left;"> <div class="required checkbox"> <input type="checkbox" value="1" id="heureka_checkbox" name="heureka_checkbox" autocomplete="off"/> </div> </div> <div style="width: 92%; float: left; margin-top: 8px;"> <label for="customer_privacy" style="font-weight: normal;">{$heureka_message}</label> </div> </fieldset> Link to comment Share on other sites More sharing options...
Rissinko Posted June 12, 2018 Author Share Posted June 12, 2018 I think another way will be use ajax call but i am not sure how to do that. Link to comment Share on other sites More sharing options...
phinq1910 Posted June 13, 2018 Share Posted June 13, 2018 Hook::exec('hookactionbeforesummary',array()); and || !$this->registerHook('actionbeforesummary')) { are not same. Link to comment Share on other sites More sharing options...
Rissinko Posted June 13, 2018 Author Share Posted June 13, 2018 Thanks it was mistake but it is not the problem why it not working. Link to comment Share on other sites More sharing options...
Rissinko Posted June 13, 2018 Author Share Posted June 13, 2018 Ok problem solved i used ajax call which will run function when checkbox is checked or unchecked. 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