/** * @test */ public function addFirstNetCartProductToGrossCartChangeGrossOfCart() { $productPrice = 10.0; $netProduct = new \Extcode\Cart\Domain\Model\Cart\Product('simple', 1, 0, 0, 1, 'First Net Product', $productPrice, $this->normalTaxClass, 1, true); $this->grossCart->addProduct($netProduct); $this->assertSame($productPrice * (1 + $this->normalTaxClass->getCalc()), $this->grossCart->getGross()); }
/** * @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; }
protected function updateService() { $this->parseData(); if (!$this->cart->getPayment()->isAvailable($this->cart->getGross())) { $fallBackId = $this->cart->getPayment()->getFallBackId(); if ($fallBackId) { $payment = $this->cartUtility->getServiceById($this->payments, $fallBackId); $this->cart->setPayment($payment); } } if (!$this->cart->getShipping()->isAvailable($this->cart->getGross())) { $fallBackId = $this->cart->getShipping()->getFallBackId(); if ($fallBackId) { $shipping = $this->cartUtility->getServiceById($this->shippings, $fallBackId); $this->cart->setShipping($shipping); } } }
/** * Return Is Useable For A Given Price * * @return bool */ public function getIsUseable() { $isUseable = $this->cartMinPrice <= $this->cart->getGross(); return $isUseable; }
/** * Save Order * * @param array $pluginSettings TypoScript Plugin Settings * @param \Extcode\Cart\Domain\Model\Cart\Cart $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 * * @return void */ public function saveOrderItem(array $pluginSettings, \Extcode\Cart\Domain\Model\Cart\Cart $cart, \Extcode\Cart\Domain\Model\Order\Item $orderItem, \Extcode\Cart\Domain\Model\Order\Address $billingAddress, \Extcode\Cart\Domain\Model\Order\Address $shippingAddress = null) { $this->storagePid = $pluginSettings['settings']['order']['pid']; $this->cart = $cart; $this->orderItem = $orderItem; if (!$this->objectManager) { $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); } $orderItem->setPid($this->storagePid); $orderItem->setFeUser((int) $GLOBALS['TSFE']->fe_user->user['uid']); $orderItem->setGross($this->cart->getGross()); $orderItem->setNet($this->cart->getNet()); $orderItem->setTotalGross($this->cart->getTotalGross()); $orderItem->setTotalNet($this->cart->getTotalNet()); $billingAddress->setPid($this->storagePid); $orderItem->setBillingAddress($billingAddress); if ($shippingAddress && !$shippingAddress->_isDirty()) { $shippingAddress->setPid($this->storagePid); $orderItem->setShippingAddress($shippingAddress); } if (!$orderItem->_isDirty()) { $this->orderItemRepository->add($orderItem); $this->addTaxClasses(); $this->addTaxes('TotalTax'); $this->addTaxes('Tax'); if ($this->cart->getProducts()) { $this->addProducts(); } if ($this->cart->getCoupons()) { $this->addCoupons(); } if ($this->cart->getPayment()) { $this->addPayment(); } if ($this->cart->getShipping()) { $this->addShipping(); } } $orderNumber = $this->getOrderNumber($pluginSettings); $orderItem->setOrderNumber($orderNumber); $orderItem->setOrderDate(new \DateTime()); $this->persistenceManager->persistAll(); $this->cart->setOrderId($orderItem->getUid()); $this->cart->setOrderNumber($orderItem->getOrderNumber()); }