Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 如何使用总价折扣百分比类型?_Laravel - Fatal编程技术网

Laravel 如何使用总价折扣百分比类型?

Laravel 如何使用总价折扣百分比类型?,laravel,Laravel,我需要折扣与百分比类型的总价格的购物车 价格: total_cart: 11,000 discoutn(percentage): 10% 我的关闭: if ($this->coupon->type === "percentage") { return $total_cart * ($this->coupon->value / 100); } 用这个代码我得到了这个结果1100|:: 你想得到总数的90%(100%-10%)。这是相同的(从你的代码中):$tot

我需要折扣与百分比类型的总价格的购物车

价格:

total_cart: 11,000

discoutn(percentage): 10%
我的关闭:

if ($this->coupon->type === "percentage") {
   return $total_cart * ($this->coupon->value / 100);
}

用这个代码我得到了这个结果
1100
|::

你想得到总数的90%(100%-10%)。这是相同的(从你的代码中):$total\u cart-($total\u cart*($this->优惠券->价值/100))这意味着((100-10)/100)*total\u cart??好吧,把数字插入并进行计算<代码>11000*(10/100)用它来找出数学逻辑中的错误所在。现在,你给的是90%的折扣,而不是10%的折扣。
if ($this->coupon->type === "percentage") {
   return $total_cart * ((100-$this->coupon->value) / 100);
}