During the search/filtration process there are many event occurs where we might require to inject our frontend logic to change the default behaviour. Wizzy Magento 2 Extension provides frontend event hooks which can be implemented to modify the default behaviour or modify the parameters.
To see the supported event hooks, check the following file.
https://github.com/wizzy-ai/wizzy-search-magento-2/blob/dev/view/frontend/web/core/page.js
You can implement the event hooks in very simple process,
- Create new file under
app/design/frontend/Theme/Namespace/Wizzy_Search/templates/common/events.phtml
Register Hook
In this file you can register any required hooks from the list to modify the config or the store behaviour. To register a hook use global wizzy variable and it’s function registerEvent. If you would like to use jQuery or any other library as dependency in these hooks implementation make sure you add them in requirejs.
Something like this,
Notes:
- Register event takes 2 parameters. One is the event type and second is callback function.
- After modifying the given parameters from callback function you must return the same.