Skip to content

Commit

Permalink
Merge pull request #1800 from benwalch/bugfix/cartcontext-latest-cart…
Browse files Browse the repository at this point in the history
…-if-multiple

fixes #1699 cart context returns latest cart even if multiple found
  • Loading branch information
dpfaffenbauer authored Nov 29, 2021
2 parents 78fdaaa + e258533 commit b2a018c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ public function findLatestByStoreAndCustomer(StoreInterface $store, CustomerInte
$list->setCondition('customer__id = ? AND store = ? AND order__id is null ', [$customer->getId(), $store->getId()]);
$list->setOrderKey('o_creationDate');
$list->setOrder('DESC');
$list->setLimit(1);
$list->load();

$objects = $list->getObjects();

if (count($objects) === 1 && $objects[0] instanceof OrderInterface) {
if (count($objects) > 0 && $objects[0] instanceof OrderInterface) {
return $objects[0];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function findLatestCartByStoreAndCustomer(StoreInterface $store, Customer

$objects = $list->getObjects();

if (count($objects) === 1 && $objects[0] instanceof OrderInterface) {
if (count($objects) > 0 && $objects[0] instanceof OrderInterface) {
return $objects[0];
}

Expand Down

0 comments on commit b2a018c

Please sign in to comment.