I'm in need of displaying the total price in product page when quantity changes.
This is the same as line price in the cart if you add quantity of products in the cart.
I'm still new with WooCommerce so I'm not sure where to start. But if someone could help me to the right direction, I think I can manage on my own.
So here's my thoughts on how should I do it.
I'm thinking my jquery would be like this.
jQuery(document).ready(function($){
$('.qty').on('change',function(){
// grab the price
var price = $('[itemprop="price"]').attr('content');
var total_price = price * this.value;
console.log(price, this.value, total_price);
});
})
this works when pasted on the console. But I'm not sure where to put this code on WooCommerce.
You're almost there... try this, paste this in your functions.php
source: http://reigelgallarde.me/programming/show-product-price-times-selected-quantity-on-woocommecre-product-page/
You need to keep in mind initial price value.
Because when you decrease quantity (after increasing it), your code returns wrong result.
A more complete code here:
Also you need to format price before printing it on the page:
It depends from your task.
Hope it helps.