Definition of a Hook
A Hook (or anchor point) is one of the fundamental mechanics underlying the entire PrestaShop architecture. Hooks are specific snippets of code, strategically placed within the theme or the CMS core, that allow external modules to "hook into" or attach themselves to execute functions or display visual content. This is done without any need to modify the website's original source code.
How Hooks Work: Display vs. Action
To grasp PrestaShop's flexibility, it is essential to divide Hooks into two main macro-categories based on their purpose:
- Display Hooks (Visual): These are tied to the Front Office, meaning what the customer sees. For instance, the
displayHomehook represents the central area of the homepage;displayHeaderis at the top of the site;displayLeftColumnmanages the sidebar. A "Featured Products" module uses a display hook to print the item grid exactly where the developer placed that anchor in the theme. - Action Hooks (Invisible): These are invisible to the end-user but crucial for the e-commerce logic. They trigger when a specific event occurs. For example, the
actionOrderStatusPostUpdatehook fires the exact moment an order changes from "Pending" to "Paid." An electronic invoicing module will leverage this hook to automatically generate the PDF and send it to the accounting system.
Managing Hooks in the Back Office (Positions)
PrestaShop provides administrators with a visual and intuitive tool to manage these anchors, accessible via the Design > Positions menu. From this interface, you can view the complete list of available hooks and all the modules currently attached to each.
A very common operation is Transplanting. If you bought a customer review module that appears at the bottom of the page by default, you can use the "Transplant a module" function to unhook it from that position and attach it to the right column by simply selecting the new destination hook from a dropdown menu. You can also change the display order (vertical sorting) of multiple modules attached to the same hook by dragging and dropping them.
The Technical Advantage: Security and Upgrades
Using the Hook system is the absolute best practice in modular web development. In the past, to add a banner to a homepage, developers would open HTML files and manually paste the code. This made it impossible to update the theme or CMS without losing customizations.
Thanks to hooks, the PrestaShop core and theme files remain intact and isolated (Clean Code). When performing a version upgrade, original files are safely overwritten with new ones, but because your modules are merely "hanging" via hooks, they will continue to function perfectly. This drastically reduces maintenance costs and ensures maximum structural stability for the online store.