| @@ 81-86 (lines=6) @@ | ||
| 78 | protected function updateRemovedCartItems(Cart $entity) |
|
| 79 | { |
|
| 80 | if ((int)$entity->getItemsQty() === 0) { |
|
| 81 | foreach ($entity->getCartItems() as $cartItem) { |
|
| 82 | if (!$cartItem->isRemoved()) { |
|
| 83 | $cartItem->setUpdatedAt(new \DateTime('now'), new \DateTimeZone('UTC')); |
|
| 84 | $cartItem->setRemoved(true); |
|
| 85 | } |
|
| 86 | } |
|
| 87 | } elseif ($this->existingCartItems) { |
|
| 88 | $existingCartItems = new ArrayCollection($this->existingCartItems); |
|
| 89 | $newCartItems = $entity->getCartItems(); |
|
| @@ 91-98 (lines=8) @@ | ||
| 88 | $existingCartItems = new ArrayCollection($this->existingCartItems); |
|
| 89 | $newCartItems = $entity->getCartItems(); |
|
| 90 | ||
| 91 | foreach ($existingCartItems as $existingCartItem) { |
|
| 92 | if (!$newCartItems->contains($existingCartItem)) { |
|
| 93 | if (!$existingCartItem->isRemoved()) { |
|
| 94 | $existingCartItem->setUpdatedAt(new \DateTime('now'), new \DateTimeZone('UTC')); |
|
| 95 | $existingCartItem->setRemoved(true); |
|
| 96 | } |
|
| 97 | } |
|
| 98 | } |
|
| 99 | } |
|
| 100 | } |
|
| 101 | ||