5 Advantages of Events vs OCMOD in OpenCart 3.0

First, there was vQmod. It allowed creating scripts that override the code during execution time.

Then, OCMOD was created. It was a simplified version of vQmod, which eliminated some of its limitations.

Let’s talk about something much simpler.

Something that will not cause confusion for users anymore and eliminate issues with compatibility, debugging and so on.

The Event system in OpenCart 3.0 is a significant improvement over OCMOD, which was dominating modifications and extensions before the newest version of the platform was released.


"Our life is frittered away by detail. Simplify, simplify!"

Henry David Thoreau, Author


Let’s explain what Events are in OpenCart, how they work and what makes them so useful.

Why Should I Use Events for OpenCart Development?

Events are a new system introduced in OpenCart and a promising future for extension development.

Essentially, they are a way to hook an action to different triggers in OpenCart so you modify the behavior of the online store.

When compared to OCMOD, Events offer:

1. Cleaner Code

No need for modifications and OCMODs which are harder to write, support and debug.

2. More Stability

OCMOD relies that a piece of code should be present, which is harder to ensure when more than one modifications are applied.

3. Easier Updates

Some modules might cause clashes when their new versions are installed in your store. Events have a smaller risk with clashes when you update your OpenCart extensions.

4. Improved Compatibility

OCMOD limits compatibility between different extensions since they use different modifications that are usually not developed to work together.

5. Simpler Debugging

You can disable events and figure out which of them causes a problem and there’s no need to refresh modifications while doing small changes during the debugging process. Otherwise, you need to refresh modifications with every change you make while debugging OCMOD.

We recommend the use of Events more than OCMOD due to all these reasons.

Breakdown of the Events

To view the events, go to your dashboard and click on extensions. The events section is at the bottom.

The event table lets you see all the registered events in your store. This is where you enable and disable them.

This is useful when debugging a problem and understand which part of your store is malfunctioning.

Events are actions that are called when a trigger is reached in the code execution process.

In other words, you can specifically define the moment when you want your custom function to run in your OpenCart store.

First, you have the Event code.

This is an identifier used by extensions to define a group of events. The group usually resembles the name of the extension that adds the event.

Then you have the trigger. It signifies the exact place in your code when the event is fired.

And finally you have the action - the exact functionality that the event will execute.

Using Events for Modifying OpenCart

Depending on the Event trigger, the actions can take different number of arguments.

These arguments can modify or return a value, which OpenCart will use instead of the default functionality.

The arguments an action can take depend on the type of trigger that they are hooking to.

For example actions hooked to a /before trigger will usually take 2 arguments, and actions hooked to /after trigger will usually take 3 arguments, the third being the results from OpenCart’s default functionality that the event is hooking to.

Events hooked /after model functionality, will usually have the third argument being the data that the model action is supposed to return.

This gives  you an opportunity to modify the data, before it gets to the caller of the model function.

The /before triggers on the other hand are a good place to replace a default functionality altogether.

For example if you use a /before trigger, you can use your custom logic to get the data from the Database skipping OpenCart’s default logic.

Event File Structure

The file structure needed for building an event-based extension needs the following:

  • 1 Admin controller

  • 1 Catalog controller

  • 1 Language file for the admin (optional)



With all of that said, we strongly recommend all OpenCart developers to start using the event system in the new OpenCart 3 and start switching from OCMOD or vQmod. So that’s the essence of the events. If you have any questions, let us know in the comments below.

Join 11,000+ subscribers receiving actionable E-commerce advice

* Unsubscribe any time

Trending blogs

comments powered by Disqus