Skip to content

Commit 23fa7ef

Browse files
authored
Merge pull request #245 from belguinan/master
[BUG FIX] - Prevent cart from breaking if item is an array or null.
2 parents ae299df + 010bb51 commit 23fa7ef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Darryldecode/Cart/Cart.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,9 @@ public function getTotalQuantity()
672672
*/
673673
public function getContent()
674674
{
675-
return (new CartCollection($this->session->get($this->sessionKeyCartItems)));
675+
return (new CartCollection($this->session->get($this->sessionKeyCartItems)))->reject(function($item) {
676+
return ! ($item instanceof ItemCollection);
677+
});
676678
}
677679

678680
/**
@@ -682,9 +684,7 @@ public function getContent()
682684
*/
683685
public function isEmpty()
684686
{
685-
$cart = new CartCollection($this->session->get($this->sessionKeyCartItems));
686-
687-
return $cart->isEmpty();
687+
return $this->getContent()->isEmpty();
688688
}
689689

690690
/**

0 commit comments

Comments
 (0)