• Resolved aaron19888

    (@aaron19888)


    Hi,

    i have this code but it only works with Simple Products, is there a way to easily change it so works with: VAriable Products as well please?

    // we are going to hook this on priority 31, so that it would display below add to cart button.
    add_action( 'woocommerce_single_product_summary', 'woocommerce_total_product_price', 31 );
    function woocommerce_total_product_price() {
        global $woocommerce, $product;
        ?>
            <script>
                jQuery(function($){
                    var 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(price * this.value),
                            cart_total = parseFloat(product_total + current_cart_total);
    
                            $('.amount').html( currency + product_total.toFixed(2));
                        }
                        $('.amount').toggle(!(this.value <= 1));
    
                    });
                });
            </script>
        <?php
    }

    Thanks
    Aaron

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Support slash1andy

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    Since this has been open for weeks with no response, I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    We highly recommend contacting one of the services on our Customizations page (https://woocommerce.com/customizations/)

Viewing 1 replies (of 1 total)

The topic ‘update price variable products’ is closed to new replies.