/**
  * @param CreateOrderFromCartCommand $command
  * @throws EntityValidatorException
  */
 public function handle(CreateOrderFromCartCommand $command)
 {
     $cart = $this->cartService->findOneById($command->getCartId());
     $user = $this->userService->findOneById($command->getUserId());
     $order = $this->orderService->createOrderFromCart($command->getOrderId(), $user, $cart, $this->cartCalculator, $command->getIp4(), OrderAddressDTOBuilder::createFromDTO($command->getShippingAddressDTO()), OrderAddressDTOBuilder::createFromDTO($command->getBillingAddressDTO()), CreditCardDTOBuilder::createFromDTO($command->getCreditCardDTO()));
     $this->cartService->delete($cart);
 }
Example #2
0
 /**
  * @param UuidInterface $cartId
  * @param string $shipmentRateExternalId
  * @param OrderAddressDTO $shippingAddressDTO
  */
 public function setExternalShipmentRate(UuidInterface $cartId, $shipmentRateExternalId, OrderAddressDTO $shippingAddressDTO)
 {
     $cart = $this->cartRepository->findOneById($cartId);
     $shipmentRate = $this->shipmentGateway->getShipmentRateByExternalId($shipmentRateExternalId);
     $cart->setShipmentRate($shipmentRate);
     $shippingAddress = OrderAddressDTOBuilder::createFromDTO($shippingAddressDTO);
     $cart->setShippingAddress($shippingAddress);
     $taxRate = $this->taxRateRepository->findByZip5AndState($shippingAddressDTO->zip5, $shippingAddressDTO->state);
     $cart->setTaxRate($taxRate);
     $this->cartRepository->update($cart);
 }