plugins - Calculate price and display on woocommerce product single page under price (simple price, variable price)

Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress.

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 5 years ago.

Improve this question

I am planing to show a new price on my woo-commerce 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 where 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>
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 5 years ago.

Improve this question

I am planing to show a new price on my woo-commerce 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 where 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>
Share Improve this question asked Aug 10, 2019 at 17:55 AnasAnas 331 silver badge5 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

One way to add JavsScript in functions.phhp is to put the JavaScript into a JS file an enqueue it. With wp_enqueue_script().

js/mynicecode.js

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

in functions.php

function my_load_scripts($hook) {
    wp_enqueue_script( 'mynicecode_js', plugins_url( 'js/mynicecode.js', __FILE__ ), array());
}
add_action('wp_enqueue_scripts', 'my_load_scripts');

the price shown in Red should be calcutated using the actual product price and the formulas i have given and display it like the way i have shown on the image.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745251199a4618685.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信