Home Forums WoodMart support forum Subtotal on product page

Subtotal on product page

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #629047

    repoot.de
    Participant

    Hi,

    I want to show subtotal on product page. Please help me!

    #629298

    Aizaz Imtiaz Awan
    Keymaster
    Xtemos team

    Hello,

    Try to Add the code below to the functions.php file in your child theme:

    add_action( 'woocommerce_after_add_to_cart_button', 'pk_product_price_recalculate' );
    
    function pk_product_price_recalculate() {
        global $product;
        echo '<div id="subtot" style="display:inline-block;">Subtotal: <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();
        ");
    }

    Best Regards

Viewing 2 posts - 1 through 2 (of 2 total)