/** * @param CartInterface $cart * @param CartItemInterface $item */ private function resolveCartItem(CartInterface $cart, CartItemInterface $item) { foreach ($cart->getItems() as $existingItem) { if ($item->equals($existingItem)) { $this->orderItemQuantityModifier->modify($existingItem, $existingItem->getQuantity() + $item->getQuantity()); return; } } $cart->addItem($item); }
public function setCart(CartInterface $cart) { $user = $this->getUser(); if ($cart !== $this->getCart()) { $this->abandonCart(); } if ($cart instanceof OrderInterface && $user instanceof UserInterface) { $cart->setUser($user); $cart->setExpiresAt(null); } }
function it_sets_cart_identifier_via_session($session, CartInterface $cart) { $cart->getIdentifier()->will(function () { return 3; }); $session->set(SessionCartStorage::KEY, 3)->will(function () use($session) { $session->get(SessionCartStorage::KEY)->willReturn(3); }); $this->setCurrentCartIdentifier($cart); $this->getCurrentCartIdentifier()->shouldReturn(3); }
function it_throw_exception_if_subject_is_not_a_cart(GenericEvent $event, CartInterface $cart) { $event->getSubject()->shouldBeCalled()->willReturn(null); $cart->calculateTotal()->shouldNotBeCalled(); $this->shouldThrow('\\InvalidArgumentException')->during('refreshCart', array($event)); }
/** * {@inheritdoc} */ public function setCurrentCartIdentifier(CartInterface $cart) { $this->session->set($this->key, $cart->getIdentifier()); }
function it_removes_cart_item_from_cart(OrderProcessorInterface $orderProcessor, CartInterface $cart, CartItemInterface $cartItem) { $cart->removeItem($cartItem)->shouldBeCalled(); $orderProcessor->process($cart)->shouldBeCalled(); $this->removeFromCart($cart, $cartItem); }
/** * {@inheritdoc} */ public function setCurrentCartIdentifier(CartInterface $cart) { $this->storage->setData(self::STORAGE_KEY, $cart->getIdentifier()); }