Answer the question
In order to leave comments, you need to log in
How to access a variable when an event occurs in opencart 2.2?
I can't figure out how to access a variable in the opencart 2.2 event system. I will explain
in earlier versions of opencart I did this: I
created an event in my module:
$this->model_extension_event->addEvent('oproscupon_register', 'post.customer.add', 'module/oproscupon/after_register');
this event was generated automatically by the kernel when calling the
catalog\model\account\customer\addCustomer model (where addCustomer is a function)
defined the function in the controller of its module public function after_register($customer_id){
//code
}
the variable $customer_id is returned in the addCustomer function of the catalog model \model\account\customer
public function addCustomer($data) {
$this->event->trigger('pre.customer.add', $data);
//code
$this->event->trigger('post.customer.add', $customer_id);
return $customer_id;
}
it turned out that in my after_register event handler I had access to the $customer_id variable and could operate on it.
I can’t figure out how to access the same variable in opencart 2.2
in the catalog\model\account\customer model in the addCustomer function, the event generation function, to which the $customer_id variable would be passed, is not called.
how do I get access from my function (event handler) to the $customer_id model variable. do I need to explicitly call the $this->event->trigger function in the model? if so, then it turns out you need to change the kernel or use ocmod? or is there another way?
Help me to understand.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question