By default, PrestaShop allows you to create modules designed to interact with different parts of your e-commerce store. This can be hugely beneficial for expanding the functionality of your website, but what if there is a module, even your own if you’re a developer, that can’t be placed exactly where you would like them to go? Custom hooks!
‘Display’ and ‘Action’ hooks are available throughout the store and allow you retrieve events or change the display.
- Display hooks (show something – for example show a module in a column)
- Action hooks (do something – for example send an email after an action)
While there are many, many hooks to attach to within Prestashop, there is always the option to create your own.
Adding a display hook is very simple, and can be placed anywhere in a .tpl file.
Now, within the code of your module, you will need to follow the standard practice of registering a hook on install of the module:
public function install()
Use the “registerHook” method, which accepts the name of the hook as it’s only argument. You don’t necessarily need to remove the hook on uninstallation.
From here you can create your display function following standard module development rules (more details can be found here):
public function hookDisplayMyHookName($params)
// Your code here
return ‘display file’;
Now, when you install your module, your content will be showing where you placed your custom hook within the .tpl. Don’t panic if your content is not showing up straight away, it is most likely a caching issue – We need to recompile the cache so our changes are shown. Simply go to Advanced Parameters > Performance – at the top right, click on clear cache, and turn on Force Compilation (this can be changed back once changes are showing). Now refresh your page and your changes should be visible!
It’s also worth noting, once your hook has been registered in the system, it is available for you to transplant other modules to.
A very simple process for truly customising your e-commerce site!