Esempio n. 1
0
 /**
  * @param UuidInterface $orderId
  * @param User $user
  * @param Cart $cart
  * @param CartCalculatorInterface $cartCalculator
  * @param string $ip4
  * @return Order
  */
 public static function fromCart(UuidInterface $orderId, User $user, Cart $cart, CartCalculatorInterface $cartCalculator, $ip4)
 {
     $order = new Order($orderId);
     $order->setIp4($ip4);
     foreach ($cart->getCartItems() as $item) {
         $order->addOrderItem($item->getOrderItem($order, $cartCalculator->getPricing()));
     }
     foreach ($cart->getCoupons() as $coupon) {
         $order->addCoupon($coupon);
     }
     $order->setUser($user);
     $order->setTaxRate($cart->getTaxRate());
     $order->setShipmentRate($cart->getShipmentRate());
     $order->setTotal($cart->getTotal($cartCalculator));
     return $order;
 }
Esempio n. 2
0
 /**
  * @return static
  */
 public function withCartTotal(CartCalculatorInterface $cartCalculator)
 {
     $this->entityDTO->cartTotal = $this->dtoBuilderFactory->getCartTotalDTOBuilder($this->entity->getTotal($cartCalculator))->withAllData()->build();
     return $this;
 }
Esempio n. 3
0
 public function testGetTotal()
 {
     $cartItem = $this->dummyData->getCartItem(null, 2);
     $cartItem->getProduct()->setUnitPrice(500);
     $cart = new Cart();
     $cart->addCartItem($cartItem);
     $cartCalculator = $this->getCartCalculator();
     $this->assertTrue($cart->getTotal($cartCalculator) instanceof CartTotal);
 }