The structure of an OpenCart module depends on the version. In 3.0, extension files are spread across the shared core directories admin/ and catalog/, in subfolders extension/{тип}/. In 4.1, each extension lives in its own folder extension/, with the same split into admin and catalog. Below we cover which files are needed, how the core finds them, what happens during installation, and where settings are stored. That way you can read other people's modules and write your own without guesswork.
Examples are for OpenCart 4.1; in 4.0.x, model triggers and event handling differ.
What parts make up an OpenCart extension?
An extension in OpenCart is a regular set of MVC-L files: a controllerCode that receives a request and prepares data. More in the glossary →, a model, a template, and a language fileA PHP file with interface texts, separate for each language. More in the glossary →. Two things set it apart from "just code." The first is the extension type. The second is a record in the extension table, without which the core does not consider the extension installed. How these layers relate to each other is described in detail in the article on MVC-L, see how the controller, model, template, and language are connected. Here we focus on what is specific to extensionsAdditional functionality: a module, a payment or shipping method, a feed, or a theme. They are managed in "Extensions → Extensions." More in the glossary →.
A typical module has two halves:
- Admin side: a controller with a settings form and
install()/uninstall()methods, a form template, a language file, and, if needed, a model (for example, to create custom tables). - StorefrontWhat the customer sees: the home page, categories, product page, and cart. More in the glossary → side (catalog): a controller that renders a block on a page or handles payment or shipping, a model for data queries, a template, and a language file.
The type determines where the core "hooks" the extension in. A module is displayed in layout positions. A payment methodAn extension such as card or cash payment. More in the glossary → is called during checkout. A total takes part in calculating the order amount. A feed exports data outward. Each type is described in detail in a separate material in this section. For the anatomy, one thing matters: the type is the name of a subdirectory, and the core uses it to build paths to files.
In the admin, the list of extensions of a particular type is generated by a separate "dispatcher" controller. In OpenCart 3.0 these are files such as admin/, payment.php, shipping.php. In OpenCart 4.1 they are admin/, payment.php, and so on. These dispatchers scan the directories, show the "Install"/"Uninstall" buttons, and write to the extension table.
What extension types exist in 3.0 and 4.1?
The set of types in the two branches is almost the same, but not identical. The list below covers the main types, collected from the dispatchers of the clean core. The service dispatcher marketplace.php in 4.1 is not included in the table.
| Type | OpenCart 3.0 | OpenCart 4.1 | Purpose |
|---|---|---|---|
| module | yes | yes | Blocks in page layouts |
| payment | yes | yes | Payment methods |
| shipping | yes | yes | Shipping methods |
| total | yes | yes | Order total lines |
| feed | yes | yes | Feeds and exports |
| report | yes | yes | Admin reports |
| analytics, captcha, currency, dashboard, fraud, theme | yes | yes | Analytics, captcha, currency rates, dashboard widgets, anti-fraud, themes |
| advertise, menu, promotion | yes | no | Service types in 3.0 |
| language | no | yes | Language packs as extensions |
| other | no | yes | Extensions without a storefront role (service, integrations) |
The other type in 4.1 is especially handy. If a module shows nothing on the storefront but, say, only syncs stock with an accounting system or hooks into events, there's no need to disguise it as a module. In 3.0, such extensions were usually built as a module with no output, and they sat "empty" in the module list.

