我无法计算乘以100的产品的总订购金额的折扣。
在我的数据库中,我要保存乘以100 breaks <- seq(as.Date("1955-10-01"), length=13, by="year")
cut(x, breaks, labels = FALSE )
# [1] 1 1 1 2 3 3 3 5 6 6 7 7 7 8 8 9 10 10 10 11
的产品价格,以防止在检索数据并将其添加到其他产品时对e.g.: $price = 33.5 * 100
进行错误的计算。
所以我现在有这个
decimal point .5
现在我要扣除的是$test_product_price = 10000 // actual price is 100 because it's save multiplied by 100
$quantity = 3;
$discount = 10.5%;
$order_amount = $test_product_price * 3 // will produce 30000 but actual price is 300 when divided by 100
的{{1}}
对于实际金额,这可以正常工作
$discount
但是我该怎么办,那就是我的金额乘以10.5%
答案 0 :(得分:1)
可能有些冗长但准确;
<?php
$amount = 100;
$number = 3;
$percent = 10.5;
$subtotal = $amount * $number;
$discount = ($percent / 100) * $subtotal;
$total = $subtotal - $discount;
$total = number_format((float)$total, 2, '.', '');
echo $total;
?>