Esempio n. 1
0
 private function addCartAmountControls()
 {
     $container = $this->addContainer('amount');
     foreach ($this->cart->getItems() as $item) {
         $errorMessage = 'Amount must be positive number.';
         $container->addText($item->getId(), 'Amount')->setType('number')->setDefaultValue($item->getAmount())->addRule(self::INTEGER, $errorMessage)->addRule(self::RANGE, $errorMessage, [1, null]);
     }
     return $container;
 }
Esempio n. 2
0
 private function createFields()
 {
     $addressContainer = new AddressFormContainer();
     $this->addComponent($addressContainer, 'address');
     $addressContainer->addNameControl('name', $this->cart->getName(), true);
     $addressContainer->addStreetControl('street', $this->cart->getStreet(), true);
     $addressContainer->addCityControl('city', $this->cart->getCity(), true);
     $addressContainer->addZipControl('zip', $this->cart->getZip(), true);
     $this->addSubmit('next', 'Next');
 }
Esempio n. 3
0
 public function __construct(Cart $cart, $number, PaymentType $paymentType)
 {
     if (count($cart->getItems()) === 0) {
         throw new InvalidEnumException('Cannot create order from empty cart.');
     }
     if (strlen($number) !== self::NUMBER_LENGTH) {
         throw new EntityInvalidArgumentException(sprintf('Order number length must be exactly %d characters.', self::NUMBER_LENGTH));
     }
     $this->number = $number;
     $this->paymentType = $paymentType->getValue();
     $cart->setOrder($this);
     $this->cart = $cart;
 }
Esempio n. 4
0
 public function createShipmentForCart(Cart $cart, ShipmentOption $shipmentOption, $name = null, $street = null, $city = null, $zip = null)
 {
     if ($shipmentOption instanceof ShipmentPersonalPoint) {
         $shipment = new ShipmentPersonal($cart, $shipmentOption);
     } elseif ($shipmentOption instanceof ShipmentTransportCompany) {
         $shipment = new ShipmentByTransportCompany($cart, $shipmentOption, $name, $street, $city, $zip);
     } elseif ($shipmentOption instanceof ShipmentCollectionPoint) {
         $shipment = new ShipmentToCollectionPoint($cart, $shipmentOption);
     } else {
         throw new \LogicException();
     }
     if ($cart->hasShipment()) {
         if ($cart->getShipment()->equals($shipment)) {
             return;
         }
         $this->removeEntity($cart->getShipment());
     }
     $cart->setShipment($shipment);
     $this->createEntity($shipment);
 }
Esempio n. 5
0
 private function setCurrentCart(Cart $cart)
 {
     $this->currentCart = $cart;
     $this->cartSession->cartId = $cart->getId();
 }