PrestaShop 1.7 entrance workplace has a scientific occasion system which “emits” some occasions. Moreover, we will use these occasions to determine consumer actions.
As an illustration, a consumer modifications mixture in product web page. Due to this fact the mixture and picture template is up to date. After that it emits “updatedProduct” occasion. You should use this occasion to seize this motion and determine the up to date mixture.
To make clear, these occasions are just like hooks system in PrestaShop core lessons. As you’ll be able to add PrestaShop core hooks to carry out your motion within the module. Equally, you should use theme occasions to determine consumer actions and carry out your required course of.
The best way to use
These occasions emit with “prestashop” object in JS. So we are going to use the identical object to use hook on these occasions:
prestashop.on("updatedProduct", perform(response) {
// The mixture is modified
// "response" argument has information associated to this occasion
// Carry out your motion
});
The argument within the callback perform is elective. You possibly can add this everytime you want the occasion response information in your callback.
Checklist of all occasions
Right here is the checklist of occasions to determine consumer actions which might be accessible in core js of PrestaShop as per newest model:
Occasion Title | Pages | Motion |
updateCart | Itemizing pages, Product web page and cart web page. | Add product to cart and cart amount updates. |
updatedCart | Cart web page | After cart complete abstract template is up to date. |
changedCheckoutStep | Checkout web page | When consumer clicks any reachable checkout step. |
editAddress | Checkout web page (Order remaining abstract) | When consumer clicks edit tackle order remaining abstract. |
updatedDeliveryForm | Checkout web page | When consumer modifications delivery choice in checkout. |
editDelivery | Checkout web page (Order remaining abstract) | When consumer clicks to edit delivery choice order remaining abstract. |
updateProductList | Itemizing pages | When the product checklist is up to date on account of filter or sorting change |
clickQuickView | Itemizing pages | When buyer clicks on fast view of a product. |
updateProduct | Product web page | As quickly as buyer clicks on mixture to vary. |
updatedProduct | Product web page | When product template is up to date on mixture change. |
updatedAddressForm | Handle kinds (Addresses and checkout web page) | When consumer modifications the nation and state checklist updates. |
handleErrors | All pages | To deal with errors in any of the above occasions. |