Intégrer du contenu dans une page à l'aide de hooks
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 name
Description
displayHeader
Displays the content in the page's header area.
displayTop
Displays the content in the page's top area.
displayLeftColumn
Displays the content in the page's left column.
displayHome
Displays the content in the page's central area.
displayRightColumn
Displays 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 name
Description
displayHeader
Called within the HTML <head> tag. Ideal location for adding JavaScript and CSS files.
displayTop
Called in the page's header.
displayLeftColumn
Called when loading the left column.
displayRightColumn
Called when loading the right column.
displayFooter
Called in the page's footer.
displayHome
Called at the center of the homepage.
Page produit
Hook name
Description
displayLeftColumnProduct
Called right before the "Print" link, under the picture.
displayRightColumnProduct
Called right after the block for the "Add to Cart" button.
displayProductButtons
Called inside the block for the "Add to Cart" button, right after that button.
actionProductOutOfStock
Called inside the block for the "Add to Cart" button, right after the "Availability" information.
displayFooterProduct
Called right before the tabs.
displayProductTab
Called in tabs list, such as "More info", "Data sheet", "Accessories", etc.
displayProductTabContent
Called when a tab is clicked.
Page du panier
Hook name
Description
actionCartSave
Called right after a cart creation or update.
displayShoppingCartFooter
Called right below the cart items table.
displayShoppingCart
Called after the cart's table of items, right above the navigation buttons.
displayCustomerAccountFormTop
Called within the client account creation form, right above the "Your personal information" block.
displayCustomerAccountForm
Called within the client account creation form, right before the "Register" button.
actionCustomerAccountAdd
Called right after the client account creation.
displayCustomerAccount
Called on the client account homepage, after the list of available links. Ideal location to add a link to this list.
displayMyAccountBlock
Called 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.
displayMyAccountBlockfooter
Displays extra information inside the "My account" block.
actionAuthentication
Called right after the client identification, only if the authentication is valid (e-mail address and password are both OK).
actionBeforeAuthentication
Called right before authentication.
Page de recherche
Hook name
Description
actionSearch
Called 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
displayBeforeCarrier
Displayed before the carrier list on front-office.
displayCarrierList
Called 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 name
Description
displayPaymentTop
Top of payment page.
displayPayment
Called 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.
displayPaymentReturn
Called 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.
displayOrderConfirmation
A duplicate of paymentReturn.
displayBeforePayment
Called 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 name
Description
actionOrderReturn
Called when the customer request to send his merchandise back to the store, and if now error occurs.
displayPDFInvoice
Called when displaying the invoice in PDF format. Ideal location to display content within the invoice.
Hooks existants : back-office
Hooks généraux
Hook name
Description
displayBackOfficeTop
Called within the header, above the tabs.
displayBackOfficeHeader
Called between the HEAD tags. Ideal location for adding JavaScript and CSS files.
displayBackOfficeFooter
Called within the page footer, above the "Power By PrestaShop" line.
displayBackOfficeHome
Called at the center of the homepage.
Commandes et détails de la commande
Hook name
Description
actionValidateOrder
Called during the new order creation process, right after it has been created.
actionPaymentConfirmation
Called when an order's status becomes "Payment accepted".
actionOrderStatusUpdate
Called when an order's status is changed, right before it is actually changed.
actionOrderStatusPostUpdate
Called when an order's status is changed, right after it is actually changed.
actionProductCancel
Called when an item is deleted from an order, right after the deletion.
displayInvoice
Called when the order's details are displayed, above the Client Information block.
displayAdminOrder
Called when the order's details are displayed, below the Client Information block.
actionOrderSlipAdd
Called during the creation of a credit note, right after it has been created.
Produits
Hook name
Description
actionProductSave
Called when saving products.
actionUpdateQuantity
Called 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.
actionProductAttributeUpdate
Called when a product declination is updated, right after said update.
actionProductAttributeDelete
Called when a product declination is deleted.
actionWatermark
Called when an image is added to a product, right after said addition.
displayAttributeForm
Add fields to the form "attribute value".
displayAttributeGroupForm
Add fields to the form "attribute group".
displayAttributeGroupPostProcess
Called when post-process in admin attribute group.
displayFeatureForm
Add fields to the form "feature".
displayFeaturePostProcess
Called when post-process in admin feature.
displayFeatureValueForm
Add fields to the form "feature value".
displayFeatureValuePostProcess
Called when post-process in admin feature value.
Statistiques
Hook name
Description
displayAdminStatsGraphEngine
Called when a stats graph is displayed.
displayAdminStatsGridEngine
Called when the grid of stats is displayed.
displayAdminStatsModules
Called when the list of stats modules is displayed.
Clients
Hook name
Description
displayAdminCustomers
Called when a client's details are displayed, right after the list of the clients groups the current client belongs to.
Transporteurs
Hook name
Description
actionCarrierUpdate
Called 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
Last updated