This topic has 4 replies, 3 voices, and was last updated 7 years, 2 months ago ago by Olga Barlow
Hi,
When the user clicks on the ‘add to cart’ button on shop page, the page scrolls to the top of the page.
I want to stop the on click behaviour from scrolling to the top of the page.
How can I keep it so that the navigation stays in the current location so the customer does not have to scroll down again?
Screenshot: https://prnt.sc/gn34kb
Hi,
Enable Ajax add to cart in WooCommerce > settings : http://prntscr.com/gncelp
Hi,
It doesn’t help to enable “Ajax add to cart” in WooCommerce > settings
Enabling or disabling “Ajax add to cart”, the behaviour is same.
Searching Google, all solutions related to this problem pointing out to the following code that cause scrolling to top after pressing “Add to cart”:
“$(‘body,html’).animate({ scrollTop:” which is related to ajx-Cart.
You can find a lot of lines with the above code in the etheme.js and other places.
Which one is the correct one to comment out, that could stop the page scrolling to top after pressing “add to cart”?
I appreciate your help.
Best Regards
Hello,
You have made additional customization to theme files and Ajax add to cart function on grid does not work anymore (you can enable parent theme and compare), that’s why after page reload you are redirected to page with different URL, to the top of the page to WooCommerce success message.
It’s not related to code that you provided. You can enable default theme and try to add any product to cart without Ajax and you’ll see the same result. So, either you need to improve your changes and fix Ajax add to cart for your products or implement some scroll to the product. In any case, additional customization is our the scope of our support. If you need help with additional customization you may contact WPKraken team.
Regards
Tagged: add to cart, stop scrolling, templates, woocommerce, wordpress
You must be logged in to reply to this topic.Log in/Sign up