function it_throws_cart_not_found_exception_if_currency_code_is_undefined(CartContextInterface $cartContext, ShopperContextInterface $shopperContext, ChannelInterface $channel, OrderInterface $cart)
 {
     $cartContext->getCart()->willReturn($cart);
     $shopperContext->getChannel()->willReturn($channel);
     $shopperContext->getCurrencyCode()->willThrow(CurrencyNotFoundException::class);
     $this->shouldThrow(CartNotFoundException::class)->during('getCart');
 }
예제 #2
0
 function it_throws_a_cart_not_found_exception_if_locale_code_is_undefined(CartContextInterface $cartContext, ShopperContextInterface $shopperContext, ChannelInterface $channel, CurrencyInterface $currency, OrderInterface $cart)
 {
     $cartContext->getCart()->willReturn($cart);
     $shopperContext->getChannel()->willReturn($channel);
     $channel->getBaseCurrency()->willReturn($currency);
     $currency->getCode()->willReturn('PLN');
     $shopperContext->getLocaleCode()->willThrow(LocaleNotFoundException::class);
     $this->shouldThrow(CartNotFoundException::class)->during('getCart');
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     try {
         $this->data['currency_code'] = $this->shopperContext->getCurrencyCode();
     } catch (CurrencyNotFoundException $exception) {
     }
     try {
         $this->data['locale_code'] = $this->shopperContext->getLocaleCode();
     } catch (LocaleNotFoundException $exception) {
     }
 }
예제 #4
0
 /**
  * {@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();
     }
 }
예제 #5
0
 /**
  * {@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;
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     try {
         /** @var ChannelInterface $channel */
         $channel = $this->shopperContext->getChannel();
         $this->data['base_currency_code'] = $channel->getBaseCurrency()->getCode();
         $this->data['currency_code'] = $this->shopperContext->getCurrencyCode();
     } catch (ChannelNotFoundException $exception) {
     } catch (CurrencyNotFoundException $exception) {
     }
     try {
         $this->data['locale_code'] = $this->shopperContext->getLocaleCode();
     } catch (LocaleNotFoundException $exception) {
     }
 }