Show discount on simple product page
-
Dear all,
I am using a piece of code for the simple products zo people can see the price when they change the amount of products on that product page.
The piece of code is working good, but the problem is the following. When people are adding a product above an amount of numbers the will get a discount. So for instance:
Product 1 = 0,95,- cents but when order this product not one but in an amount of 100 (or more) the will get a discount of 5 cents (so 0,90,- cents for the product). This is visible on the checkout page, but it’s not visible on the simple page of the product itself.
Who can help me out? Kind regards Mark
See the code:
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 totaal:','woocommerce'),'<span class="price">'.$product->get_price().'</span>'); ?> <script> jQuery(function($){ var price = <?php echo $product->get_price(); ?>, 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 }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Show discount on simple product page’ is closed to new replies.