How to create Opencart 4 module or extensions?

Opencart 4 extension tutorial

With the launch of Opencart 4, there are changes in extensions or module management and code structure so we are creating Opencart 4 extension tutorial to create Opencart 4 modules or extensions and try to understand the flow and ways to develop Opencart 4 extensions. We will create a new module called “showallproducts” and others will be similar to it. Check Opencart 4 demo.

Files and folder structure of Opencart module

The modules are in the extension folder in Opencart 4, now it is available in the root folder. When you see in the extension folder, by default there is an opencart folder and index.html, in the opencart folder, you will see all default extensions provided by default.

Files and folder structure opencart extensions
  • File name should be between 1 letter and up to 128 letters.
  • The filename should end with “
  • The uploaded file should not exceeds the max file size: 32 megabytes
  • Opencart extension installer checks if the file already exists, if it exists then it will throw an error.
  • It validates if the file can be opened and there is an install.json that can be read. So, every extension should have install.json

How to create an install.json file in Opencart extension?

Create a folder, in our example it is “showallproducts” and inside it create a file name called install.json. It supports following key: name, version, author and link. 

As per our module, following is an example:

	"name": "Show all Products OC 4",
	"version": "0.1",
	"author": "Rupak Nepali",
	"link": ""

Once install.json is inside the folder, now you can zip it and name it that ends with, then you can upload it from the Opencart extension installer.

For our example we named it and upload in Admin >> Extensions >> Installer and click upload blue button and we get details like below:

Opencart module extension installer

While uploading, if you don’t get anything then you need to go to the storage folder and inside it see the marketplace folder and remove the existing zip file.

With this you are ready to start coding and adding files for your module. Now, in our next opencart tutorial we will create all the files needed for the showallproducts module and start adding code to install it and create admin form and show the link in the header when activated.

It will contain files and folders like below:

Files and folder Opencart module

In this Opencart 4 tutorial, we set up install.json for the opencart module and upload it, and are ready to install it and create a way to add the functionalities. Please don’t forget to post your questions or comments so that we can add extra topics. You can follow us at our Twitter account @rupaknpl, and subscribe to our YouTube channel for an opencart tutorial. Click to see all Opencart 4 tutorials.

Previous articleBest Payment Gateways for eCommerce & Dropshipping in 2022
Next articleHow to add an Analytics extension in Opencart 4? Third-party JS free Opencart extension


    • On Opencart 4, they are moving away from OCMOD totally and using events everywhere.
      But I am seeing developers are using updated VQMOD

      You can achieve multiple things from events, if you still want to use OCMOD then you can use the VQMOD module and code similarly.


Please enter your comment!
Please enter your name here