Basically I am developing an extension for OC 4.0.2.3 and I am encountering an issue. I want the function createShipmentWandiAfter to be triggered after a new order is added but i can't make it work. Once I install the extension, the event is correctly created (see picture at the end) but in any case it triggers when I complete a purchase in the checkout.
I have even added some additional logging to the addOrder function to debug that is properly working and that is the data that I need in my event, but can't manage to trigger it. Any help would be extremely appreciated!

-
Here the code:
Code: Select all
public function install(): void {
$this->load->model('setting/event');
$this->model_setting_event->deleteEventByCode('enable_dark_theme');
$this->model_setting_event->deleteEventByCode('post_shipment_to_wandi');
$this->model_setting_event->addEvent([
'code' => 'post_shipment_to_wandi',
'description' => '',
'trigger' => 'catalog/model/checkout/order/addHistory/after',
'action' => $this->event . '.createShipmentWandiAfter',
'status' => true,
'sort_order' => 1
]);
$this->model_setting_event->addEvent([
'code' => 'enable_dark_theme',
'description' => '',
'trigger' => 'admin/controller/common/header/before',
'action' => $this->event . '.runDarkThemeScripts',
'status' => true,
'sort_order' => 1
]);
$this->load->model('user/user_group');
$groups = $this->model_user_user_group->getUserGroups();
foreach($groups as $group) {
$this->model_user_user_group->addPermission($group['user_group_id'], 'access', $this->path);
$this->model_user_user_group->addPermission($group['user_group_id'], 'access', $this->event);
}
}
public function uninstall(): void {
if ($this->user->hasPermission('modify', $this->path)) {
$this->load->model('setting/event');
$this->model_setting_event->deleteEventByCode('enable_dark_theme');
$this->model_setting_event->deleteEventByCode('post_shipment_to_wandi');
}
}
public function runDarkThemeScripts($route, &$args): void {
if ($this->config->get($this->module . '_status')) {
$this->document->addScript('../extension/wandioc/admin/view/javascript/darktheme.js');
$this->document->addStyle('../extension/wandioc/admin/view/styles/darktheme.css');
}
}
public function createShipmentWandiAfter(&$route, &$args , &$output): void {
$this->log->write('Purchase Event Catched'.print_r($args), TRUE);
$this->log->write('Route: ' . $route);
$this->log->write('Order Info: ');
$this->log->write(print_r($args));
}
public function createShipmentWandiBefore(&$route, &$args): void {
$this->log->write('Purchase Event Catched'.print_r($args), TRUE);
$this->log->write('Route: ' . $route);
$this->log->write('Order Info: ');
$this->log->write(print_r($args));
}
}
event created and active:
