akhil850 Posted June 30, 2018 Share Posted June 30, 2018 <?php add_filter( 'woocommerce_variable_price_html', 'bbloomer_variation_price_format_310', 10, 2 ); function bbloomer_variation_price_format_310( $price, $product ) { global $woocommerce, $product; // 1. Find the minimum regular and sale prices $min_var_reg_price = $product->get_variation_regular_price( 'min', true ); $min_var_sale_price = $product->get_variation_sale_price( 'min', true ); // 2. New $price if ( $min_var_sale_price < $min_var_reg_price ) { $price = sprintf( __( 'From: <del>%1$s</del><ins>%2$s</ins>', 'woocommerce' ), wc_price( $min_var_reg_price ), wc_price( $min_var_sale_price ) ); } else { $price = sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $min_var_reg_price ) ); } //3. Return edited $price return $price; } // 4. Multiplpier Setion add_action( 'woocommerce_single_product_summary', 'woocommerce_total_product_price', 31 ); function woocommerce_total_product_price() { global $woocommerce, $product; // let's setup our divs echo sprintf('<div id="product_total_price" style="margin-bottom:20px;">%s %s</div>',__('Product Total:','woocommerce'),'<span class="price">'.$product->get_price().'</span>'); ?> <script> jQuery(function($) { //get price var price = <?php echo $product->get_price(); ?>, //get currency symbol 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( currency + product_total.toFixed(2)); } }); }); </script> <?php } ?> Quote Link to comment Share on other sites More sharing options...
akhil850 Posted June 30, 2018 Author Share Posted June 30, 2018 (edited) Goal: Total Prize = Product Prize x Quantity. The above code block works with Simple Products NOT WORKS for variable Products. Check the Existing Progress at : https://zmcakes.com/product/butterscotch-cake/ Edited June 30, 2018 by akhil850 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.