Skip to content

Commit

Permalink
Merge pull request #245 from belguinan/master
Browse files Browse the repository at this point in the history
[BUG FIX] - Prevent cart from breaking if item is an array or null.
  • Loading branch information
darryldecode committed May 26, 2020
2 parents ae299df + 010bb51 commit 23fa7ef
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Darryldecode/Cart/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,9 @@ public function getTotalQuantity()
*/
public function getContent()
{
return (new CartCollection($this->session->get($this->sessionKeyCartItems)));
return (new CartCollection($this->session->get($this->sessionKeyCartItems)))->reject(function($item) {
return ! ($item instanceof ItemCollection);
});
}

/**
Expand All @@ -682,9 +684,7 @@ public function getContent()
*/
public function isEmpty()
{
$cart = new CartCollection($this->session->get($this->sessionKeyCartItems));

return $cart->isEmpty();
return $this->getContent()->isEmpty();
}

/**
Expand Down

0 comments on commit 23fa7ef

Please sign in to comment.