Display Total Price When Quantity Selection Change in WooCommerce

Use this code snippet to display the total price when the quantity selected changes in WooCommerce on child sites.

Snippet Type

Execute on Child Sites


add_action( 'woocommerce_single_product_summary', 'woocommerce_total_product_price', 31 );
function woocommerce_total_product_price() {
    global $woocommerce, $product;
    // let's setup our divs
    echo sprintf('<div id="product_total_price" style="margin-bottom:20px;">%s %s</div>',__('Product Total:','woocommerce'),'<span class="price">'.$product->get_price().'</span>');
                var price = <?php echo $product->get_price(); ?>,
                    currency = '<?php echo get_woocommerce_currency_symbol(); ?>';

                    if (!(this.value < 1)) {

                        var product_total = parseFloat(price * this.value);

                        $('#product_total_price .price').html( currency + product_total.toFixed(2));


Thank you so much! <3
This worked for me for both simple and variable products.

I’ve been searching on how to display a message based on the selected quantity. Even though this snippet is calculating and display a price, it’s the closest thing I found. Is it possible to add a message based on the quantity?

I am sure it is possible to display a message based on the select product quantity.