PrestaShop 1.7 Module Hooks
In PrestaShop 1.7, modules can use hooks to execute code after various actions occur and add additional code to display in various places in the Front Office and Back Office. Hooks can be viewed on the Modules > Positions tab in the Back Office. The hooks are listed alphabetically by name in the Back Office and have a brief description.
Hooks starting with action
are executed before or after an action has occurred. Hooks starting with display
and used to add additional code to TPL files in the theme. By default, only the hooks with a Position of 1 are displayed on the Positions subtab of the Modules tab. To view all hooks, tick the Display non-positionable hooks checkbox.
To call a hook, use the code Hook::exec('name')
, where name is from the Name column below. In PrestaShop, it is convention to put the code generated by the hook in a variable called HOOK_NAME
. For example, the code to call all the modules in the Homepage content hook and then pass them into a TPL is $this->context->smarty->assign('HOOK_HOME' => Hook::exec('displayHome'));
.
Here's a list of all the module hooks available in PrestaShop v1.6 along with descriptions of what they can be used for and the parameters available to them. Parameters can be accessed like this: function hookDisplayFooterProduct($params) { $product = $params['product']; }
Name | Description | Parameters |
actionAdmin<Action>Before | Called before the specified action is performed by a Back Office controller | controller |
actionAdmin<Action>After | Called after the specified action is performed by a Back Office controller | controller, return |
actionAdmin<Class><Action>Before | Called before the specified action in the specified class is performed by a Back Office controller | controller |
actionAdmin<Class><Action>After | Called after the specified action in the specified class is performed by a Back Office controller | controller, return |
actionAdminControllerSetMedia | Called after adding media to the Back Office header | |
actionAdminLoginControllerSetMedia | Called after adding media to the Back Office login page header | |
actionAdminMetaSave | Called after saving Preferences > SEO & URLs tab | |
actionAdminMetaAfterWriteRobotsFile | Called after writing robots.txt, before closing the file | rb_data, write_fd (modifiable) |
actionAdminMetaBeforeWriteRobotsFile | Called before writing robots.txt | rb_data (modifiable) |
actionAdminOrdersTrackingNumberUpdate | Called after the tracking number update email is sent | order, customer, carrier |
actionAdminThemesControllerUpdate_optionsAfter | Called after clicking the Save button on the Design > Theme & Logo tab | |
actionAttributeDelete | Called while deleting a product attribute | id_attribute |
actionAttributeCombinationDelete | Called while deleting a product attribute combination | id_product_attribute |
actionAttributeCombinationSave | Called while saving a product attribute combination | id_product_attribute, id_attributes |
actionAttributeGroupDelete | Called while deleting a product attribute group | id_attribute_group |
actionAttributeGroupSave | Called while saving a product attribute group | id_attribute_group |
actionAttributePostProcess | Called on post-process of product attributes | id_attribute |
actionAttributeSave | Called while saving a product attribute | id_attribute |
actionAuthentication | Called after a customer successfully signs in | customer |
actionAuthenticationBefore | Called before a customer is authenticated | |
actionAjaxDieBefore | Called before the results of an AJAX request are displayed | controller, method, value |
actionAjaxDie<Controller><Method>Before | Called before the results of an AJAX request for the specified controller and method are displayed | controller, method, value |
actionBeforeCartUpdateQty | Called before the quantity of a cart product is updated | cart, product, id_product_attribute, id_customization, quantity, operator, id_address_delivery, shop, auto_add_cart_rule |
actionCarrierProcess | Called when the carrier changes during checkout | cart |
actionCarrierUpdate | Called when a carrier is updated in the Back Office | id_carrier (current), carrier (new) |
actionCartSave | Called when a product is added to the cart or the cart's contents are modified | |
actionCartSummary | Called to add variables to the cart summary | delivery, delivery_state, invoice, invoice_state, formattedAddresses, products, gift_products, discounts, is_virtual_cart, total_discounts, total_discounts_tax_exc, total_wrapping, total_wrapping_tax_exc, total_shipping, total_shipping_tax_exc, total_products_wt, total_products, total_price, total_tax, total_price_without_tax, is_multi_address_delivery, free_ship, carrier |
actionCartUpdateQuantityBefore | Called before the a product quantity is updated in the cart | cart, product, id_product_attribute, id_customization, quantity, operator, id_address_delivery, shop, auto_add_cart_rule |
actionCategoryAdd | Called when a product category is created | category |
actionCategoryDelete | Called when a product category is deleted | category, delete_children |
actionCategoryUpdate | Called when a product category is modified | category |
action<Controller>ListingFieldsModifier | Called to modify the listing query and fields for the specified controller | select (modifiable), join (modifiable), where (modifiable), group_by (modifiable), order_by (modifiable), order_way (modifiable), fields (modifiable) |
action<Controller>ListingResultsModifier | Called to modify the listing results for the specified controller | list (modifiable), list_total (modifiable) |
action<Controller>FormModifier | Called to modify the form fields and values for the specified controller | fields (modifiable), fields_value (modifiable), form_vars (modifiable) |
action<Controller>OptionsModifier | Called to modify the option fields and values for the specified controller | options (modifiable), option_vars (modifiable) |
actionCustomerAccountAdd | Called when a new customer successfully creates an account | _POST, newCustomer |
actionCustomerAddGroups | Called before adding a customer to groups | id_customer, groups |
actionCustomerBeforeUpdateGroup | Called before updating a customer's groups | id_customer, groups |
actionCustomerLogoutBefore | Called before a customer logs out | customer |
actionCustomerLogoutAfter | Called after a customer logs out | customer |
actionDeliveryPriceByPrice | Called to override the delivery price by price | id_carrier, order_total, id_zone |
actionDeliveryPriceByWeight | Called to override the delivery price by weight | id_carrier, total_weight, id_zone |
actionDispatcher | Called before running a controller | controller_type, controller_class, is_module |
actionDeleteProductInCartAfter | Called after a product is deleted from the cart | id_cart, id_product, id_product_attribute, customization_id, id_address_delivery |
actionDownloadAttachment | Called before downloading a product attachment | attachment |
actionEmailAddAfterContent | Called just after fetching a mail template | template, template_html (modifiable), template_txt (modifiable), id_lang |
actionEmailAddBeforeContent | Called just before fetching a mail template | template, template_html (modifiable), template_txt (modifiable), id_lang |
actionFeatureDelete | Called while deleting a product feature | id_feature |
actionFeatureSave | Called while saving a product feature | id_feature |
actionFeatureValueDelete | Called while deleting a product feature value | id_feature_value |
actionFeatureValueSave | Called while saving a product feature value | id_feature_value |
actionFrontControllerSetMedia | Called after adding media to a Front Office controller | |
actionGetExtraMailTemplateVars | Called to add template variables to emails | template, template_vars, extra_template_vars (modifiable), id_lang |
actionGetIDZoneByAddressID | Used to override the zone for an address | id_address |
actionGetProductPropertiesAfter | Called after getting the properties of a product | id_lang, product, context |
actionGetProductPropertiesBefore | Called before getting the properties of a product | id_lang, product, context |
actionHtaccessCreate | Called after writing the .htaccess access | |
actionInvoiceNumberFormatted | Called to override the formatted invoice number | id_lang, id_shop, number |
actionModuleInstallAfter | Called after installing a module | object |
actionModuleInstallBefore | Called before installing a module | object |
actionModuleRegisterAfter | Called after a module hook is registered | object, hook_name |
actionModuleRegisterBefore | Called before a module hook is registered | object, hook_name |
actionModuleUnRegisterAfter | Called after a module hook is unregistered | object, hook_name |
actionModuleUnRegisterBefore | Called before a module hook is unregistered | object, hook_name |
actionObjectAddBefore | Called before any object is added | object |
actionObject<Class>AddBefore | Called before any object of the specified class is added | object |
actionObjectAddAfter | Called after any object is added | object |
actionObject<Class>AddAfter | Called after any object of the specified class is added | object |
actionObjectDeleteBefore | Called before any object is updated | object |
actionObject<Class>DeleteBefore | Called before any object of the specified class is updated | object |
actionObjectDeleteAfter | Called after any object is updated | object |
actionObject<Class>DeleteAfter | Called after any object of the specified class is updated | object |
actionObjectUpdateBefore | Called before any object is updated | object |
actionObject<Class>UpdateBefore | Called before any object of the specified class is updated | object |
actionObjectUpdateAfter | Called after any object is updated | object |
actionObject<Class>UpdateAfter | Called after any object of the specified class is updated | object |
actionOnImageResizeAfter | Called after resizing an image | dst_file, file_type |
actionOnImageCutAfter | Called after cropping an image | dst_file, file_type |
actionOrderEdited | Called when an order is edited | order |
actionOrderReturn | Called when a customer returns a product | orderReturn |
actionOrderSlipAdd | Called when a credit slip is created | order, productList, qtyList |
actionOrderStatusPostUpdate | Called after the status of an order changes | newOrderStatus, id_order |
actionOrderStatusUpdate | Called before the status of an order changes | newOrderStatus, id_order |
actionPasswordRenew | Called after a customer updates their password | customer, password |
actionPaymentCCAdd | Called after an order payment is added | paymentCC |
actionPaymentConfirmation | Called after the order payment is validated | id_order |
actionPDFInvoiceRender | Called before the PDF invoice is rendered | order_invoice_list |
actionProductAdd | Called after a product is created | id_product, product |
actionProductAttributeDelete | Called after a product combination is deleted | id_product_attribute, deleteAllAttributes |
actionProductAttributeUpdate | Called after a product combination is updated | id_product_attribute |
actionProductCancel | Called after cancelling a product in an order | order, id_order_detail |
actionProductCoverage | Called when the quantity of a product is reduced from a warehouse | id_product, id_product_attribute, warehouse |
actionProductDelete | Called while a product is deleted | id_product |
actionProductOutOfStock | Used to add buttons in product.tpl when a product is out of stock | product |
actionProductSave | Called while saving products | id_product, product |
actionProductSearchComplete | Called after a faceted search is completed | label, products, sort_orders, pagination, rendered_facets, rendered_active_filters, js_enabled, current_url |
actionProductUpdate | Called after a product has been updated | id_product, product |
actionSetInvoice | Called to modify the invoice number | Order, OrderInvoice, use_existing_payment |
actionShopDataDuplication | Called when duplicating a shop | old_id_shop, new_id_shop |
actionTaxManager | Called when calculating product tax | |
actionUpdateQuantity | Called when a product quantity is updated | id_product, id_product_attribute, quantity, id_shop |
actionValidateCustomerAddressForm | Called after validating the customer address | form |
actionValidateOrder | Called when an order is validated by a payment module | cart, order, customer, currency, order_status |
actionWatermark | Called to add a watermark to a product image | id_image, id_product |
additionalCustomerFormFields | Used to add fields to the customer registration form | |
addWebserviceResources | Used to add resources to the Webservice | resources |
advancedPaymentOptions | Used to add advanced payment options | |
dashboardZoneOne | Used to add a module to the left column of the dashboard | date_from, date_to |
dashboardZoneTwo | Used to add a module to the right column of the dashboard | date_from, date_to |
displayAdminCustomers | Used to add a block when viewing a customer in the Back Office | id_customer |
displayAdminOrder | Used to add a block above the products block when viewing an order in the Back Office | id_order |
displayAdminOrderContentOrder | Used to add a new tab content before the Status tab when viewing an order in the Back Office | order, products, customer |
displayAdminOrderContentShip | Used to add a new tab content before the Shipping Address tab when viewing an order in the Back Office | order, products, customer |
displayAdminOrderTabOrder | Used to add a tab before the Status tab when viewing an order in the Back Office | order, products, customer |
displayAdminOrderTabShip | Used to add a tab before the Shipping Address tab when viewing an order in the Back Office | order, products, customer |
displayAdminProductsExtra | Used to add options to the "Modules options" tab on the product editor | id_module |
displayAdminStatsGraphEngine | Used to add a new graph engine when rendering stats | |
displayAdminStatsGridEngine | Used to add a new grid engine when rendering stats | |
displayAdminStatsModules | Used to add a new subtab to the Stats tab in the Back Office | |
displayAfterBodyOpeningTag | Used to add content after the <body&rt; tag. | |
displayAfterCarrier | Used to add content after the carrier list in the Front Office | cart |
displayAttributeForm | Used to add a new field when editing product attributes | id_attribute |
displayAttributeGroupForm | Used to add a new field when editing product attribute groups | id_attribute_group |
displayAttributeGroupPostProcess | Used to add code to post-process when saving product attribute groups | errors (modifiable) |
displayBackOfficeCategory | Used by the "Categories block" module to add category thumbnails when editing categories | |
displayBackOfficeFooter | Used to add content to the right side of the Back Office footer | |
displayBackOfficeHeader | Used to add media to the <head> tag in the Back Office | |
displayBackOfficeHome | Used to add content to the Back Office homepage | |
displayBackOfficeTop | Used to add content to the right side of the Back Office header | |
displayBeforeCarrier | Used to add content before the carrier list in the Front Office | cart |
displayBeforeBodyClosingTag | Used to add content before the <body> | |
displayCarrierExtraContent | Used to add content below a carrier on the checkout pages | carrier |
displayCarrierList | Used to add extra carriers on the checkout page | address |
displayCustomerAccount | Used to add links to the customer account page | |
displayCustomerAccountForm | Used to add fields to the bottom of customer registration form in the Front Office | |
displayCustomerAccountFormTop | Used to add fields to the top of the customer registration form in the Front Office | |
displayCustomization | Used to override the a customization value | customization |
displayFeatureForm | Used to add fields when editing product features | id_feature |
displayFeaturePostProcess | Used to add code to post-process when saving product features | errors (modifiable) |
displayFeatureValueForm | Used to add fields when editing product feature values | id_feature_value |
displayFeatureValuePostProcess | Used to add code to post-process when saving product feature values | errors (modifiable) |
displayFooter | Used to add blocks to the footer in the Front Office | |
displayFooterProduct | Used to add blocks on the product page under the description | product, category |
displayHome | Used to add blocks to the homepage in the Front Office | |
displayInvoice | Used to add content to the top of the order page in the Back Office | id_order |
displayInvoiceLegalFreeText | Used to modify the legal free text on PDF invoices | id_order |
displayLeftColumn | Used to add blocks to the left column in the Front Office | |
displayLeftColumnProduct | Used to add content to the left column of the product page in the Front Office | |
displayMaintenance | Used to add content below the logo on the maintenance page | |
displayMyAccountBlock | Used to add links to the "My account block" in the left or right column | |
displayNav | Used to add content to the navigation bar at the top of the Front Office | |
displayNavFullWidth | Used to add a full width navigation menu at the top of the page | |
displayOrderConfirmation | Called before the order confirmation page is displayed | order |
displayOrderDetail | Used to add content above the products in the order detail in the Front Office | order |
displayOverrideTemplate | Used to override the template of the current Front Office controller | controller |
displayPaymentEU | Used to add EU payment options | |
displayPaymentReturn | Used to add code before the payment return page is displayed | order |
displayPaymentTop | Used to add content to the top of the payment page | |
displayPDFInvoice | Used to add content to the bottom of PDF invoices | object |
displayProductButtons | Used to add action buttons to the product page in the Front Office | product |
displayProductExtraContent | Used to add tabs and content to the product page | products |
displayProductListFunctionalButtons | Used to add buttons to each product in listings in the Front Office | product |
displayRightColumn | Used to add blocks to the right column in the Front Office | cart |
displayRightColumnProduct | Used to add content to the right column of the product page in the Front Office | |
displayShoppingCart | Used to add additional action buttons to the shopping cart on the checkout page | delivery, delivery_state, invoice, invoice_state, formattedAddresses, products, gift_products, discounts, is_virtual_cart, total_discounts, total_discounts_tax_exc, total_wrapping, total_wrapping_tax_exc, total_shipping, total_shipping_tax_exc, total_products_wt, total_products, total_price, total_tax, total_price_without_tax, is_multi_address_delivery, free_ship, carrier |
displayShoppingCartFooter | Used to add content below the shopping cart on the checkout page | delivery, delivery_state, invoice, invoice_state, formattedAddresses, products, gift_products, discounts, is_virtual_cart, total_discounts, total_discounts_tax_exc, total_wrapping, total_wrapping_tax_exc, total_shipping, total_shipping_tax_exc, total_products_wt, total_products, total_price, total_tax, total_price_without_tax, is_multi_address_delivery, free_ship, carrier |
displayTop | Used to add content to the top of the page in the Front Office | |
displayTopColumn | Used to add content to the top of the center column in the Front Office | |
Header | Used to add media to the <head> tag in the Front Office | |
overrideMinimalPurchasePrice | Used to override the minimum purchase price | minimalPurchase (modifiable) |
paymentOptions | Used to add a payment option to the checkout page | |
termsAndConditions | Used to add terms and conditions to the checkout page | |
updateProduct | Called after updating a product | id_product |
validateCustomerFormFields | Used to validate customer form fields the module has created | fields |