Hello !
Tell me how I can do this functionality in your REHub Theme
I need what to do show Total Product Price
I give an example in the photo
I tried to write such a code as advised on the forums, but it doesn’t want to work
....
add_action('woocommerce_single_product_summary', 'pt_woocommerce_product_total_price', 35);
function pt_woocommerce_product_total_price() {
global $woocommerce, $product;
// Setup our Html to show the totoal price
echo sprintf('<div id="pt-product-total-price" style="margin-bottom:20px;display:none">%s %s</div>', __('Product Total:', 'woocommerce'), '<span class="price">' . $product->get_price() . '</span>');
echo sprintf('<div id="pt-cart-total-price" style="margin-bottom:20px;display:none">%s %s</div>', __('Cart Total:', 'woocommerce'), '<span class="price">' . $product->get_price() . '</span>');
?>
<script>
jQuery(function ($) {
var product_price = <?php echo $product->get_price(); ?>,
current_cart_total = <?php echo $woocommerce->cart->cart_contents_total; ?>,
currency = '<?php echo get_woocommerce_currency_symbol(); ?>';
$('[name=quantity]').change(function () {
if (!(this.value < 1)) {
var product_total = parseFloat(product_price * this.value),
cart_total = parseFloat(product_total + current_cart_total);
$('#pt-product-total-price .price').html(currency + product_total.toFixed(2));
$('#pt-cart-total-price .price').html(currency + cart_total.toFixed(2));
}
$('#pt-product-total-price,#pt-cart-total-price').toggle(!(this.value <= 1));
});
});
</script>
Thanks ! !
It would be very good if such a function appears!