计算购物车商品总额

This commit is contained in:
Edward Yang 2022-12-05 14:27:47 +08:00
parent cc6f47a99d
commit 55423be548
1 changed files with 7 additions and 2 deletions

View File

@ -18,8 +18,7 @@ class SubtotalService
{
public static function getTotal(TotalService $totalService)
{
$carts = $totalService->cartProducts;
$amount = collect($carts)->sum('subtotal');
$amount = self::getAmount($totalService);
$totalData = [
'code' => 'sub_total',
'title' => trans('shop/carts.product_total'),
@ -32,4 +31,10 @@ class SubtotalService
return $totalData;
}
public static function getAmount(TotalService $totalService)
{
$carts = $totalService->cartProducts;
return collect($carts)->sum('subtotal');
}
}