I made a code for calculating Woocommmerce discount... Sorry for the stupid question, but I can not find a solution.
"division" outputs the "price_per_bottle" devided by "price_per_ltr". I can not get it to output only 2 decimal places ("12.30" as in €), because now, by default, there are many.
<button id='add' type='button' onclick='ik(this.value);' value='3'>
30% Discount <span class="kalkc3" id="kalk1"><?php
$price_per_bottle= $product->get_price();
$price_per_ltr= 0.7;
$division = $price_per_bottle/ $price_per_ltr;
echo $division;
?></span></button>
I have found the answer, but not in the mentioned post... But with trial and error:)..
<?php
$kokstane3 = $product->get_price();
$popust3 = 0.7;
$rezultat3 = $kokstane3 * $popust3;
echo (round($rezultat3,2));// <= HERE
?>