Page 1 of 1

[SOLVED] - Disable scroll to top when adding product to cart

Posted: Thu Mar 05, 2020 10:09 pm
by Dutch Pride Code
How do I disable scroll to top on all pages when users add a product to cart?

Already removed the below code (three times) from common.js in the catalog theme folder as suggested by other topics on the forum.

Code: Select all

$('html, body').animate({ scrollTop: 0 }, 'slow');
This works on category pages but the page still scrolls on the home page when adding something from the "recommended products" module.

Anyone knows what to do about this?

OC 3.0.3.2
PHP 7.2.10
Default theme

Re: Disable scroll to top when adding product to cart

Posted: Thu Mar 05, 2020 10:24 pm
by Johnathan
There's at least one more instance of that code in this file, triggered by adding the product to the cart on the product page:

/catalog/view/theme/default/template/product/product.twig

Beyond that, you should check the other template files for that same line of code. The Featured module doesn't have it, but if you have some other third-party "recommended products" module, it may have its own code controlling that. You'd need to edit its files to fix that, so if you can't find those, contact the developer for support.

Re: Disable scroll to top when adding product to cart

Posted: Thu Mar 05, 2020 10:42 pm
by Dutch Pride Code
Thanks a lot, I found it and it works ;D
If I happen to encounter another scroll-top I know where to find it now.