laravel - 如何用总价打折百分比类型?
问题描述
我需要使用购物车总价的百分比类型打折吗?
价格:
total_cart: 11,000
discoutn(percentage): 10%
我的闭嘴:
if ($this->coupon->type === "percentage") {
return $total_cart * ($this->coupon->value / 100);
}
有了这段代码,我得到了这个结果1,100
|:!
解决方案
if ($this->coupon->type === "percentage") {
return $total_cart * ((100-$this->coupon->value) / 100);
}
推荐阅读
- firebase - 我正在尝试在个人资料用户上显示姓名但出现错误,为什么?
- javascript - 如何使用嵌入的 Typeform(使用隐藏字段)捕获页面 URL?
- r - 显示图列表并允许用户单击感兴趣的图进行下游分析
- python - 如何在 godaddy 上设置你的 python django 项目
- ios - 为什么 wkwebview 隐藏在导航栏下
- mysql - 用于 MySQL 和 Spring Boot 的 Docker Compose
- wordpress - 我需要帮助更改添加到购物车按钮文本的粘性
- javascript - Array.push 在 while 循环外为空
- jquery - 在 laravel 查询生成器中找不到列
- javascript - 无法更新 JSON 值