/** * @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; }
/** * Send Mails * * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem Order Item * @param \Extcode\Cart\Domain\Model\Order\Address $billingAddress Billing Address * @param \Extcode\Cart\Domain\Model\Order\Address $shippingAddress Shipping Address * * @return void */ protected function sendMails(\Extcode\Cart\Domain\Model\Order\Item $orderItem, \Extcode\Cart\Domain\Model\Order\Address $billingAddress, \Extcode\Cart\Domain\Model\Order\Address $shippingAddress = null) { $paymentId = $this->cart->getPayment()->getId(); if (intval($this->pluginSettings['payments']['options'][$paymentId]['preventBuyerEmail']) != 1) { $this->sendBuyerMail($orderItem, $billingAddress, $shippingAddress); } if (intval($this->pluginSettings['payments']['options'][$paymentId]['preventSellerEmail']) != 1) { $this->sendSellerMail($orderItem, $billingAddress, $shippingAddress); } }
/** * Return Is Useable For A Given Price * * @return bool */ public function getIsUseable() { $isUseable = $this->cartMinPrice <= $this->cart->getGross(); return $isUseable; }
/** * Add Shipping * * @return void */ protected function addShipping() { $shipping = $this->cart->getShipping(); /** * Order Shipping * @var $orderShipping \Extcode\Cart\Domain\Model\Order\Shipping */ $orderShipping = $this->objectManager->get('Extcode\\Cart\\Domain\\Model\\Order\\Shipping'); $orderShipping->setPid($this->storagePid); $orderShipping->setServiceId($shipping->getId()); $orderShipping->setName($shipping->getName()); $orderShipping->setStatus($shipping->getStatus()); $orderShipping->setGross($shipping->getGross()); $orderShipping->setNet($shipping->getNet()); $orderShipping->setTaxClass($this->taxClasses[$shipping->getTaxClass()->getId()]); $orderShipping->setTax($shipping->getTax()); $orderShipping->setNote($shipping->getNote()); $this->shippingRepository->add($orderShipping); $this->orderItem->setShipping($orderShipping); }
/** * Parse Services * * @param string $className * @param array $pluginSettings Plugin Settings * @param \Extcode\Cart\Domain\Model\Cart\Cart $cart * * @return array */ public function parseServices($className, array $pluginSettings, \Extcode\Cart\Domain\Model\Cart\Cart $cart) { $services = []; $type = strtolower($className) . 's'; if ($pluginSettings[$type]['options']) { foreach ($pluginSettings[$type]['options'] as $key => $value) { $class = '\\Extcode\\Cart\\Domain\\Model\\Cart\\' . $className; /** * Service * @var \Extcode\Cart\Domain\Model\Cart\Service $service */ $service = new $class($key, $value['title'], $cart->getTaxClass($value['taxClassId']), $value['status'], $value['note'], $cart->getIsNetCart()); if ($className == 'Payment') { if ($value['provider']) { $service->setProvider($value['provider']); } } if (is_array($value['extra'])) { $service->setExtraType($value['extra']['_typoScriptNodeValue']); unset($value['extra']['_typoScriptNodeValue']); foreach ($value['extra'] as $extraKey => $extraValue) { $extra = new \Extcode\Cart\Domain\Model\Cart\Extra($extraKey, $extraValue['value'], $extraValue['extra'], $cart->getTaxClass($value['taxClassId']), $cart->getIsNetCart()); $service->addExtra($extra); } } elseif (!floatval($value['extra'])) { $service->setExtraType($value['extra']); $extra = new \Extcode\Cart\Domain\Model\Cart\Extra(0, 0, 0, $cart->getTaxClass($value['taxClassId']), $cart->getIsNetCart()); $service->addExtra($extra); } else { $service->setExtraType('simple'); $extra = new \Extcode\Cart\Domain\Model\Cart\Extra(0, 0, $value['extra'], $cart->getTaxClass($value['taxClassId']), $cart->getIsNetCart()); $service->addExtra($extra); } if ($value['free']) { $service->setFreeFrom($value['free']['from']); $service->setFreeUntil($value['free']['until']); } if ($value['available']) { $service->setAvailableFrom($value['available']['from']); $service->setAvailableUntil($value['available']['until']); if ($value['available']['fallBackId']) { $service->setFallBackId($value['available']['fallBackId']); } } if ($pluginSettings[$type]['preset'] == $key) { $service->setIsPreset(true); } $additional = []; if ($value['additional.']) { foreach ($value['additional'] as $additionalKey => $additionalValue) { if ($additionalValue['value']) { $additional[$additionalKey] = $additionalValue['value']; } } } $service->setAdditionalArray($additional); $service->setCart($cart); $services[$key] = $service; } } return $services; }
/** * @test */ public function getSubtotalGrossInitiallyReturnsZero() { $this->assertSame(0.0, $this->grossCart->getSubtotalGross()); $this->assertSame(0.0, $this->netCart->getSubtotalGross()); }