示例#1
0
 /**
  * Action order Cart
  *
  * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem
  * @param \Extcode\Cart\Domain\Model\Order\Address $billingAddress
  * @param \Extcode\Cart\Domain\Model\Order\Address $shippingAddress
  *
  * @ignorevalidation $shippingAddress
  *
  * @return void
  */
 public function orderCartAction(\Extcode\Cart\Domain\Model\Order\Item $orderItem = null, \Extcode\Cart\Domain\Model\Order\Address $billingAddress = null, \Extcode\Cart\Domain\Model\Order\Address $shippingAddress = null)
 {
     if ($orderItem == null || $billingAddress == null) {
         $this->redirect('showCart');
     }
     $this->cart = $this->cartUtility->getCartFromSession($this->settings['cart'], $this->pluginSettings);
     if ($this->cart->getCount() == 0) {
         $this->redirect('showCart');
     }
     $this->parseData();
     $this->orderUtility->checkStock($this->cart);
     $orderItem->setCartPid(intval($GLOBALS['TSFE']->id));
     if ($this->request->hasArgument('shipping_same_as_billing')) {
         $isShippingAddressSameAsBilling = $this->request->getArgument('shipping_same_as_billing');
         if ($isShippingAddressSameAsBilling == 'true') {
             $shippingAddress = null;
             $orderItem->removeShippingAddress();
         }
     }
     $this->orderUtility->saveOrderItem($this->pluginSettings, $this->cart, $orderItem, $billingAddress, $shippingAddress);
     $this->orderUtility->handleStock($this->cart);
     $this->orderUtility->handlePayment($orderItem, $this->cart);
     $this->orderUtility->autoGenerateDocuments($orderItem, $this->pluginSettings);
     $this->sendMails($orderItem, $billingAddress, $shippingAddress);
     $this->view->assign('cart', $this->cart);
     $this->view->assign('orderItem', $orderItem);
     $paymentId = $this->cart->getPayment()->getId();
     if (intval($this->pluginSettings['payments']['options'][$paymentId]['preventClearCart']) != 1) {
         $this->cart = $this->cartUtility->getNewCart($this->settings['cart'], $this->pluginSettings);
     }
     $this->sessionHandler->writeToSession($this->cart, $this->settings['cart']['pid']);
 }
示例#2
0
 /**
  * @return null
  */
 private function getConditionFromCart()
 {
     $condition = null;
     if ($this->isFree($this->cart->getGross())) {
         return 0.0;
     }
     switch ($this->getExtraType()) {
         case 'by_price':
             $condition = $this->cart->getGross();
             break;
         case 'by_quantity':
             $condition = $this->cart->getCount();
             break;
         case 'by_service_attribute_1_sum':
             $condition = $this->cart->getSumServiceAttribute1();
             break;
         case 'by_service_attribute_1_max':
             $condition = $this->cart->getMaxServiceAttribute1();
             break;
         case 'by_service_attribute_2_sum':
             $condition = $this->cart->getSumServiceAttribute2();
             break;
         case 'by_service_attribute_2_max':
             $condition = $this->cart->getMaxServiceAttribute2();
             break;
         case 'by_service_attribute_3_sum':
             $condition = $this->cart->getSumServiceAttribute3();
             break;
         case 'by_service_attribute_3_max':
             $condition = $this->cart->getMaxServiceAttribute3();
             break;
         default:
     }
     return $condition;
 }
示例#3
0
文件: CartTest.php 项目: extcode/cart
 /**
  * @test
  */
 public function addFirstCartProductToCartChangeCountOfProducts()
 {
     $product = new \Extcode\Cart\Domain\Model\Cart\Product('simple', 1, 0, 0, 1, 'First Product', 10.0, $this->normalTaxClass, 1, false);
     $this->grossCart->addProduct($product);
     $this->assertSame(1, $this->grossCart->getCount());
 }