Hook: cart.totals
Last updated on May 21, 2026 00:20
Overview
Type: Filter
Location: app/Services/Ecommerce/CartService.php
Filters calculated cart totals before returning to the client. Use for custom discounts, surcharges, or fee adjustments.
Parameters
| Param | Type | Description |
|---|---|---|
$totals |
array | Calculated totals (subtotal, tax, shipping, total) |
$cart |
Cart | Cart model with items |
Return
Must return array - modified totals.
Usage Example
Hook::addFilter('cart.totals', function (array $totals, $cart) {
if ($totals['subtotal'] < 100000) {
$totals['total'] += 15000; // handling fee for small orders
}
return $totals;
});
Related Hooks
- shipping.calculate_cost - Override shipping cost
- tax.calculated - Override tax calculation