Use a Module to Call a Hook
Posted: Thu Sep 10, 2026 8:54 am
You aren't confined to whatever Hooks exist in Core Code. You can add your own Hooks.
Here is a real example - I recently created a `Call To Action` addon which shows in the Product Info page a bit like this;
The addon has a layout module for the product_info page and a number of hooks which each create a different message, but only one message shows based on a priority you decide. For example "low stock BUY NOW" hook might have a more important priority than "free shipping" hook.
--
Using a module to trigger a hook is a smart way to add features to your site without changing Core Code.
The Module is like a light switch on your wall. It controls when something is turned on or off.
The Hook is the lightbulb. It does the actual work (choosing which message should display).
If you flip the switch off (disable the layout module in your admin panel), the lightbulb never turns on. You don't have to unscrew any wires or change core code - it just stops showing up on the page.
--
How It Works (Step-by-Step)
The Module handles where and when the execution happens (e.g., controlling position/sort order on the Product Info layout). The Hook handles what actually happens (e.g., querying databases, evaluating user conditions, etc).
Here is a real example - I recently created a `Call To Action` addon which shows in the Product Info page a bit like this;
The addon has a layout module for the product_info page and a number of hooks which each create a different message, but only one message shows based on a priority you decide. For example "low stock BUY NOW" hook might have a more important priority than "free shipping" hook.
--
Using a module to trigger a hook is a smart way to add features to your site without changing Core Code.
The Module is like a light switch on your wall. It controls when something is turned on or off.
The Hook is the lightbulb. It does the actual work (choosing which message should display).
If you flip the switch off (disable the layout module in your admin panel), the lightbulb never turns on. You don't have to unscrew any wires or change core code - it just stops showing up on the page.
--
How It Works (Step-by-Step)
- You turn on the Layout Module in your admin dashboard.
You decide where on the product page it should live (Sort Order, Slot, Width etc). - The Module calls your Hook.
Instead of building the message itself, the module simply tells your site, "Hey, trigger the CTA Hook right here!" - The Hook builds the message.
The hook runs its code, checks if there’s a special offer for that product, and generates the message. - Your product_info page displays your Call To Action.
- Safe Updates:
You never touch core files. When software updates come out, your site won't break. - One-Click On/Off:
Want to temporarily hide your Call To Action box? Turn off the module in the admin area, and the hook completely stops running. No leftover code or broken spaces on your page. - Clean & Flexible:
The module decides where the message goes, while the hook decides what the message says.
The Module handles where and when the execution happens (e.g., controlling position/sort order on the Product Info layout). The Hook handles what actually happens (e.g., querying databases, evaluating user conditions, etc).