'Wordpress add automatic price update after quantity change on single product page

I am using the Porto Wordpress theme. The problem with that theme is that it does not show an automatically updating product price under the "Add-to-cart"-Button. It only shows the standard price for quantity = 1 below the product name.

I have already tried some solutions, e.g. show price*quantity in single product page

or

function bbloomer_product_price_recalculate() {
   global $product;
   echo '<div id="subtot" style="display:inline-block;">Total: <span></span></div>';
   $price = $product->get_price();
   $currency = get_woocommerce_currency_symbol();
   wc_enqueue_js( "      
      $('[name=quantity]').on('input change', function() { 
         var qty = $(this).val();
         var price = '" . esc_js( $price ) . "';
         var price_string = (price*qty).toFixed(2);
         $('#subtot > span').html('" . esc_js( $currency ) . "'+price_string);
      }).change();
   " );
}

But they do not seem to work. Any solution out there, how to add automatically updating price after quantity change in single product page?

Thanks in Advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source