diff --git a/beike/Shop/Services/TotalService.php b/beike/Shop/Services/TotalService.php index 0ae10206..0b25edf0 100644 --- a/beike/Shop/Services/TotalService.php +++ b/beike/Shop/Services/TotalService.php @@ -138,13 +138,34 @@ class TotalService return collect($carts)->sum('subtotal'); } - public function getCartProducts() + /** + * Get Cart Products + * + * @return array + */ + public function getCartProducts(): array { return $this->cartProducts; } + /** + * Get Current Cart + * + * @return Cart + */ public function getCurrentCart() { return $this->currentCart; } + + /** + * Get Cart Product Amount + * + * @return mixed + */ + public function countProducts(): mixed + { + $cartProducts = $this->getCartProducts(); + return collect($cartProducts)->sum('quantity'); + } }