Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X

5 things you need to know when migrating your OpenCart Payment extension from 1.5.x to 2.0.x

I got a call from a friend requesting that I helped him port his OpenCart Payment extension/pluggin from 1.5.x to 2.0.x. It is funny there is rarely a place you can get information about migrating your OpenCart 1.5.x extenion to 2.0.x, so I deceided write one.

Here are five things you need to know or take note of when migrating your OpenCart Payment extension/plugin.

1. Change all $this->data[''] to $data[''] in your controllers.

2. From the admin controller, change the template loader from


$this->template = 'payment/....tpl';
$this->children = array(
'common/header',
'common/footer'
);

$this->response->setOutput($this->render());
		

to


$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('payment/....tpl', $data));
		

3. There is no more confirm method in the ModelCheckoutOrder class (in catalog/model/checkout/order.php), so using $this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('accessbank_order_status_id')) in your Controller payment would give an error.

4. Add "terms" to your catalog model method. Go to your model and see what looks like below, where you are checking the status of your payment extension, add terms to your array.


if ($status) { 
    $method_data = array( 
    'code' => '...',
    'title' => $this->language->get('text_title'),
    'sort_order' => $this->config->get('..._sort_order')
   );
}
		

to


if ($status) { 
    $method_data = array( 
    'code' => '...',
    'title' => $this->language->get('text_title'),
    'terms' => '',
    'sort_order' => $this->config->get('..._sort_order')
   );
}
		

5. The admin template has also greatly changed, <?php echo $column_left; ?> should to be added to the <?php echo $header; ?> at the top. You now have this <?php echo $header; ?><?php echo $column_left; ?>. The styling of the component too changed. You can check other pre-installed payment to have a sneak at what changed.

 

Update:

6. You also need need to change the template loader in your catalog controller from


if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/....tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/....tpl';
} else {

$this->template = 'default/template/default/....tpl';
} 

$this->render();
		

to


if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/....tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/payment/....tpl', $data);
} else {
return $this->load->view('default/template/payment/....tpl', $data);
}
		

7. Change the index method visibity from protected to public in your <root>/catalog/controller/payment/....php

Change the visibility of the index method in your <root>/catalog/controller/payment from


class ControllerPaymentCod extends Controller {
protected function index() {
		

to


class ControllerPaymentCod extends Controller {
public function index() {
		

8. Change your redirect method from $this->redirect() to $this->response->redirect()

 

I guess this helps someone before OpenCart releases their official migration documentation.

Movement

 


comments powered by Disqus