Page 1 of 1

OpenCart Events

Posted: Wed Dec 16, 2020 10:23 pm
by OSWorX
Since OpenCart Version 2.x there is a new way to add and edit already existing code (see array $data and string $route).
And as well the already parsed HTML $output when used with after.

This is called events and the core princip is explained here: https://github.com/opencart/opencart/wiki/Events-System

Events should replace the so well used VQMod and OCMod system.
Files using those 2, are based on xml-files and the manipulated files are stored as flat files.
While files affected by events are stored in the database only.

This thread here should be a place where everybody should post the experience with events.
And also a place where everybody can ask and add ideas, solutions and samples.

Extensions and Developers should prefer to use events rather the old VQ- & OCMod-system.
Events are constantly developed and extended and will provide a future proof solution.
The more OpenCart 4.x is in sight ..

Here are a few links which explain what Events are and how they work and can be used:
https://www.opencart.com/blog?blog_id=174
https://www.opencart.com/blog?page=7&blog_id=215
https://stackoverflow.com/questions/264 ... art-events
https://extensioncart.com/posts/writing ... ith-events

How to modify .twig template files: viewtopic.php?f=144&t=221533#p807608

Re: OpenCart Events

Posted: Wed Dec 16, 2020 10:33 pm
by straightlight
OSWorX wrote:
Wed Dec 16, 2020 10:23 pm
Since OpenCart Version 2.x there is a new way to add and edit already existing code (see arrays $data and $route).
And as well the already parsed HTML $output when used with after.

This is called events and the core princip is explained here: https://github.com/opencart/opencart/wiki/Events-System

Events should replace the so well used VQMod and OCMod system.
Files using those 2, are based on xml-files and the manipulated files are stored as flat files.
While files affected by events are stored in the database only.

This thread here should be a place where everybody should post the experience with events.
And also a place where everybody can ask and add ideas, solutions and samples.

Extensions and Developers should prefer to use events rather the old VQ- & OCMod-system.
Events are constantly developed and extended and will provide a future proof solution.
The more OpenCart 4.x is in sight ..
Couldn't agree more on that with the exception on the request size an OP could bring to share the Events. Based on the size, Commercial Support should be handling those claims.

Re: OpenCart Events

Posted: Tue Nov 15, 2022 6:50 pm
by devmiqbal
Can anyone please share a tutorial to capture the product add/update and product add to cart and cart update events implementation in OpenCart V4.
I was using that events by implementing them in install.xml, but I am not getting any clue how to implement them in v4.
Please help

Re: OpenCart Events

Posted: Tue Nov 15, 2022 9:19 pm
by JNeuhoff
devmiqbal wrote:
Tue Nov 15, 2022 6:50 pm
Can anyone please share a tutorial to capture the product add/update and product add to cart and cart update events implementation in OpenCart V4.
I was using that events by implementing them in install.xml, but I am not getting any clue how to implement them in v4.
Please help
This question has been discussed on github for OpenCart 4.

When I have some time I'll publish an article on how to modify library classes using event handlers.

Re: OpenCart Events

Posted: Tue Nov 15, 2022 9:45 pm
by devmiqbal
You are talking about this one https://github.com/opencart/opencart/wiki/Events-System ?
or send me the git link so I can check.

Re: OpenCart Events

Posted: Wed Nov 16, 2022 5:52 am
by JNeuhoff