Post by latheesan » Sun Dec 27, 2015 2:27 am

I am a developer working on an open cart based hosting site. The requirement is to hook into successful order & payment event, so that I can load the order "options" and then call third party api to actually create the hosting package.

Thanks to this guide, http://isenselabs.com/posts/opencart2-e ... m-tutorial I have started to work on a custom module. Can someone tell me which event I need to subscribe to? I want to know when there is a successful order with a completed payment (will be using paypal express checkout).

Here's my custom module code so far:

catalog/controller/module/mysite.php

Code: Select all

<?php

class ControllerModuleMysite extends Controller
{
    private $eventList;

    public function __construct()
    {
        $this->$eventList = array
        (
            'NewSuccessfulOrder' => '???.???.???'
        );
    }

    public function install()
    {
        $this->load->model('extension/event');

        foreach ($this->$eventList as $eventName => $eventHook)
        {
            $this->model_extension_event->addEvent(
                'mysite_'. $eventName,
                $eventHook,
                'module/mysite/'. $eventName
            );
        }
    }
    
    public function uninstall()
    {
        $this->load->model('extension/event');

        foreach ($this->$eventList as $eventName => $eventHook)
        {
            $this->model_extension_event->deleteEvent(
                'mysite_'. $eventName);
        }
    }
    
    public function NewSuccessfulOrder($order_id)
    {
        // Todo: Load order and all of it's options
        // Todo: Call third party api to create the hosting package based on order
        // Todo: Email customer with hosting access details
    }
}
Apologies if I have posted this question in the wrong board.

P.S. where can I finding the OpenCart 2.x Event system documentation? I would like to see what other events I can make use of.

Regards,
Latheesan

Newbie

Posts

Joined
Fri Dec 18, 2015 6:18 pm

Post by jimmyphong » Tue Dec 29, 2015 2:02 pm

Here list of opencart event

Code: Select all

https://github.com/opencart/opencart/wiki/Events-(script-notifications)-2.0.0.1

News CMS || Plus SEO || Live Price change with Option Select


Active Member

Posts

Joined
Sat Aug 13, 2011 2:48 am

Who is online

Users browsing this forum: No registered users and 39 guests