Replies: 2 comments
-
That's exactly the kind of functionality I need right now (developing a module for OpenCart 3). Any way to simulate that of course without touching the core files? I want my module to get notified before |
Beta Was this translation helpful? Give feedback.
-
It can be done, using event handlers in controllers and decorators for library classes. When I have some time I'll publish a little document on how to do it. |
Beta Was this translation helpful? Give feedback.
-
The Event library allows us to use it as a hook to change the inner process/data in another library, controller, and model methods. It would be great if we start adding the event hook in OpenCart 4, to complement the event middleware "before/after".
Tested on OpenCart v4.0.1.1, this event hook example allows multiple 3rd extensions to change the Cart library
getProducts()
.Add two event hooks as a start in the file
system/library/cart/cart.php
Edit
catalog/controller/common/home.php
for a quick test, by adding the following methods:Results:
Beta Was this translation helpful? Give feedback.
All reactions