Where are the module files located in OpenCart 3.0?
In 3.0, an extension has no directory of its own. Its files are embedded into the core tree, and the file name (the extension code) is repeated in each of the branches. For a module with the code price_badge, the structure is as follows:
admin/controller/extension/module/price_badge.php
admin/model/extension/module/price_badge.php
admin/language/en-gb/extension/module/price_badge.php
admin/language/uk-ua/extension/module/price_badge.php
admin/view/template/extension/module/price_badge.twig
catalog/controller/extension/module/price_badge.php
catalog/model/extension/module/price_badge.php
catalog/language/en-gb/extension/module/price_badge.php
catalog/view/theme/default/template/extension/module/price_badge.twig
Key rules for 3.0:
- The route matches the path. The admin controller is opened via
route=extension/, and the class is named after the path in CamelCase:module/ price_badge ControllerExtensionModulePriceBadge. The model isModelExtensionModulePriceBadge, and in the controller it is available as$this.->model_extension_module_price_badge - The storefront template lives in the theme. The core looks for it in the active theme's directory, and if the file is not there, it takes it from
default. So put the template indefault, and a custom theme can override it if needed. - Extension code = file name. This is what gets written to the
extensiontable (columnstypeandcode) and becomes the prefix for settings.
The main drawback of this scheme is that module files are mixed with core files and files from other extensions. You can remove a module "cleanly" only by using a list of paths. The 3.0 installer records this list in the extension_path table, but only for modules installed through it. If you copied files over FTP, you have to keep the list yourself. It's handy to keep the 3.0 directory map at hand: OpenCart directory map for developers.
How did the structure change in OpenCart 4.1?
In 4.1, each extension is a separate "package" in the site root: extension/. Inside, the familiar pair admin/ and catalog/ is repeated, but without the intermediate extension/. The core ships its standard extensions the same way, in the extension/opencart/ package, and that is the best model to follow. Our example package mystore with the same module would look like this:
extension/mystore/
├── install.json
├── admin/
│ ├── controller/module/price_badge.php
│ ├── model/module/price_badge.php
│ ├── language/en-gb/module/price_badge.php
│ ├── language/uk-ua/module/price_badge.php
│ └── view/template/module/price_badge.twig
├── catalog/
│ ├── controller/module/price_badge.php
│ ├── model/module/price_badge.php
│ ├── language/en-gb/module/price_badge.php
│ └── view/template/module/price_badge.twig
└── system/ # за потреби: власні бібліотеки, config
What has fundamentally changed:
- The route contains the package code:
extension/. Language files and templates are loaded the same way, for examplemystore/ module/ price_badge $this.->load ->language('extension/ mystore/ module/ price_badge') - Namespaces instead of class prefixes. The admin controller is the class
PriceBadgein the namespaceOpencart\Admin\Controller\Extension\Mystore\Module, extending\Opencart\System\Engine\Controller. The storefront one is inOpencart\Catalog\Controller\Extension\Mystore\Module. - Methods in the route. In 4.1 the method is separated by a dot:
extension/. The settings form is usually submitted via an AJAX request tomystore/ module/ price_badge.save saveand receives a JSON response. - Storefront templates are not tied to the theme. They live in the package under
catalog/, not inview/ template/ catalog/.view/ theme/ …
One package can contain several extensions of different types. For example, extension/mystore/ can hold module/, payment/…, and other/…. Each is installed separately in its own section of the admin, while the files all sit together. How the core parses the route and finds classes is explained in the article on routing with route= in 3.0 and 4.1.
What happens when a module is installed?
Installation is a two-stage process, and in both versions the stages are easy to confuse. The first stage delivers the files to the server. The second registers the extension in the database and runs its install().
flowchart TD
A["Upload .ocmod.zip in Installer"] --> B{"Version?"}
B -->|"3.0"| C["Files from upload/ are copied to the root"]
B -->|"4.1"| D["Package is extracted to extension/code/"]
C --> E["Record in extension_install and extension_path"]
D --> E
E --> F["Extensions → type → Install"]
F --> G["Row in the extension table"]
G --> H["access/modify permissions for the admin group"]
H --> I["Controller install() is called"]
I --> J["Edit and save settings"]
- Uploading the package. "Extensions → Installer." In 3.0, the archive contents are copied straight into the site tree. In 4.1, the archive first appears in the list of uploaded files, and the files are extracted to
extension/{код}/after clicking "Install" in the same list. - Registering the extension. Next, "Extensions → Extensions," selecting the type in the filter, and the "Install" button next to the required row. The core adds a row to the
extensiontable. In 3.0 this is the pairtype/code. In 4.1 an extra columnextensionwith the package code is added. - Permissions. The current user's group is granted access and modify rights on the extension's route. Other admin groups must have these rights added manually in "System → Users → User Groups." Details are in the article on checking module access permissions.
- Your
install(). Here the module creates tables, registers events, and writes default settings.

