From 89c0f1f0903e4e265887c8e2d2f7fb3e80e4cdaf Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 22 Nov 2017 18:29:06 +0800 Subject: [PATCH] Cast items to array. Fix issues when items are null and php raises "Invalid argument supplied for foreach()". --- src/LaraCart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LaraCart.php b/src/LaraCart.php index b252694..0c6a01b 100644 --- a/src/LaraCart.php +++ b/src/LaraCart.php @@ -747,7 +747,7 @@ public function totalDiscount($format = true, $withItemDiscounts = true) if ($withItemDiscounts) { /** @var CartItem $item */ - foreach ($this->cart->items as $item) { + foreach ((array) $this->cart->items as $item) { $total += floatval($item->getDiscount(false)); } }