Page 1 of 1

Opecart 3.0.3 Event Not Working

Posted: Thu Jul 02, 2020 7:27 pm
by drdre4life
I have written a shipping extension which works fine but I need opencart event to update the shipping API using curl but it seems not to be working.
I have the following written at admin/controller/extension/module/post_order.php

<?php
class ControllerExtensionModulePostOrder extends Controller
{
public function install()
{
$this->load->model('setting/event');

$this->model_setting_event->addEvent('post_order', 'catalog/model/checkout/order/addOrderHistory/after', 'extension/module/post_order/addOrderHistory');
}
public function uninstall()
{
$this->load->model('setting/event');

$this->model_extension_event->deleteEvent('post_order');
}
}
and I also have catalog/controller/extension/module/post_order.php
<?php
class ControllerExtensionModulePostOrder extends Controller {

public function postOrderData(&$route, &$args, &$output) {
$this->log->write('test');

}

}
the code seems not to be running as I cant see the event listed in the event section of admin not also logging the test.
Thanks

Re: Opecart 3.0.3 Event Not Working

Posted: Thu Jul 09, 2020 5:26 pm
by sw!tch
Well first fix your code.

Your event is calling

Code: Select all

extension/module/post_order/addOrderHistory
yet your module method is

Code: Select all

postOrderData()
You need to call the correct method

Code: Select all

extension/module/post_order/postOrderData
For testing events IMO, it's easier to just manually insert the events via your DB and once confirmed working then write the module to install them.

Also use code tags when posting in the future.

Re: Opecart 3.0.3 Event Not Working

Posted: Wed Jul 15, 2020 1:21 am
by drdre4life
Thank you for your reply. I finally figured it out. I was calling the wrong method