OpenCart – Creating Your Own Extension

Perhaps you have been digging around your Open Cart installation and have decided that you want to brave the waters to make your own extension, or perhaps you just cannot afford the money to purchase an existing extension from the store; this article will go over the basics to developing an extension and will attempt to simplify the process. Before we begin, it helps to know the basics of an MVC-L (MODEL VIEW CONTROL LANGUAGE) framework and we recommend reading this article before continuing.

To begin, conjure up ideas about what you want your extension to do. What is its main purpose?  How will it function? What settings are you going to make available to the user in terms of configuration? After you have decided these things, first think if there are any existing default Open Cart extensions that are similar. We are basically going to be copying/duplicating files in order to minimize the labor and if there is one that is already close then that is the one we will mimic. For example, if you wanted to create a module that displayed HTML on a specific page; that would be positioned on your choice of page; it would make sense to copy the WELCOME MODULE because it already does this.


Open admin/controller/module/welcome.php and whichever editor you are in choose SAVE AS and name it something different “whichever your extension will be named.” For this demonstration we will name our extension displayhtml.php

Now you have your new control file called displayhtml.php. In this file, at the very top you will want to locate the following line of code:

class ControllerModuleWelcome extends Controller {

Change this code to the name of your file : class ControllerModuleDisplayHtml extends Controller {

Now find this line of code: $this->model_setting_setting->editSetting(‘welcome’, $this->request->post); and change to: $this->model_setting_setting->editSetting(‘displayhtml’, $this->request->post);

Next, find/replace all instances of module/welcome with module/displayhtml

Next, find this code: if (isset($this->request->post[‘welcome_module’])) {
$this->data[‘modules’] = $this->request->post[‘welcome_module’];
} elseif ($this->config->get(‘welcome_module’)) {
$this->data[‘modules’] = $this->config->get(‘welcome_module’);
and replace it with:

if (isset($this->request->post[‘displayhtml_module’])) {
$this->data[‘modules’] = $this->request->post[‘displayhtml_module’];
} elseif ($this->config->get(‘displayhtml_module’)) {
$this->data[‘modules’] = $this->config->get(‘displayhtml_module’);

That set’s up the display code correctly.

Lastly, find $this->template = ‘module/welcome.tpl’; and replace with $this->template = ‘module/displayhtml.tpl’;


Now open admin/view/template/module/welcome.tpl and SAVE AS displayhtml.tpl

In this file, find/replace all instances of welcome_module with displayhtml_module


Now open admin/language/english/module/welcome.php and SAVE AS displayhtml.php

In that file, edit your text strings to match your new extension.

IMPORTANT: You must now do the same routine for the files in the catalog. This is what your customers will see. I guided you through the admin portion.

Upload all of these files and guess what, you have your new extension!  Go to EXTENSIONS>MODULES and you will see it there. INSTALL/EDIT and have fun.

Looking for quality OpenCart Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , | Posted under OpenCart | RSS 2.0

Author Spotlight

Joe Stenhouse

I am a web application developer that specializes in PHP, JAVASCRIPT, MYSQL, HTML, and CSS. We manifest exciting potentials within the world wide web through means of innovation.

4 Comments on OpenCart – Creating Your Own Extension

  1. Divya says:

    is it for opencart 2.0?? i want to develop one sms extension to send sms from

  2. anjali says:

    bt there is not welcome file in module..then what i do?

  3. anjali says:

    and one more que is i want to export my products in excel sheet and i also try import/export tool and any other free resource bt export/import does nt appear on admin area now what i do..plz rply

Leave a Reply

Your email address will not be published. Required fields are marked *