Child pages
  • Integrating content in a page using hooks
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Current »

Table of contents

Integrating content in a page using hooks

Hooks are a way to attach your code to some specific PrestaShop events.

Most of the time, they are used to insert content in a page.

For instance, the PrestaShop default theme's home page has the following hooks:

Hook nameDescription
displayHeaderDisplays the content in the page's header area.
displayTopDisplays the content in the page's top area.
displayLeftColumnDisplays the content in the page's left column.
displayHomeDisplays the content in the page's central area.
displayRightColumnDisplays the content in the page's right column.
displayFooter

Displays the content in the page's footer area.

Hooks can also be used to perform specific actions under certain circumstances (i.e. sending an e-mail to the client).

Existing hooks: front-office

Home page and general site pages

Hook nameDescription
displayHeaderCalled within the HTML <head> tag. Ideal location for adding JavaScript and CSS files.
displayTopCalled in the page's header.
displayLeftColumnCalled when loading the left column.
displayRightColumnCalled when loading the right column.
displayFooterCalled in the page's footer.
displayHomeCalled at the center of the homepage.

Product page

Hook nameDescription
displayLeftColumnProductCalled right before the "Print" link, under the picture.
displayRightColumnProductCalled right after the block for the "Add to Cart" button.
displayProductButtonsCalled inside the block for the "Add to Cart" button, right after that button.
actionProductOutOfStockCalled inside the block for the "Add to Cart" button, right after the "Availability" information.
displayFooterProductCalled right before the tabs.
displayProductTabCalled in tabs list, such as "More info", "Data sheet", "Accessories", etc.
displayProductTabContentCalled when a tab is clicked.

Cart page

Hook nameDescription
actionCartSaveCalled right after a cart creation or update.
displayShoppingCartFooterCalled right below the cart items table.
displayShoppingCartCalled after the cart's table of items, right above the navigation buttons.
displayCustomerAccountFormTopCalled within the client account creation form, right above the "Your personal information" block.
displayCustomerAccountFormCalled within the client account creation form, right before the "Register" button.
actionCustomerAccountAddCalled right after the client account creation.
displayCustomerAccountCalled on the client account homepage, after the list of available links. Ideal location to add a link to this list.
displayMyAccountBlockCalled within the "My account" block, in the left column, below the list of available links. This is the ideal location to add a link to this list.
displayMyAccountBlockfooterDisplays extra information inside the "My account" block.
actionAuthenticationCalled right after the client identification, only if the authentication is valid (e-mail address and password are both OK).
actionBeforeAuthenticationCalled right before authentication.

Search page

Hook nameDescription
actionSearchCalled after a search is performed. Ideal location to parse and/or handle the search query and results.

Carrier choice page

Hook name

Description

displayBeforeCarrierDisplayed before the carrier list on front-office.
displayCarrierListCalled after the list of available carriers, during the order process. Ideal location to add a carrier, as added by a module.

Payment page

Hook nameDescription
displayPaymentTopTop of payment page.
displayPaymentCalled when needing to build a list of the available payment solutions, during the order process. Ideal location to enable the choice of a payment module that you have developed.
displayPaymentReturnCalled when the user is sent back to the store after having paid on the 3rd-party website. Ideal location to display a confirmation message or to give some details on the payment.
displayOrderConfirmationA duplicate of paymentReturn.
displayBeforePaymentCalled when displaying the list of available payment solutions. Ideal location to redirect the user instead of displaying said list (i.e., 1-click PayPal checkout).

Order page

Hook nameDescription
actionOrderReturnCalled when the customer request to send his merchandise back to the store, and if now error occurs.
displayPDFInvoiceCalled when displaying the invoice in PDF format. Ideal location to display content within the invoice.

Existing hooks: back-office

General hooks

Hook nameDescription
displayBackOfficeTopCalled within the header, above the tabs.
displayBackOfficeHeaderCalled between the HEAD tags. Ideal location for adding JavaScript and CSS files.
displayBackOfficeFooterCalled within the page footer, above the "Power By PrestaShop" line.
displayBackOfficeHomeCalled at the center of the homepage.

Orders and order details

Hook nameDescription
actionValidateOrderCalled during the new order creation process, right after it has been created.
actionPaymentConfirmationCalled when an order's status becomes "Payment accepted".
actionOrderStatusUpdateCalled when an order's status is changed, right before it is actually changed.
actionOrderStatusPostUpdateCalled when an order's status is changed, right after it is actually changed.
actionProductCancelCalled when an item is deleted from an order, right after the deletion.
displayInvoiceCalled when the order's details are displayed, above the Client Information block.
displayAdminOrderCalled when the order's details are displayed, below the Client Information block.
actionOrderSlipAddCalled during the creation of a credit note, right after it has been created.

Products

Hook nameDescription
actionProductSaveCalled when saving products.
actionUpdateQuantityCalled during the validation of an order, the status of which being something other than "canceled" or "Payment error", for each of the order's items.
actionProductAttributeUpdateCalled when a product declination is updated, right after said update.
actionProductAttributeDeleteCalled when a product declination is deleted.
actionWatermarkCalled when an image is added to a product, right after said addition.
displayAttributeFormAdd fields to the form "attribute value".
displayAttributeGroupFormAdd fields to the form "attribute group".
displayAttributeGroupPostProcessCalled when post-process in admin attribute group.
displayFeatureFormAdd fields to the form "feature".
displayFeaturePostProcessCalled when post-process in admin feature.
displayFeatureValueFormAdd fields to the form "feature value".
displayFeatureValuePostProcessCalled when post-process in admin feature value.

Statistics

Hook nameDescription
displayAdminStatsGraphEngineCalled when a stats graph is displayed.
displayAdminStatsGridEngineCalled when the grid of stats is displayed.
displayAdminStatsModulesCalled when the list of stats modules is displayed.

Clients

Hook nameDescription
displayAdminCustomersCalled when a client's details are displayed, right after the list of the clients groups the current client belongs to.

Carriers

Hook nameDescription
actionCarrierUpdateCalled during a carrier's update, right after said update.

Visual location of the main hooks

One of the main aspects of integrating content from PrestaShop in your theme is to know where your content will be displayed, and therefore where exactly are the hooks and modules located.

This section presents a visual representation of their location on the home page. It gives you:

  • the block's name.
  • the block's identifier, in order to properly target it using CSS.
  • the block's folder or its template file, should you wish to edit it.

Main content zones

Page header

Left column

Central area

Right column

Categories

  • No labels