Skip to content

Commit

Permalink
Cast items to array.
Browse files Browse the repository at this point in the history
Fix issues when items are null and php raises "Invalid argument supplied for foreach()".
  • Loading branch information
yajra committed Nov 22, 2017
1 parent 4ea689a commit 89c0f1f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/LaraCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down

0 comments on commit 89c0f1f

Please sign in to comment.