• Resolved arslion

    (@arslion)


    Whenever I add multiple products and delete one of them it scrolls to top of the page to show msg that product is deleted. I want to stop this behavior and want to stay where it already is.

    This was also happening when changing quantity and updating cart which I resolved by using this code. Any changes to this code so both could work?
    Pls Help

    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);
                });
            });
    });
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter arslion

    (@arslion)

    No one replying :/

    Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the following places for more development-oriented questions:

    1. WooCommerce Slack Community: https://woocommerce.com/community-slack/
    2. WooCommerce FB group: https://www.facebook.com/groups/advanced.woocommerce/
    Thread Starter arslion

    (@arslion)

    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.

    wc_print_notices();

    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.

    Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    Thanks for sharing your solution with the community!

    
    remove_action('woocommerce_before_cart', 'woocommerce_output_all_notices', 10);
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Stop scrolling to top when deleting a product from cart’ is closed to new replies.