OpenCart 3.x Event System Overview

Video transcript:

We will give an overview of the Event system in the extensions menu.

You will learn what Events are in OpenCart, how they work and what makes them so useful.

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

Here are all the core events in your OpenCart 3 installation.

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

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

Let’s explain what events are.

Events are methods that are called when an action takes place.

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

Developers can use them for assigning functionalities to your store from their extensions.

First, you have the Event code. This is an identifier which extensions use to define a group of events.

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.

Now, what makes events so useful.

Events help make the code of extensions much cleaner. This improves compatibility between different extensions and gives more stability.

Events also make module updating and debugging much simpler.

Events remove the need for modifications so there is no refreshing when you install a new extension in your store. It just works.

This is how a module with OCMOD looks like.

This is how a module with events looks like.

This sample tells OpenCart that we want to execute our function before it starts rendering the left column of the admin panel.

This is the sample that actually adds the new menu item.

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. Like our video and subscribe to the channel if you’re interested in more OpenCart 3 tutorials!

comments powered by Disqus