Jump to content

Prestashop 1.6 - OPC exec custom action hook


Recommended Posts

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 by Rissinko (see edit history)
Link to comment
Share on other sites

@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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...