This commit is contained in:
Edward Yang 2022-06-29 08:56:40 +08:00
parent 8ed66a2e58
commit 2f4aed3922
1 changed files with 5 additions and 3 deletions

View File

@ -100,7 +100,7 @@ class CartService
}
Cart::query()->where('customer_id', $customer->id)
->where('id', $cartId)
->update(['quantity' => $quantity]);
->update(['quantity' => $quantity, 'selected' => 1]);
}
@ -126,10 +126,12 @@ class CartService
if (empty($carts)) {
$carts = CartService::list(current_customer());
}
$amount = collect($carts)->sum('subtotal');
$selected = collect($carts)->where('selected', 1);
$quantity = $selected->sum('quantity');
$amount = $selected->sum('subtotal');
$data = [
'carts' => $carts,
'quantity' => collect($carts)->sum('quantity'),
'quantity' => $quantity,
'amount' => $amount,
'amount_format' => currency_format($amount)
];