Jump to content

Hook to refresh content displayed by module on Shopping Cart Page


Recommended Posts

In prestashop 1.7, I have a module that displays content on the shopping cart page (hook displayShoppingCartFooter). I want to refresh what is displayed after the cart is updated (e.g. changed quantity, delete item). What hook can I use for the same or how can I trigger the refresh after the cart has been updated (the content displayed by my module depends on the cart contents, so this should happen after the cart is updated). afterCartSave hook does not help.

 

Any guidance?

 

Thanks!

Link to comment
Share on other sites

you can use emitter 'on cart update', and then - do an ajax request to your module and update the contents http://developers.prestashop.com/themes/javascript/index.html

 

 

updatedCart On the cart page, everytime something happens (change quantity, remove product and so on) the cart is reloaded by ajax call. After the cart is updated, this event is triggered.
Link to comment
Share on other sites

  • 2 years later...
  • 4 years later...
  • 8 months later...
On 12/5/2023 at 3:03 PM, mangeur de fleurs said:

Hello,

have you find a solution to your problem ?

$(document).ready(function () {
     
    if (typeof prestashop !== 'undefined') {
      prestashop.on(
        'updateCart',
        function (event) {
          if (event && event.resp ) {

// here you do some modifications as you want. Like doing ajax calls, add classes to divs, hide elements...

//you can examine the event for available values (event.resp.cart ie.)            
          }
        }
      );
    }

});

You have to add this code within your own module or extend the module you want to behave different...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...