I used this answer code which works perfectly for single product:
// Priority 31 is placed below the 'add to cart' button
add_action( 'woocommerce_single_product_summary', 'action_woocommerce_single_product_summary', 31, 0 );
function action_woocommerce_single_product_summary() {
global $product;
$price = $product->get_price();
$currency_symbol = get_woocommerce_currency_symbol();
$min_qnty = $product->get_min_purchase_quantity();
$initial_price = floatval($price) * intval ($min_qnty);
// leave the span class 'prezzo' as it is or it won't render the price
echo sprintf('<div id="product_total_price">%s %s</div>', __('Total:','woocommerce'), '<span class="prezzo">' . $currency_symbol . $initial_price . '</span>' );
?>
<script>
jQuery(function($) {
// vars
var price = <?php echo $price; ?>,
currency = '<?php echo $currency_symbol; ?>',
quantity = $( '[name=quantity]' ).val();
var product_total = parseFloat( price * quantity );
$( '#product_total_price .prezzo' ).html( currency + product_total.toFixed( 2 ) );
// On change
$( '[name=quantity]' ).change( function() {
if ( ! ( this.value < 1 ) ) {
product_total = parseFloat( price * this.value );
$( '#product_total_price .prezzo' ).html( currency + product_total.toFixed( 2 ) );
}
});
});
</script>
<?php
}
I would like to do the same thing for grouped products, but I'm not sure, how I should tackle this.
Any help is appreciated.