function it_creates_cart_if_does_not_exist_with_shop_basic_configuration(CartContextInterface $cartContext, ShopperContextInterface $shopperContext, OrderInterface $cart, ChannelInterface $channel, CustomerInterface $customer) { $cartContext->getCart()->willReturn($cart); $shopperContext->getChannel()->willReturn($channel); $shopperContext->getCurrencyCode()->willReturn('PLN'); $shopperContext->getCustomer()->willReturn($customer); $cart->setChannel($channel)->shouldBeCalled(); $cart->setCurrencyCode('PLN')->shouldBeCalled(); $cart->setCustomer($customer)->shouldBeCalled(); $this->getCart()->shouldReturn($cart); }
/** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { $this->version = Kernel::VERSION; $this->channelCode = $this->shopperContext->getChannel()->getCode(); $this->currencyCode = $this->shopperContext->getCurrencyCode(); $this->localeCode = $this->shopperContext->getLocaleCode(); $customer = $this->shopperContext->getCustomer(); if (null !== $customer) { $this->customerEmail = $customer->getEmail(); } }
/** * {@inheritdoc} */ public function getCart() { if (null !== $this->cart) { return $this->cart; } /** @var OrderInterface $cart */ $cart = $this->cartContext->getCart(); try { $cart->setChannel($this->shopperContext->getChannel()); } catch (ChannelNotFoundException $exception) { throw new CartNotFoundException('Sylius was not able to prepare the cart properly', $exception); } try { $cart->setCurrencyCode($this->shopperContext->getCurrencyCode()); } catch (CurrencyNotFoundException $exception) { throw new CartNotFoundException($exception); } $cart->setCustomer($this->shopperContext->getCustomer()); $this->cart = $cart; return $cart; }