Child pages
  • Intégrer du contenu dans une page à l'aide de hooks
Skip to end of metadata
Go to start of metadata

Contenu

Intégrer du contenu dans une page à l'aide de hooks

Les points d'accroche, ou "hooks", permettent d'associer votre code à des évènements propres à PrestaShop.

La plupart du temps, ils sont utilisés pour insérer du contenu dans la page.

Par exemple, le thème par défaut de PrestaShop dispose des hooks suivants :

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.

Les hooks peuvent également être utilisés pour lancer des actions précises en fonction des circonstances (par exemple, envoyer un e-mail au client).

Hooks existants : front-office

Page d'accueil et pages générales du site

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.

Page produit

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.

Page du panier

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.

Page de recherche

 

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

Page de choix du transport

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.

Page de paiement

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).

Page de commande

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.

Hooks existants : back-office

Hooks généraux

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.

Commandes et détails de la commande

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.

Produits

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.

Statistiques

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.

Transporteurs

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

Visualiser l'emplacement des principaux hooks

L'un des principaux aspects de l'intégration du contenu de PrestaShop dans votre thème, consiste à savoir où votre contenu sera affiché, et donc à savoir où exactement se trouvent les hooks et modules.

Cette section vous donne une représentation visuelle de leur position sur la page d'accueil. Elle vous indique

  • le nom du bloc ;
  • l'identifiant du bloc, afin de le cibler en CSS ;
  • le dossier du bloc ou son fichier template, si vous souhaitez le modifier.

Zones principales de contenu

En-tête de la page

Colonne de gauche

Zone centrale

Colonne de droite

Catégories

  • No labels