Woocommerce - Cart form is being duplicated after adjusting the input quantity

22 views Asked by At

After adjusting (increase or decrease) the quantity of the products on the cart page of my e-shop, the whole section is being duplicated. What I found on the web is that the problem si probably in the form: "woocommerce-cart-form".

I have only one customization connected with quantity and it is automatic update of cart totals after adjusting the quantity (without button). I am attaching the code below. But this is not the reason of this problem, the same will happen with the cart update using button.

add_action( 'wp_footer', function() {

?><script>
jQuery( function( $ ) {
    let timeout;
    $('.woocommerce').on('change', 'input.qty', function(){
        if ( timeout !== undefined ) {
            clearTimeout( timeout );
        }
        timeout = setTimeout(function() {
            $("[name='update_cart']").trigger("click"); // trigger cart update
        }, 1000 ); // 1 second delay, half a second (500) seems comfortable too
    });
} );
</script><?php
} );

Below you can find how it looks after any quantity adjust. Good to know is that cart totals (price) are correct and if I refresh the page after this problem happen, all is correct. It is probably some bug with the cart update function.

Thank you for any hint!

Before adjusting the quantity:enter image description here

After adjusting the quantity (this happened before woo notices appeared):enter image description here

After adjusting the quantity 2 (this happened after woocommerce notices appeared): enter image description here

0

There are 0 answers