Post by drdre4life » Thu Jul 02, 2020 7:27 pm

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

Newbie

Posts

Joined
Wed May 27, 2020 2:35 am

Post by sw!tch » Thu Jul 09, 2020 5:26 pm

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.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by drdre4life » Wed Jul 15, 2020 1:21 am

Thank you for your reply. I finally figured it out. I was calling the wrong method

Newbie

Posts

Joined
Wed May 27, 2020 2:35 am
Who is online

Users browsing this forum: No registered users and 248 guests