挂钩:tax.calculated
Last updated on Jun 24, 2026 02:01
## 概述
类型: 过滤器
位置: app/Services/Ecommerce/CartService.php
在返回给客户端之前过滤计算出的购物车总计。用于自定义折扣、附加费或费用调整。
## 参数
| 参数 | 类型 | 描述 |
|---|---|---|
$totals |
数组 | 计算总计(小计、税费、运费、总计) |
$cart |
购物车 | 带有物品的购物车模型 |
## 返回
必须返回“array”-修改后的总计。
使用示例
Hook::addFilter('cart.totals', function (array $totals, $cart) {
if ($totals['subtotal'] < 100000) {
$totals['total'] += 15000; // handling fee for small orders
}
return $totals;
});
相关挂钩
- shipping.calculate_cost - 覆盖运费
- tax.calculated - 覆盖税收计算