How to stop the page scrolling to top after press add to cart button

This topic has 4 replies, 3 voices, and was last updated 6 years, 7 months ago ago by Olga Barlow

  • Avatar: cyberone
    cyberone
    Participant
    September 19, 2017 at 17:12

    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

    Please, contact administrator
    for this information.
    3 Answers
    Avatar: amzy
    Amzy Leel
    Participant
    September 20, 2017 at 07:32

    Hi,

    Enable Ajax add to cart in WooCommerce > settings : http://prntscr.com/gncelp

    Avatar: cyberone
    cyberone
    Participant
    September 20, 2017 at 17:52

    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

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    September 21, 2017 at 15:42

    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

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.