'Opencart 3.0.3.7 event not catch, not working
Note: I had read tons of information here and another sources, including official docs.
I have a payment extension - ex title simplepay.
- I want to know specifically if it is a way to "listen" to a system (predefined) event.
- I want to run some logic when an order status has changed.
In the admin/controller/extension/payment/simplepay.php I have this (nothing more elsewhere):
public function install()
{
$this->load->model('setting/event');
/** addEvent($code, $trigger, $action, $status = 1, $sort_order = 0); */
$this->model_setting_event->addEvent(
'do_transaction_on_order_status_change',
'catalog/controller/api/order/history/after',
'extension/payment/simplepay/doTransactionOnOrderStatusChange');
}
public function uninstall()
{
$this->load->model('setting/event');
/** deleteEventByCode($code); */
$this->model_setting_event->deleteEventByCode('do_transaction_on_order_status_change');
}
public function doTransactionOnOrderStatusChange(&$route, &$data)
{
// testing purpose for the moment
$log = new Log('aaaaaa.log');
$log->write('Route ' . $route);
}
The event do_transaction_on_order_status_change is properly registered in events list.
What I am doing wrong?
Solution 1:[1]
Nevermind!
After a while I got the point.
My method doTransactionOnOrderStatusChange(&$route, &$data) was writted with 3 parameters.
Like doTransactionOnOrderStatusChange(&$route, &$data, &$output).
The problem is that OC 3+ not accept a third parameter, even if there is a "before" or an "after" event.
And another problem was the related event: it must be admin/controller/sale/order/history/before. (or /after)
No other event on order change worked. (probably this event is the only admin event, the rest being from catalog).
If I am wrong, please correct me!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | LucianDex |
