Calculate price and display on WooCommerce product single page under price (simple price, variable price)

I am planing to show a new price on my WooCommerce product page for all products. This is the installment price per month. I need to show this below the normal price (variable price and simple price) something like this.

0% interest installments starting from Rs.3,093

where Rs.3,093 is the new price.

This is the calculation I tried on W3 schools, and I got the calculation correct.

whereas 60000 is the price of the product
multiplied by this number 5.15464
divided by 100

Answer is 3,093
(answer should be rounded off to the nearest integer)

I need a custom function for this that I can add to my functions.php

<script>
var x = myFunction(60000, 5.15464, 100);
function myFunction(a, b, c) {
  return Math.round (a * b / c);
}
</script>

Solutions

This code will display the value or content before Add to Cart button in woocommerce product page.

        add_action( 'woocommerce_single_product_summary', 'show_emi', 20 );
      function show_emi() {
       global $product; 
       $id = $product->get_id();
        $product = wc_get_product( $id );
        $a=$product->get_price();
        $b  = 5.15464;
        $c = 100;
        $d = $a * $b;
        $total = $d/$c;
          echo $total;
      }

Similar questions

How to display shipping methods on checkout page and calculate shipping rate in woocommerce
How can I display shipping methods on checkout page instead of cart page and calculate shipping rate with product price on change shipping method. I have tried Shipping methods only enabled in checkout page on Woocommerce answer code addition. It's removed shipping methods on cart page but shipping methods is not showing on Checkout Page I have als...
Dynamically calculate product price based on custom fields values when added-to-cart
I found the code to add existing product: But I need to add product, with price that determined by 2 inputs: I calculate the product's price by the formula age*quality. I know it's possible to add product with variations, but it's so many possible variations. Is it possible to set the product price dynamically based on custom fields calculation val...
woocomerce calculate final price based on the quantity of one product
I am currently setting up a woocommerce shop. Basically this is what I am trying to achieve. "this is a fruit shop for whom they want fruits in basket( package), the customer select the fruits he wants (for example 3 items), then he/she select the basket with the desired quantity (1 among 3 different baskets in sites). the total cost must be calcul...
Display prefixed price and additional unit price in Woocommerce simple products
Using Woocommerce I sell wine per box with 6 bottles in a box. So naturally I enter a price per box when setting up my product. I do however want the user to see the price per bottle as well. $120 / box $20 / bottle I tried using Display on shop pages the unit price and the wholesale price on product pages answer code. It does exactly what I want, ...
woocommerce calculate and save price
I have added custom fields to Woocommerce/Add Product/General tab using this excellent tutorial http://www.remicorson.com/mastering-woocommerce-products-custom-fields/ The custom fields (height, width, multiplier) are being saved to the database OK. I want to calculate a price based on the custom fields, and save the price to the database as the Re...
Woocommerce - Variable product loads default product image before loading actual Variable product image
I have woocommerce and i am adding variable products with images. When i wish to open the variable product first it loads the default image/ featured image of product before loading variable products image. In other way it loads feature image of product and after that it loads image of that variation.

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy .