简体   繁体   中英

Prestashop - how to catch cart update

I'm writing a module to Prestashop. My module adds a small widget on cart view. The content of widget depends on cart content. My question is how to update my widget when user changes quantity of product or removes product from cart. This action is done via AJAX, so page is not refreshed and my widget is not refreshed as well. It would by nice find solution that doesn't require changes in templates - installing module should by enough.

Thanks, amos

I am using PrestaShop 1.7 and have used the following code to grab the response and update my cart icon.

Documentation can be found here: http://developers.prestashop.com/themes/javascript/index.html

prestashop.on('updatedCart', function(event) { $('.nav-container .shopping-cart .shopping-cart-icon-count').text(this.cart.products_count) });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM