Hooks are how modules interact with PrestaShop without modifying core files. Understanding which hook to use, when it fires, and what data it provides is essential knowledge for every PrestaShop developer. This reference covers the hooks you will use most often.
Display Hooks vs. Action Hooks
PrestaShop has two types of hooks:
- Display hooks (prefix:
display) — render content at specific positions in the page. Your hook method returns HTML. Example:displayHeader,displayProductAdditionalInfo - Action hooks (prefix:
action) — triggered when something happens. Your hook method performs logic but returns nothing visible. Example:actionCartSave,actionOrderStatusPostUpdate
Front Office Display Hooks
Page Structure
displayHeader— inside<head>. Add CSS, meta tags, JS references. Fires on every front page.displayTop/displayNavFullWidth— top navigation area. Banners, announcements.displayHome— homepage content area. Featured products, sliders, promotions.displayFooter/displayFooterBefore— footer content. Newsletter signup, trust badges.
Product Page
displayProductAdditionalInfo— below the add-to-cart button. Delivery estimates, stock warnings.displayProductExtraContent— adds tabs to the product page. Returns aPrestaShop\PrestaShop\Core\Product\ProductExtraContentobject.displayAfterProductThumbs— below product images. Additional media, 360-degree views.displayProductListReviews— in product listings, below each product. Star ratings.
Cart and Checkout
displayShoppingCartFooter— below the cart table. Cross-sell suggestions.displayPaymentReturn— order confirmation page. Thank you messages, tracking info.displayOrderConfirmation— also on order confirmation. Analytics tracking scripts.
Key Action Hooks
Cart Events
actionCartSave— fires after any cart modification. Use for real-time stock checks or price recalculations.actionCartUpdateQuantityBefore— before quantity changes. Allows you to validate or block the change.
Order Events
actionValidateOrder— fires when an order is created. Contains the full order object, cart, customer, and currency.actionOrderStatusPostUpdate— after an order status change. Trigger notifications, update external systems, adjust stock.actionPaymentConfirmation— when payment is confirmed. Different from order validation for deferred payment methods.
Customer Events
actionCustomerAccountAdd— new customer registration. Sync to CRM, trigger welcome email.actionAuthentication— customer logs in. Update last login, sync session data.
Product Events
actionProductSave— product created or updated. Sync to feeds, update caches.actionProductDelete— product removed. Clean up related module data.actionUpdateQuantity— stock level changes. Trigger low-stock alerts, update availability.
Dynamic Hooks (PS 1.7.7+)
PrestaShop generates hooks dynamically based on entity and action:
action{Entity}{Action}Before
action{Entity}{Action}After
For example: actionProductFormBuilderModifier lets you add fields to the product edit form in the admin panel.
The setMedia Hook
actionFrontControllerSetMedia is the correct place to register CSS and JavaScript files. Unlike displayHeader, it fires before the page renders and provides the controller context:
public function hookActionFrontControllerSetMedia($params)
{
$controller = $this->context->controller;
if ($controller instanceof ProductController) {
$this->context->controller->registerStylesheet(
'my-module-css',
'modules/' . $this->name . '/views/css/product.css'
);
}
}
Common Pitfalls
- Heavy database queries in display hooks — display hooks fire on every page load. Cache your queries or use lazy loading.
- Registering hooks you do not use — each registered hook adds overhead, even if the method returns nothing.
- Forgetting
registerHook()ininstall()— hooks must be registered during module installation. Missing this is the #1 reason hooks do not fire. - Not checking the controller class — if your hook should only run on product pages, check
instanceof ProductControllerbefore doing work.
Hooks are powerful but require discipline. Use the right hook for the right job, keep your hook methods fast, and always test with cache enabled to catch performance issues early.
Comments (2)
Leave a comment