コード例 #1
0
ファイル: CartForm.php プロジェクト: shophp/shophp
 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;
 }
コード例 #2
0
ファイル: AddressForm.php プロジェクト: shophp/shophp
 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');
 }
コード例 #3
0
ファイル: Order.php プロジェクト: shophp/shophp
 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;
 }
コード例 #4
0
ファイル: CartService.php プロジェクト: shophp/shophp
 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);
 }
コード例 #5
0
ファイル: CurrentCartService.php プロジェクト: shophp/shophp
 private function setCurrentCart(Cart $cart)
 {
     $this->currentCart = $cart;
     $this->cartSession->cartId = $cart->getId();
 }