public function handle(GetLowestShipmentRatesByDeliveryMethodQuery $query)
 {
     $request = $query->getRequest();
     $response = $query->getResponse();
     $shipmentRates = $this->shipmentGateway->getTrimmedRates($request->getToAddressDTO(), $request->getParcelDTO());
     foreach ($shipmentRates as $shipmentRate) {
         $response->addShipmentRateDTOBuilder($this->dtoBuilderFactory->getShipmentRateDTOBuilder($shipmentRate));
     }
 }
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);
 }
Example #3
0
 public function buyShipmentLabel(UuidInterface $orderId, OrderItemQtyDTO $orderItemQtyDTO, $comment, $rateExternalId, $shipmentExternalId)
 {
     $order = $this->orderRepository->findOneById($orderId);
     $shipmentTracker = $this->shipmentGateway->buy($shipmentExternalId, $rateExternalId);
     $this->addShipment($comment, $orderItemQtyDTO, $shipmentTracker, $order);
 }