Whenever I remove a product from cart page on woocommerce it scrolls to top. I managed to do that for quantity change but its not working when removing item.
this is Working with quantity change. I want to stop scrolling to top after deleting a product from cart page. Searched everywhere didn’t get any answer.
var timeout;
jQuery( function( $ ) {
$('.woocommerce').on('change', 'input.qty', function(){
if ( timeout !== undefined ) {
clearTimeout( timeout );
}
timeout = setTimeout(function() {
$("[name='update_cart']").trigger("click");
document.location.reload(true);
});
});
});
4
Answers
So, I haven't found a nice solution to this anywhere. So went into the code of woocommerce and changed some code.
Open this file wp-content/plugins/woocommerce/includes/wc-template-functions.php and search for this at line 3640.
and comment or remove this line. then it will work for change in quantity and removing items from cart and it won't scroll to top every time when you have 100's of products.
Also you don't need to use
document.location.reload(true);
for this.P.S. You have to change it every time when you update the plugin.
Try fixing it in CSS by adding
Only this worked for me, if you dont want disable woocommerce notices.
Add this code wrapped on
<script>...</script>
tag in the footer