Removal runs in reverse order: the "Uninstall" button deletes the row from extension and calls uninstall(). The files remain in place; only uninstalling the package in the installer removes them. This leads to a typical trap: the module was "removed," but its events or OCMOD modifications still work, because uninstall() does not clean them up.
Where are module settings and instances stored?
Extensions have two places for storing configuration, and the choice between them depends on the type.
The setting table is for "single" settings. Keys are grouped by code with a type prefix: module_price_badge_status, payment_liqpay_…, shipping_flat_cost. This prefix is not cosmetic. Type dispatchers and storefront mechanisms (for example, selecting the available payment methods) read the status and sort order precisely from keys like {тип}_{код}_status and {тип}_{код}_sort_order. If you name the field differently, the extension is formally installed, but the core will consider it disabled. Saving goes through the setting/setting model with a group equal to the prefix. For details, see the article in the setting model section.
The module table is only for the module type with multiple instances (such as the standard "Featured" or "Slideshow"). Each instance is a row with module_id, a name, a code, and a JSON field setting. Layout positions are bound to a specific instance. The instance code in 3.0 looks like price_badge, and in 4.1 it also includes the package: mystore.price_badge. If one set of parameters is enough for the module, don't overcomplicate things: setting is simpler and doesn't require working with layouts.
How do you package a module for each version?
Both versions accept an .ocmod.zip archive, but the contents differ. A 3.0 package cannot simply be repacked for 4.1.
| Item | OpenCart 3.0 | OpenCart 4.1 |
|---|---|---|
| Archive root | a folder upload/ mirroring the site tree | directly admin/, catalog/, system/ of the package |
| Metadata | optional; install.xml is an OCMOD modification | install.json with name, version, author, link |
| Package code | none, only codes of individual extensions | archive name without .ocmod.zip = folder in extension/ |
| Modifying core files | OCMOD via install.xml | mainly events; OCMOD is limited |
A minimal install.json for 4.1 looks roughly like this (an example, not a core file; use extension/ in your copy of OpenCart as the reference):
{
"name": "Price Badge",
"version": "1.0.0",
"author": "My Store Dev",
"link": "https://example.com"
}
Checklist before packing:
- the archive is named after the package code:
mystore.ocmod.zip, notmystore-v1.0-final.zip; - in 4.1 there is no extra nested folder at the first level of the archive;
- there are language files for every store language. In 3.0,
en-gbloads first and serves as the fallback. In 4.1 there is no fallbacken-gb, so the language file must exist for every store language (en-gb,uk-ua) with a complete set of keys; uninstall()removes events, settings, and, if agreed with the client, tables;- in 3.0, verify that the files do not overwrite same-named files from other modules.
The details of install.xml, compatibility, and common installer errors are covered in a separate article in the packaging section. For how to build a whole module step by step, see the step-by-step example of a first module for 3.0 and 4.1.
Summary
- In OpenCart 3.0, a module is scattered across
admin/and…/ extension/ {тип}/ catalog/. Classes are named after their path, and the storefront template lives in the theme.…/ extension/ {тип}/ - In OpenCart 4.1, a module lives in
extension/. The route contains the package code, classes have namespaces, and methods are called via a dot in the route.{пакет}/ - Installation is two-stage: first the files (installer), then registration in the
extensiontable, permissions, and yourinstall(). - Settings are stored in
settingwith the{тип}_{код}_prefix. Module instances for layouts are stored in themoduletable. - 3.0 and 4.1 packages are incompatible in archive structure. For 4.1, a correct
install.jsonand the package code in the archive name are mandatory.
Next, it's worth understanding how the extension controller interacts with the Loader and Registry: see how load->controller, model, view, and language work. The remaining topics (types, settings form, install/uninstall, custom tables) are gathered on the section page Creating OpenCart Modules.