PrestaShop 1.5 … hooks, hooks everywhere!

Ever faced the need to put something in a PS theme but you don’t have an hook that you can use?

If the answer is yes don’t despair!

You can create your custom hooks (in your custom modules) and then call them directly anywhere you want in your theme.

Just like this:

{hook h='hookName'}

And here’s the definition of your hook (i.e. a public method) in your custom module (i.e. a class extending the abstract ModuleCore class):

public function hookName($params)
  return 'hi there!';

Simple isn’t it? 🙂

Just remember to register the new custom hook during the module installation:

public function install()
  return parent::install() && $this->registerHook('hookName');

Here you can find a more detailed explanation by Nemo which owns the credits for what I presented here!

Leave a Reply

Please Login to comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.