I'd like the user to be scrolled to the top of the product page upon successfully adding a product to their cart, so that they can see the success message.

What would be the best way to accomplish this?


Try this code in your custom js

require(['jquery', 'jquery/ui'],function($){
    $('[data-block="minicart"]').on('contentLoading', function (event) {    
        $('[data-block="minicart"]').on('contentUpdated', function ()  {
            $('html, body').animate({scrollTop:0}, 'slow');
| improve this answer | |
  • Works perfectly, thank you! – brackfost Jul 23 '19 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.