I wanted to add total price in single product page. Unfortunately I'm not a programmer. It means I actually don't know about JavaScript or code well.
So I searched some codes on google and added it in function.php
file.
This is the code:
add_action( 'woocommerce_single_product_summary', 'woocommerce_total_product_price', 29 );
function woocommerce_total_product_price() {
global $woocommerce, $product;
echo sprintf('<div id="product_total_price" style="margin-bottom:20px;">%s %s</div>',__('price total','woocommerce'),'<span class="price">'.$product->get_price().'</span>'.'KRW');
?>
<script>
jQuery(function($){
var price = <?php echo $product->get_price(); ?>,
currency = '<?php echo get_woocommerce_currency_symbol(); ?>';
$('[name=quantity]').change(function(){
if (!(this.value < 1)) {
var product_total = parseFloat(price * this.value);
$('#product_total_price .price').html(product_total.toFixed(0));
}
});
});
</script>
<?php
}
My problem is the code doesn't show thousands separator. How can I do that?
And I want to add the total price between quantity and add to cart button. Now the total price is before quantity.
Thanks.