M
M
MisTFoR2021-11-29 19:17:02
WooCommerce
MisTFoR, 2021-11-29 19:17:02

How to update the price of a product when the quantity of products changes without reloading the page?

Hello!
There is this code:

add_action( 'wp_footer', 'cart_refresh_update_qty', 100 );
function cart_refresh_update_qty() {
    if ( is_cart() ) {
        ?>
        <script type="text/javascript">
            jQuery('div.woocommerce').on('change', 'input.qty', function(){
                setTimeout(function() {
                    jQuery('[name="update_cart"]').trigger('click');
                }, 100 );
            });
        </script>
        <?php
    }
}

When I change the number of items in the cart, the page is updated, but I need the price to be updated without refreshing the page. What to do?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question