Modified: ps_shoppingcart.js
PrestaShop: 8.x
Theme: classic
After modified js, clear cache !
$(document).ready(function () { prestashop.blockcart = prestashop.blockcart || {}; prestashop.on( 'updateCart', function (event) { var refreshURL = $('.blockcart').data('refresh-url'); var requestData = {}; if (event && event.reason && typeof event.resp !== 'undefined' && !event.resp.hasError) { requestData = { id_customization: event.reason.idCustomization, id_product_attribute: event.reason.idProductAttribute, id_product: event.reason.idProduct, action: event.reason.linkAction }; } if (event && event.resp && event.resp.hasError) { prestashop.emit('showErrorNextToAddtoCartButton', { errorMessage: event.resp.errors.join('<br/>')}); } $.post(refreshURL, requestData).then(function (resp) { var html = $('<div />').append($.parseHTML(resp.preview)); $('.blockcart').replaceWith($(resp.preview).find('.blockcart')); /* added ps8modules */ startScroll(); /* end */ }).fail(function (resp) { prestashop.emit('handleError', { eventType: 'updateShoppingCart', resp: resp }); }); } ); }); /* added ps8modules */ function startScroll() { $('html, body').animate({scrollTop : 0}, 300, scrollTopAndShake); } function scrollTopAndShake() { var cartElement = $('.blockcart'); cartElement.attr('style', 'transition: all 100ms;'); shakeCart(cartElement); } function shakeCart(el) { el.css('margin-right', '20px'); shakeTime = 100; setTimeout(function() { el.css('margin-right','-20px'); setTimeout(function() { el.css('margin-right','10px'); setTimeout(function() { el.css('margin-right','-10px'); setTimeout(function() { el.css('margin-right','0px'); }, shakeTime); }, shakeTime); }, shakeTime); }, shakeTime); return true; } /* end */