diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..4071ba38 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +Documentation/_make + +.DS_Store +.idea diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/ChangeLog @@ -0,0 +1 @@ + diff --git a/Classes/.htaccess b/Classes/.htaccess new file mode 100644 index 00000000..896fbc5a --- /dev/null +++ b/Classes/.htaccess @@ -0,0 +1,2 @@ +Order deny,allow +Deny from all \ No newline at end of file diff --git a/Classes/Controller/CartController.php b/Classes/Controller/CartController.php new file mode 100644 index 00000000..2a3cc136 --- /dev/null +++ b/Classes/Controller/CartController.php @@ -0,0 +1,499 @@ + + */ +class CartController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController +{ + + /** + * Session Handler + * + * @var \Extcode\Cart\Service\SessionHandler + * @inject + */ + protected $sessionHandler; + + /** + * @var \Extcode\Cart\Domain\Repository\Product\CouponRepository + * @inject + */ + protected $couponRepository; + + /** + * Cart Utility + * + * @var \Extcode\Cart\Utility\CartUtility + * @inject + */ + protected $cartUtility; + + /** + * Order Utility + * + * @var \Extcode\Cart\Utility\OrderUtility + * @inject + */ + protected $orderUtility; + + /** + * Parser Utility + * + * @var \Extcode\Cart\Utility\ParserUtility + * @inject + */ + protected $parserUtility; + + /** + * Cart + * + * @var \Extcode\Cart\Domain\Model\Cart\Cart + */ + protected $cart; + + /** + * GpValues + * + * @var array + */ + protected $gpValues = array(); + + /** + * TaxClasses + * + * @var array + */ + protected $taxClasses = array(); + + /** + * Shippings + * + * @var array + */ + protected $shippings = array(); + + /** + * Payments + * + * @var array + */ + protected $payments = array(); + + /** + * Specials + * + * @var array + */ + protected $specials = array(); + + /** + * Plugin Settings + * + * @var array + */ + protected $pluginSettings; + + /** + * Action initialize + * + * @return void + */ + public function initializeAction() + { + $this->pluginSettings = + $this->configurationManager->getConfiguration( + \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK + ); + + $this->pageId = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'); + + if (TYPO3_MODE === 'BE') { + $frameworkConfiguration = $this->configurationManager->getConfiguration( + \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK + ); + $persistenceConfiguration = array('persistence' => array('storagePid' => $this->pageId)); + $this->configurationManager->setConfiguration( + array_merge($frameworkConfiguration, $persistenceConfiguration) + ); + } + + $this->piVars = $this->request->getArguments(); + } + + + protected function initializeOrderAction() + { + /* + if ($this->request->hasArgument('shipping_same_as_billing')) { + $this->arguments['orderItem'] + ->getPropertyMappingConfiguration() + ->skipProperties('shippingAddress'); + } + */ + } + + /** + * Action Show Cart + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem OrderItem + * @param \Extcode\Cart\Domain\Model\Order\Address $billingAddress Billing + * @param \Extcode\Cart\Domain\Model\Order\Address $shippingAddress Shipping + * + * @return void + */ + public function showCartAction( + \Extcode\Cart\Domain\Model\Order\Item $orderItem = null, + \Extcode\Cart\Domain\Model\Order\Address $billingAddress = null, + \Extcode\Cart\Domain\Model\Order\Address $shippingAddress = null + ) { + $this->cart = $this->cartUtility->getCartFromSession($this->settings['cart'], $this->pluginSettings); + + $this->view->assign('cart', $this->cart); + + $this->parseData(); + + $assignArguments = array( + 'shippings' => $this->shippings, + 'payments' => $this->payments, + 'specials' => $this->specials + ); + $this->view->assignMultiple($assignArguments); + + if ($orderItem == null) { + $orderItem = new \Extcode\Cart\Domain\Model\Order\Item(); + } + if ($billingAddress == null) { + $billingAddress = new \Extcode\Cart\Domain\Model\Order\Address(); + } + if ($shippingAddress == null) { + $shippingAddress = new \Extcode\Cart\Domain\Model\Order\Address(); + } + + $assignArguments = array( + 'orderItem' => $orderItem, + 'billingAddress' => $billingAddress, + 'shippingAddress' => $shippingAddress + ); + $this->view->assignMultiple($assignArguments); + } + + /** + * Action showMini + * + * @return void + */ + public function showMiniAction() + { + $this->cart = $this->cartUtility->getCartFromSession($this->settings['cart'], $this->pluginSettings); + $this->view->assign('cart', $this->cart); + + $this->parseData(); + } + + /** + * Action Clear Cart + * + * @return void + */ + public function clearCartAction() + { + $this->cart = $this->cartUtility->getNewCart($this->settings['cart'], $this->pluginSettings); + + $this->sessionHandler->writeToSession($this->cart, $this->settings['cart']['pid']); + + $this->redirect('showCart'); + } + + /** + * Action Update Cart + * + * @return void + */ + public function updateCartAction() + { + if ($this->request->hasArgument('quantities')) { + $this->cart = $this->cartUtility->getCartFromSession($this->settings['cart'], $this->pluginSettings); + $updateQuantities = $this->request->getArgument('quantities'); + if (is_array($updateQuantities)) { + foreach ($updateQuantities as $productId => $quantity) { + $product = $this->cart->getProductById($productId); + if ($product) { + if (ctype_digit($quantity)) { + $quantity = intval($quantity); + $product->changeQuantity(intval($quantity)); + } elseif (is_array($quantity)) { + $product->changeVariantsQuantity($quantity); + } + } + } + $this->cart->reCalc(); + } + $this->sessionHandler->writeToSession($this->cart, $this->settings['cart']['pid']); + } + $this->redirect('showCart'); + } + + /** + * Action Add Product + * + * @return void + */ + public function addProductAction() + { + $this->cart = $this->cartUtility->getCartFromSession($this->settings['cart'], $this->pluginSettings); + + // TODO: Check if the function call is necessary. + $this->parseData(); + + $products = $this->cartUtility->getProductsFromRequest( + $this->pluginSettings, + $this->request, + $this->cart->getTaxClasses() + ); + + foreach ($products as $product) { + $this->cart->addProduct($product); + } + + $this->sessionHandler->writeToSession($this->cart, $this->settings['cart']['pid']); + + $this->redirect('showCart'); + } + + /** + * Action Add Coupon + * + * @return void + */ + public function addCouponAction() + { + if ($this->request->hasArgument('couponCode')) { + $this->cart = $this->cartUtility->getCartFromSession($this->settings['cart'], $this->pluginSettings); + + $couponCode = $this->request->getArgument('couponCode'); + $coupon = $this->couponRepository->findOneByCode($couponCode); + if ($coupon) { + $couponWasAdded = $this->cart->addCoupon($coupon); + } + + $this->sessionHandler->writeToSession($this->cart, $this->settings['cart']['pid']); + } + + $this->redirect('showCart'); + } + + /** + * Action removeProduct + * + * @return void + */ + public function removeProductAction() + { + if ($this->request->hasArgument('product')) { + $this->cart = $this->sessionHandler->restoreFromSession($this->settings['cart']['pid']); + $this->cart->removeProductById($this->request->getArgument('product')); + + $this->sessionHandler->writeToSession($this->cart, $this->settings['cart']['pid']); + } + $this->redirect('showCart'); + } + + /** + * Action setShipping + * + * @param int $shippingId ShippingId + * + * @return void + */ + public function setShippingAction($shippingId) + { + $cart = $this->cartUtility->getCartFromSession($this->settings['cart'], $this->pluginSettings); + + $this->shippings = $this->parserUtility->parseServices('Shipping', $this->pluginSettings, $cart); + + $shipping = $this->shippings[$shippingId]; + + if ($shipping) { + $cart->setShipping($shipping); + } + + $this->sessionHandler->writeToSession($cart, $this->settings['cart']['pid']); + + $this->redirect('showCart'); + } + + /** + * Action setPayment + * + * @param int $paymentId PaymentId + * + * @return void + */ + public function setPaymentAction($paymentId) + { + $cart = $this->cartUtility->getCartFromSession($this->settings['cart'], $this->pluginSettings); + + $this->payments = $this->parserUtility->parseServices('Payment', $this->pluginSettings, $cart); + + $payment = $this->payments[$paymentId]; + + if ($payment) { + $cart->setPayment($payment); + } + + $this->sessionHandler->writeToSession($cart, $this->settings['cart']['pid']); + + $this->redirect('showCart'); + } + + /** + * 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, + \Extcode\Cart\Domain\Model\Order\Address $billingAddress, + \Extcode\Cart\Domain\Model\Order\Address $shippingAddress = null + ) { + $this->cart = $this->cartUtility->getCartFromSession($this->settings['cart'], $this->pluginSettings); + $this->parseData(); + + $this->orderUtility->checkStock($this->cart); + + 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->sendMails($orderItem, $billingAddress, $shippingAddress); + + $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']); + } + + /** + * 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); + } + } + + /** + * Send a Mail to Buyer + * + * @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 sendBuyerMail( + \Extcode\Cart\Domain\Model\Order\Item $orderItem, + \Extcode\Cart\Domain\Model\Order\Address $billingAddress, + \Extcode\Cart\Domain\Model\Order\Address $shippingAddress = null + ) { + $mailHandler = $this->objectManager->get('Extcode\Cart\Service\MailHandler'); + $mailHandler->setCart($this->cart); + $mailHandler->sendBuyerMail($orderItem, $billingAddress, $shippingAddress); + } + + /** + * Send a Mail to Seller + * + * @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 sendSellerMail( + \Extcode\Cart\Domain\Model\Order\Item $orderItem, + \Extcode\Cart\Domain\Model\Order\Address $billingAddress, + \Extcode\Cart\Domain\Model\Order\Address $shippingAddress = null + ) { + $mailHandler = $this->objectManager->get('Extcode\Cart\Service\MailHandler'); + $mailHandler->setCart($this->cart); + $mailHandler->sendSellerMail($orderItem, $billingAddress, $shippingAddress); + } + + /** + * Parse Data + * + * @return void + */ + protected function parseData() + { + // parse all shippings + $this->shippings = $this->parserUtility->parseServices('Shipping', $this->pluginSettings, $this->cart); + + // parse all payments + $this->payments = $this->parserUtility->parseServices('Payment', $this->pluginSettings, $this->cart); + + // parse all specials + $this->specials = $this->parserUtility->parseServices('Special', $this->pluginSettings, $this->cart); + } + +} \ No newline at end of file diff --git a/Classes/Controller/OrderController.php b/Classes/Controller/OrderController.php new file mode 100644 index 00000000..36f26fe3 --- /dev/null +++ b/Classes/Controller/OrderController.php @@ -0,0 +1,510 @@ + + */ +class OrderController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController +{ + + /** + * Persistence Manager + * + * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager + * @inject + */ + protected $persistenceManager; + + /** + * Order Item Repository + * + * @var \Extcode\Cart\Domain\Repository\Order\ItemRepository + * @inject + */ + protected $itemRepository; + + /** + * Order Utility + * + * @var \Extcode\Cart\Utility\OrderUtility + * @inject + */ + protected $orderUtility; + + /** + * Page Id + * + * @var int + */ + protected $pageId; + + /** + * PiVars + * + * @var array + */ + protected $piVars; + + /** + * Initialize Update Action + * + * @return void + */ + public function initializeUpdateAction() + { + if ($this->request->hasArgument('orderItem')) { + $orderItem = $this->request->getArgument('orderItem'); + + $invoiceDateString = $orderItem['invoiceDate']; + $orderItem['invoiceDate'] = \DateTime::createFromFormat('d.m.Y', $invoiceDateString); + + $this->request->setArgument('orderItem', $orderItem); + } + $this->arguments-> + getArgument('orderItem')-> + getPropertyMappingConfiguration()-> + forProperty('birthday')-> + setTypeConverterOption( + 'TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\DateTimeConverter', + DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'd.m.Y' + ); + } + + /** + * Initialize Action + * + * @return void + */ + protected function initializeAction() + { + if (!$this->persistenceManager) { + $this->persistenceManager = $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager'); + } + + $this->pageId = (int)(GeneralUtility::_GET('id')) ? Utility\GeneralUtility::_GET('id') : 1; + + if (TYPO3_MODE === 'BE') { + $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $GLOBALS['BE_USER']->getPagePermsClause(1)); + + $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface'); + + $frameworkConfiguration = + $configurationManager->getConfiguration( + \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK + ); + $persistenceConfiguration = array('persistence' => array('storagePid' => $this->pageId)); + $configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration)); + + $this->settings = $configurationManager->getConfiguration( + \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, + $this->request->getControllerExtensionName(), + $this->request->getPluginName() + ); + } + + $this->piVars = $this->request->getArguments(); + } + + /** + * Statistic Action + * + * @return void + */ + public function statisticAction() + { + $orderItems = $this->itemRepository->findAll($this->piVars); + + $this->view->assign('piVars', $this->piVars); + + $statistics = array( + 'gross' => 0.0, + 'net' => 0.0, + 'orderItemCount' => count($orderItems), + 'orderProductCount' => 0, + ); + + foreach ($orderItems as $orderItem) { + /** @var \Extcode\Cart\Domain\Model\Order\Item $orderItem */ + $statistics['orderItemGross'] += $orderItem->getGross(); + $statistics['orderItemNet'] += $orderItem->getNet(); + + $orderProducts = $orderItem->getProducts(); + + if ($orderProducts) { + foreach ($orderProducts as $orderProduct) { + $statistics['orderProductCount'] += $orderProduct->getCount(); + } + } + } + + if ($statistics['orderItemCount'] > 0) { + $statistics['orderItemAverageGross'] = $statistics['orderItemGross'] / $statistics['orderItemCount']; + $statistics['orderItemAverageNet'] = $statistics['orderItemNet'] / $statistics['orderItemCount']; + } + + $this->view->assign('statistics', $statistics); + } + + /** + * List Action + * + * @return void + */ + public function listAction() + { + if (TYPO3_MODE === 'BE') { + $orderItems = $this->itemRepository->findAll($this->piVars); + } else { + $feUser = (int) $GLOBALS['TSFE']->fe_user->user['uid']; + $orderItems = $this->itemRepository->findByFeUser($feUser); + } + $this->view->assign('piVars', $this->piVars); + $this->view->assign('orderItems', $orderItems); + + $this->view->assign('paymentStatus', $this->getPaymentStatus()); + $this->view->assign('shippingStatus', $this->getShippingStatus()); + + $pdfRendererInstalled = Utility\ExtensionManagementUtility::isLoaded('wt_cart_pdf'); + $this->view->assign('pdfRendererInstalled', $pdfRendererInstalled); + } + + /** + * Export Action + * + * @return void + */ + public function exportAction() + { + $format = $this->request->getFormat(); + + if ($format == 'csv') { + $title = 'Order-Export-' . date('Y-m-d_H-i'); + + $this->response->setHeader('Content-Type', 'text/' . $format, true); + $this->response->setHeader('Content-Description', 'File transfer', true); + $this->response->setHeader('Content-Disposition', 'attachment; filename="' . $title . '.' . $format . '"', + true); + } + + $orderItems = $this->itemRepository->findAll($this->piVars); + + $this->view->assign('piVars', $this->piVars); + $this->view->assign('orderItems', $orderItems); + + $pdfRendererInstalled = Utility\ExtensionManagementUtility::isLoaded('wt_cart_pdf'); + $this->view->assign('pdfRendererInstalled', $pdfRendererInstalled); + } + + /** + * Show Action + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem + * + * @ignorevalidation $orderItem + * + * @return void + */ + public function showAction(\Extcode\Cart\Domain\Model\Order\Item $orderItem) + { + if (TYPO3_MODE === 'FE') { + $feUser = (int) $GLOBALS['TSFE']->fe_user->user['uid']; + if ($orderItem->getFeUser() != $feUser) { + $this->addFlashMessage( + 'Access denied.', + '', + \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR + ); + $this->redirect('list'); + } + } + + $this->view->assign('orderItem', $orderItem); + + $pdfRendererInstalled = Utility\ExtensionManagementUtility::isLoaded('wt_cart_pdf'); + $this->view->assign('pdfRendererInstalled', $pdfRendererInstalled); + } + + /** + * Edit Action + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem + * + * @return void + */ + public function editAction(\Extcode\Cart\Domain\Model\Order\Item $orderItem) + { + $this->view->assign('orderItem', $orderItem); + } + + /** + * Update Action + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem + * + * @return void + */ + public function updateAction(\Extcode\Cart\Domain\Model\Order\Item $orderItem) + { + $this->itemRepository->update($orderItem); + $this->persistenceManager->persistAll(); + + $this->redirect('show', null, null, array('orderItem' => $orderItem)); + } + + /** + * Generate Invoice Number Action + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem + * + * @return void + */ + public function generateInvoiceNumberAction(\Extcode\Cart\Domain\Model\Order\Item $orderItem) + { + if (!$orderItem->getInvoiceNumber()) { + $invoiceNumber = $this->generateInvoiceNumber($orderItem); + $orderItem->setInvoiceNumber($invoiceNumber); + $orderItem->setInvoiceDate(new \DateTime()); + + $this->itemRepository->update($orderItem); + $this->persistenceManager->persistAll(); + + $msg = 'Invoice Number ' . $invoiceNumber . ' was generated.'; + + $this->addFlashMessage($msg); + } + + $this->redirect('list'); + } + + /** + * Generate Invoice Document Action + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem + * + * @return void + */ + public function generateInvoiceDocumentAction(\Extcode\Cart\Domain\Model\Order\Item $orderItem) + { + if (!$orderItem->getInvoiceNumber()) { + $invoiceNumber = $this->generateInvoiceNumber($orderItem); + $orderItem->setInvoiceNumber($invoiceNumber); + + $msg = 'Invoice Number was generated.'; + $this->flashMessageContainer->add($msg); + } + + if ($orderItem->getInvoiceNumber()) { + $this->generateInvoiceDocument($orderItem); + + $this->itemRepository->update($orderItem); + $this->persistenceManager->persistAll(); + + $msg = 'Invoice Document was generated.'; + $this->flashMessageContainer->add($msg); + } + + $this->redirect('list'); + } + + /** + * Download Invoice Document Action + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem + * + * @return void + */ + public function downloadInvoiceDocumentAction(\Extcode\Cart\Domain\Model\Order\Item $orderItem) + { + $file = PATH_site . $orderItem->getInvoicePdf(); + $fileName = 'Invoice.pdf'; + + if (is_file($file)) { + $fileLen = filesize($file); + + $headers = array( + 'Pragma' => 'public', + 'Expires' => 0, + 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', + 'Cache-Control' => 'public', + 'Content-Description' => 'File Transfer', + 'Content-Type' => 'application/pdf', + 'Content-Disposition' => 'attachment; filename="' . $fileName . '"', + 'Content-Transfer-Encoding' => 'binary', + 'Content-Length' => $fileLen + ); + + foreach ($headers as $header => $data) { + $this->response->setHeader($header, $data); + } + + $this->response->sendHeaders(); + @readfile($file); + } + + $this->redirect('list'); + } + + /** + * Generate an Invoice Number + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem + * + * @return int + */ + protected function generateInvoiceNumber(\Extcode\Cart\Domain\Model\Order\Item $orderItem) + { + $this->buildTSFE(); + $cartConf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_cart.']; + + /** + * @var \TYPO3\CMS\Extbase\Service\TypoScriptService $typoScriptService + */ + $typoScriptService = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService'); + $pluginTypoScriptSettings = $typoScriptService->convertTypoScriptArrayToPlainArray($cartConf); + + $invoiceNumber = $this->orderUtility->getInvoiceNumber($pluginTypoScriptSettings); + + return $invoiceNumber; + } + + /** + * Generate Invoice Document + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem + * + * @return void + */ + protected function generateInvoiceDocument(\Extcode\Cart\Domain\Model\Order\Item $orderItem) + { + + $this->buildTSFE($orderItem->getPid()); + + $renderer = Utility\GeneralUtility::makeInstance('Tx_WtCartPdf_Utility_Renderer'); + + $files = array(); + $errors = array(); + + $params = array( + 'orderItem' => $orderItem, + 'type' => 'invoice', + 'files' => &$files, + 'errors' => &$errors + ); + + $renderer->createPdf($params); + + if ($params['files']['invoice']) { + $orderItem->setInvoicePdf($params['files']['invoice']); + } + } + + /** + * Build TSFE + * + * @param int $pid Page Id + * + * @return void + */ + protected function buildTSFE($pid = 1, $typeNum = 0) + { + if (!is_object($GLOBALS['TT'])) { + $GLOBALS['TT'] = new \TYPO3\CMS\Core\TimeTracker\NullTimeTracker; + $GLOBALS['TT']->start(); + } + + $GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( + 'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', + $GLOBALS['TYPO3_CONF_VARS'], + $pid, + $typeNum + ); + $GLOBALS['TSFE']->connectToDB(); + $GLOBALS['TSFE']->initFEuser(); + $GLOBALS['TSFE']->id = $pid; + $GLOBALS['TSFE']->determineId(); + $GLOBALS['TSFE']->initTemplate(); + $GLOBALS['TSFE']->getConfigArray(); + } + + /** + * prepare payment status for select box + * + * @return array + */ + public function getPaymentStatus() + { + $paymentStatusArray = array(); + + $paymentStatus = new \stdClass(); + $paymentStatus->key = ''; + $paymentStatus->value = LocalizationUtility::translate( + 'tx_cart_domain_model_order_payment.status.all', + 'Cart' + ); + $paymentStatusArray[] = $paymentStatus; + + $entries = array('open', 'pending', 'paid', 'canceled'); + foreach ($entries as $entry) { + $paymentStatus = new \stdClass(); + $paymentStatus->key = $entry; + $paymentStatus->value = LocalizationUtility::translate( + 'tx_cart_domain_model_order_payment.status.' . $entry, + 'Cart' + ); + $paymentStatusArray[] = $paymentStatus; + } + return $paymentStatusArray; + } + + /** + * prepare shipping status for select box + * + * @return array + */ + public function getShippingStatus() + { + $shippingStatusArray = array(); + + $shippingStatus = new \stdClass(); + $shippingStatus->key = ''; + $shippingStatus->value = LocalizationUtility::translate( + 'tx_cart_domain_model_order_shipping.status.all', + 'Cart' + ); + $shippingStatusArray[] = $shippingStatus; + + $entries = array('open', 'on_hold', 'in_process', 'shipped'); + foreach ($entries as $entry) { + $shippingStatus = new \stdClass(); + $shippingStatus->key = $entry; + $shippingStatus->value = LocalizationUtility::translate( + 'tx_cart_domain_model_order_shipping.status.' . $entry, + 'Cart' + ); + $shippingStatusArray[] = $shippingStatus; + } + return $shippingStatusArray; + } +} diff --git a/Classes/Controller/Product/BeVariantSetController.php b/Classes/Controller/Product/BeVariantSetController.php new file mode 100644 index 00000000..12ed802b --- /dev/null +++ b/Classes/Controller/Product/BeVariantSetController.php @@ -0,0 +1,116 @@ + + */ +class BeVariantController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController +{ + + /** + * productRepository + * + * @var \Extcode\Cart\Domain\Repository\Product\BeVariantRepository + * @inject + */ + protected $beVariantRepository; + + /** + * Persistence Manager + * + * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager + * @inject + */ + protected $persistenceManager; + + /** + * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface + * @inject + */ + protected $configurationManager; + + /** + * @var int Current page + */ + protected $pageId; + + /** + * piVars + * + * @var array + */ + protected $piVars; + + /** + * Action initializer + * + * @return void + */ + protected function initializeAction() + { + $this->pageId = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'); + + $frameworkConfiguration = + $this->configurationManager->getConfiguration( + \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK + ); + $persistenceConfiguration = array('persistence' => array('storagePid' => $this->pageId)); + $this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration)); + + $this->piVars = $this->request->getArguments(); + } + + /** + * action show + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariant $beVariant + * @return void + */ + public function showAction(\Extcode\Cart\Domain\Model\Product\BeVariant $beVariant) + { + $this->view->assign('beVariant', $beVariant); + } + + /** + * action edit + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariant $beVariant + * @return void + */ + public function editAction(\Extcode\Cart\Domain\Model\Product\BeVariant $beVariant) + { + $this->view->assign('beVariant', $beVariant); + } + + /** + * action update + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariant $beVariant + * @return void + */ + public function updateAction(\Extcode\Cart\Domain\Model\Product\BeVariant $beVariant) + { + $this->beVariantRepository->update($beVariant); + + //$this->persistenceManager->persistAll(); + + $this->redirect('show', null, null, array('beVariant' => $beVariant)); + } +} diff --git a/Classes/Controller/ProductController.php b/Classes/Controller/ProductController.php new file mode 100644 index 00000000..78f28161 --- /dev/null +++ b/Classes/Controller/ProductController.php @@ -0,0 +1,147 @@ + + */ +class ProductController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController +{ + + /** + * productRepository + * + * @var \Extcode\Cart\Domain\Repository\Product\ProductRepository + * @inject + */ + protected $productRepository; + + /** + * categoryRepository + * + * @var \Extcode\Cart\Domain\Repository\CategoryRepository + * @inject + */ + protected $categoryRepository; + + /** + * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface + * @inject + */ + protected $configurationManager; + + /** + * @var int Current page + */ + protected $pageId; + + /** + * piVars + * + * @var array + */ + protected $piVars; + + /** + * Action initializer + * + * @return void + */ + protected function initializeAction() + { + $this->pageId = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'); + + $frameworkConfiguration = + $this->configurationManager->getConfiguration( + \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK + ); + $persistenceConfiguration = array('persistence' => array('storagePid' => $this->pageId)); + $this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration)); + + $this->piVars = $this->request->getArguments(); + } + + /** + * action list + * + * @return void + */ + public function listAction() + { + if ($this->settings['categoriesList']) { + $selectedCategories = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode( + ',', + $this->settings['categoriesList'], + true + ); + + $categories = array(); + + foreach ($selectedCategories as $selectedCategory) { + $category = $this->categoryRepository->findByUid($selectedCategory); + $categories = array_merge( + $categories, + $this->categoryRepository->findSubcategoriesRecursiveAsArray($category) + ); + } + + $products = $this->productRepository->findByCategories($categories); + } else { + $products = $this->productRepository->findAll($this->piVars); + } + + $this->view->assign('piVars', $this->piVars); + $this->view->assign('products', $products); + } + + /** + * action show + * + * @param \Extcode\Cart\Domain\Model\Product\Product $product + * @return void + */ + public function showAction(\Extcode\Cart\Domain\Model\Product\Product $product) + { + $this->view->assign('product', $product); + } + + /** + * action teaser + * + * @return void + */ + public function teaserAction() + { + $products = $this->productRepository->findByUids($this->settings['productUids']); + $this->view->assign('products', $products); + } + + /** + * action flexform + * + * @return void + */ + public function flexformAction() + { + $this->contentObj = $this->configurationManager->getContentObject(); + $contentId = $this->contentObj->data['uid']; + + $this->view->assign('contentId', $contentId); + } +} diff --git a/Classes/Domain/Model/Cart.php b/Classes/Domain/Model/Cart.php new file mode 100644 index 00000000..fbd3c122 --- /dev/null +++ b/Classes/Domain/Model/Cart.php @@ -0,0 +1,140 @@ + + */ +class Cart extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + /** + * FeUser + * + * @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser + */ + protected $feUser; + + /** + * Item + * + * @var \Extcode\Cart\Domain\Model\Order\Item + */ + protected $orderItem; + + /** + * Cart + * + * @var string + */ + protected $cart; + + /** + * Was Ordered + * + * @var boolean + */ + protected $wasOrdered; + + /** + * Returns FeUser + * + * @return \TYPO3\CMS\Extbase\Domain\Model\FrontendUser + */ + public function getFeUser() + { + return $this->feUser; + } + + /** + * Sets FeUser + * + * @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $feUser + * + * @return void + */ + public function setFeUser($feUser) + { + $this->feUser = $feUser; + } + + /** + * Returns Item + * + * @return \Extcode\Cart\Domain\Model\Order\Item + */ + public function getOrderItem() + { + return $this->orderItem; + } + + /** + * Sets Item + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem + * + * @return void + */ + public function setOrderItem($orderItem) + { + $this->orderItem = $orderItem; + } + + /** + * Returns Cart + * + * @return \Extcode\Cart\Domain\Model\Cart\Cart + */ + public function getCart() + { + return unserialize($this->cart); + } + + /** + * Sets Cart + * + * @param \Extcode\Cart\Domain\Model\Cart\Cart $cart + * @return void + */ + public function setCart($cart) + { + $this->cart = serialize($cart); + } + + /** + * Returns Was Ordered + * + * @return boolean + */ + public function getWasOrdered() + { + return $this->wasOrdered; + } + + /** + * Set Was Ordered + * + * @param boolean $wasOrdered + * + * @return void + */ + public function setWasOrdered($wasOrdered) + { + $this->wasOrdered = $wasOrdered; + } +} diff --git a/Classes/Domain/Model/Cart/AbstractService.php b/Classes/Domain/Model/Cart/AbstractService.php new file mode 100644 index 00000000..63603fd4 --- /dev/null +++ b/Classes/Domain/Model/Cart/AbstractService.php @@ -0,0 +1,664 @@ + + */ +abstract class AbstractService +{ + + /** + * Cart + * + * @var \Extcode\Cart\Domain\Model\Cart\Cart + */ + private $cart; + + /** + * Id + * + * @var int + */ + private $id; + + /** + * Name + * + * @var string + */ + private $name; + + /** + * Provider + * + * @var string + */ + private $provider; + + /** + * Tax Class + * + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + private $taxClass; + + /** + * Status + * + * @var string + */ + private $status = 0; + + /** + * Note + * + * @var string + */ + private $note; + + /** + * ExtraType + * + * @var string + */ + private $extratype; + + /** + * Extras + * + * @var Extra + */ + private $extras; + + /** + * Free From + * + * @var float + */ + private $freeFrom; + + /** + * Free Until + * + * @var float + */ + private $freeUntil; + + /** + * Available From + * + * @var float + */ + private $availableFrom; + + /** + * Available Until + * + * @var float + */ + private $availableUntil; + + /** + * Is Net Price + * + * @var bool + */ + private $isNetPrice; + + /** + * Is Preset + * + * @var bool + */ + private $isPreset; + + /** + * Additional + * + * @var array Additional + */ + private $additional; + + /** + * Gross + * + * @var float + */ + private $gross; + + /** + * Net + * + * @var float + */ + private $net; + + /** + * Tax + * + * @var float + */ + private $tax; + + /** + * __construct + * @param $id + * @param $name + * @param \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass + * @param $status + * @param $note + * @param $isNetPrice + */ + public function __construct( + $id, + $name, + \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass, + $status, + $note, + $isNetPrice + ) { + $this->id = $id; + $this->name = $name; + $this->taxClass = $taxClass; + $this->status = $status; + $this->note = $note; + $this->isNetPrice = $isNetPrice; + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\Cart $cart + * + * @return void + */ + public function setCart($cart) + { + $this->cart = $cart; + $this->calcGross(); + $this->calcTax(); + $this->calcNet(); + } + + /** + * Returns Provider + * + * @return string + */ + public function getProvider() + { + return $this->provider; + } + + /** + * Sets Provider + * + * @param string $provider + * + * @return void + */ + public function setProvider($provider) + { + $this->provider = $provider; + } + + /** + * @return void + */ + public function calcAll() + { + $this->calcGross(); + $this->calcTax(); + $this->calcNet(); + } + + /** + * @param bool + */ + public function setIsNetPrice($isNetPrice) + { + $this->isNetPrice = $isNetPrice; + } + + /** + * @return bool + */ + public function getIsNetPrice() + { + return $this->isNetPrice; + } + + /** + * @param bool + */ + public function setIsPreset($isPreset) + { + $this->isPreset = $isPreset; + } + + /** + * @return bool + */ + public function getIsPreset() + { + return $this->isPreset; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @return float + */ + public function getGross() + { + $this->calcGross(); + return $this->gross; + } + + /** + * @return void + */ + public function calcGross() + { + $gross = 0.0; + + $condition = $this->getConditionFromCart(); + + if (isset($condition)) { + if ($condition === 0.0) { + $gross = 0.0; + } else { + foreach ($this->extras as $extra) { + /** @var Extra $extra */ + if ($extra->leq($condition)) { + $gross = $extra->getGross(); + } else { + break; + } + } + } + } else { + $gross = $this->extras[0]->getGross(); + if ($this->getExtraType() == 'each') { + $gross = $this->cart->getCount() * $gross; + } + } + + $this->gross = $gross; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return float + */ + public function getNet() + { + $this->calcNet(); + return $this->net; + } + + /** + * @return void + */ + private function calcNet() + { + $net = 0.0; + + $condition = $this->getConditionFromCart(); + + if (isset($condition)) { + if ($condition === 0.0) { + $net = 0.0; + } else { + foreach ($this->extras as $extra) { + /** @var Extra $extra */ + if ($extra->leq($condition)) { + $net = $extra->getNet(); + } else { + break; + } + } + } + } else { + $net = $this->extras[0]->getNet(); + if ($this->getExtraType() == 'each') { + $net = $this->cart->getCount() * $net; + } + } + + $this->net = $net; + } + + /** + * @return string + */ + public function getNote() + { + return $this->note; + } + + /** + * @return float + */ + public function getTax() + { + $this->calcTax(); + return $this->tax; + } + + /** + * @return void + */ + private function calcTax() + { + $tax = 0.0; + + $condition = $this->getConditionFromCart(); + + if (isset($condition)) { + if ($condition === 0.0) { + $tax = 0.0; + } else { + foreach ($this->extras as $extra) { + /** @var Extra $extra */ + if ($extra->leq($condition)) { + $tax = $extra->getTax(); + $tax = $tax['tax']; + } else { + break; + } + } + } + } else { + $tax = $this->extras[0]->getTax(); + if ($this->getExtraType() == 'each') { + $tax = $this->cart->getCount() * $tax['tax']; + } else { + $tax = $tax['tax']; + } + } + + $this->tax = $tax; + } + + /** + * @return \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + public function getTaxClass() + { + return $this->taxClass; + } + + /** + * @return Extra + */ + public function getExtras() + { + return $this->extras; + } + + /** + * @param Extra $newExtra + */ + public function addExtra($newExtra) + { + $this->extras[] = $newExtra; + } + + /** + * @return string + */ + public function getExtraType() + { + return $this->extratype; + } + + /** + * @param string $extratype + */ + public function setExtraType($extratype) + { + $this->extratype = $extratype; + } + + /** + * @return float + */ + public function getFreeFrom() + { + return $this->freeFrom; + } + + /** + * @param $freeFrom + */ + public function setFreeFrom($freeFrom) + { + $this->freeFrom = $freeFrom; + } + + /** + * @return float + */ + public function getFreeUntil() + { + return $this->freeUntil; + } + + /** + * @param $freeUntil + */ + public function setFreeUntil($freeUntil) + { + $this->freeUntil = $freeUntil; + } + + /** + * @return float + */ + public function getAvailableFrom() + { + return $this->availableFrom; + } + + /** + * @param $availableFrom + */ + public function setAvailableFrom($availableFrom) + { + $this->availableFrom = $availableFrom; + } + + /** + * @return float + */ + public function getAvailableUntil() + { + return $this->availableUntil; + } + + /** + * @param $availableUntil + */ + public function setAvailableUntil($availableUntil) + { + $this->availableUntil = $availableUntil; + } + + /** + * @param $price + * @return bool + */ + public function isFree($price) + { + if (isset($this->freeFrom) || isset($this->freeUntil)) { + if (isset($this->freeFrom) && $price < $this->freeFrom) { + return false; + } + if (isset($this->freeUntil) && $price > $this->freeUntil) { + return false; + } + + return true; + } + + return false; + } + + /** + * @param $price + * @return bool + */ + public function isAvailable($price) + { + if (isset($this->availableFrom) && $price < $this->availableFrom) { + return false; + } + if (isset($this->availableUntil) && $price > $this->availableUntil) { + return false; + } + + return true; + } + + /** + * @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; + } + + /** + * @return array + */ + public function getAdditionalArray() + { + return $this->additional; + } + + /** + * @param array $additional + * @return void + */ + public function setAdditionalArray($additional) + { + $this->additional = $additional; + } + + /** + * @return void + */ + public function unsetAdditionalArray() + { + $this->additional = array(); + } + + /** + * @param $key + * @return mixed + */ + public function getAdditional($key) + { + return $this->additional[$key]; + } + + /** + * @param string $key + * @param mixed $value + * @return void + */ + public function setAdditional($key, $value) + { + $this->additional[$key] = $value; + } + + /** + * @param string $key + * @return void + */ + public function unsetAdditional($key) + { + if ($this->additional[$key]) { + unset($this->additional[$key]); + } + } + + /** + * @param string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } +} diff --git a/Classes/Domain/Model/Cart/BeVariant.php b/Classes/Domain/Model/Cart/BeVariant.php new file mode 100644 index 00000000..67a1864c --- /dev/null +++ b/Classes/Domain/Model/Cart/BeVariant.php @@ -0,0 +1,959 @@ + + */ +class BeVariant +{ + + /** + * Id + * + * @var string + */ + private $id = ''; + + /** + * Product + * + * @var \Extcode\Cart\Domain\Model\Cart\Product + */ + private $product = null; + + /** + * BeVariant + * + * @var \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + private $parentBeVariant = null; + + /** + * Title + * + * @var string + */ + private $title = ''; + + /** + * SKU + * + * @var string + */ + private $sku = ''; + + /** + * SKU Delimiter + * + * @var string + */ + private $skuDelimiter = '-'; + + /** + * Price Calc Method + * + * @var int + */ + private $priceCalcMethod = 0; + + /** + * Price + * + * @var float + */ + private $price = 0.0; + + /** + * Quantity + * + * @var int + */ + private $quantity = 0; + + /** + * Variants + * + * @var \Extcode\Cart\Domain\Model\Cart\BeVariant[] + */ + private $beVariants; + + /** + * Gross + * + * @var float + */ + private $gross = 0.0; + + /** + * Net + * + * @var float + */ + private $net = 0.0; + + /** + * Tax + * + * @var float + */ + private $tax = 0.0; + + /** + * Is Fe Variant + * + * @var bool + */ + private $isFeVariant = false; + + /** + * Number Of Fe Variant + * + * @var int + */ + private $hasFeVariants; + + /** + * Min + * + * @var int + */ + private $min = 0; + + /** + * Max + * + * @var int + */ + private $max = 0; + + /** + * Additional + * + * @var array Additional + */ + private $additional = array(); + + /** + * __construct + * + * @param string $id + * @param \Extcode\Cart\Domain\Model\Cart\Product $product + * @param \Extcode\Cart\Domain\Model\Cart\BeVariant $beVariant + * @param string $title + * @param string $sku + * @param int $priceCalcMethod + * @param float $price + * @param int $quantity + * + * @return \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + public function __construct( + $id, + $product = null, + $beVariant = null, + $title, + $sku, + $priceCalcMethod, + $price, + $quantity = 0 + ) { + if ($product === null && $beVariant === null) { + throw new \InvalidArgumentException; + } + + if ($product != null && $beVariant != null) { + throw new \InvalidArgumentException; + } + + if (!$title) { + throw new \InvalidArgumentException( + 'You have to specify a valid $title for constructor.', + 1437166475 + ); + } + + if (!$sku) { + throw new \InvalidArgumentException( + 'You have to specify a valid $sku for constructor.', + 1437166615 + ); + } + + if (!$quantity) { + throw new \InvalidArgumentException( + 'You have to specify a valid $quantity for constructor.', + 1437166805 + ); + } + + $this->id = $id; + + if ($product != null) { + $this->product = $product; + } + + if ($beVariant != null) { + $this->parentBeVariant = $beVariant; + } + + $this->title = $title; + $this->sku = $sku; + $this->priceCalcMethod = $priceCalcMethod; + $this->price = floatval(str_replace(',', '.', $price)); + $this->quantity = $quantity; + + $this->reCalc(); + } + + /** + * @return array + */ + public function toArray() + { + $variantArr = array( + 'id' => $this->id, + 'sku' => $this->sku, + 'title' => $this->title, + 'price_calc_method' => $this->priceCalcMethod, + 'price' => $this->getPrice(), + 'taxClass' => $this->getTaxClass(), + 'quantity' => $this->quantity, + 'price_total_gross' => $this->gross, + 'price_total_net' => $this->net, + 'tax' => $this->tax, + 'additional' => $this->additional + ); + + if ($this->beVariants) { + $innerVariantArr = array(); + + foreach ($this->beVariants as $variant) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $variant */ + array_push($innerVariantArr, array($variant->getId() => $variant->toArray())); + } + + array_push($variantArr, array('variants' => $innerVariantArr)); + } + + return $variantArr; + } + + /** + * Gets Product + * + * @return \Extcode\Cart\Domain\Model\Cart\Product + */ + public function getProduct() + { + return $this->product; + } + + /** + * Gets Parent Variant + * + * @return \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + public function getParentBeVariant() + { + return $this->parentBeVariant; + } + + /** + * Gets Is Net Price + * + * @return bool + */ + public function getIsNetPrice() + { + $isNetPrice = false; + + if ($this->getParentBeVariant()) { + $isNetPrice = $this->getParentBeVariant()->getIsNetPrice(); + } elseif ($this->getProduct()) { + $isNetPrice = $this->getProduct()->getIsNetPrice(); + } + + return $isNetPrice; + } + + /** + * Gets Id + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Gets Title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Gets Price + * + * @return float + */ + public function getPrice() + { + return $this->price; + } + + + /** + * Gets Discount + * + * @return float + */ + public function getDiscount() + { + $price = $this->getPrice(); + + if ($this->getParentBeVariant()) { + $parentPrice = $this->getParentBeVariant()->getPrice(); + } elseif ($this->getProduct()) { + $parentPrice = $this->getProduct()->getBestPrice(); + } else { + $parentPrice = 0; + } + + switch ($this->priceCalcMethod) { + case 2: + $discount = -1 * (($price / 100) * ($parentPrice)); + break; + case 4: + $discount = ($price / 100) * ($parentPrice); + break; + default: + $discount = 0; + } + + if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) { + foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount'] as $funcRef) { + if ($funcRef) { + $params = array( + 'price_calc_method' => $this->priceCalcMethod, + 'price' => &$price, + 'parent_price' => &$parentPrice, + 'discount' => &$discount, + ); + + GeneralUtility::callUserFunction($funcRef, $params, $this); + } + } + } + + return $discount; + } + + /** + * Gets Price Calculated + * + * @return float + */ + public function getPriceCalculated() + { + $price = $this->getPrice(); + + if ($this->getParentBeVariant()) { + $parentPrice = $this->getParentBeVariant()->getPrice(); + } elseif ($this->getProduct()) { + $parentPrice = $this->getProduct()->getBestPrice(); + } else { + $parentPrice = 0; + } + + switch ($this->priceCalcMethod) { + case 3: + $discount = -1 * (($price / 100) * ($parentPrice)); + break; + case 5: + $discount = ($price / 100) * ($parentPrice); + break; + default: + $discount = 0; + } + + if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) { + foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount'] as $funcRef) { + if ($funcRef) { + $params = array( + 'price_calc_method' => $this->priceCalcMethod, + 'price' => &$price, + 'parent_price' => &$parentPrice, + 'discount' => &$discount, + ); + + GeneralUtility::callUserFunction($funcRef, $params, $this); + } + } + } + + switch ($this->priceCalcMethod) { + case 1: + $parentPrice = 0.0; + break; + case 2: + $price = -1 * $price; + break; + case 4: + break; + default: + $price = 0.0; + } + + return $parentPrice + $price + $discount; + } + + /** + * Gets Parent Price + * + * @return float + */ + public function getParentPrice() + { + if ($this->priceCalcMethod == 1) { + return 0.0; + } + + if ($this->getParentBeVariant()) { + return $this->getParentBeVariant()->getPrice(); + } elseif ($this->getProduct()) { + return $this->getProduct()->getPrice(); + } + + return 0.0; + } + + /** + * Sets Price + * + * @param $price + */ + public function setPrice($price) + { + $this->price = $price; + + $this->reCalc(); + } + + /** + * Gets Price Calc Method + * + * @return int + */ + public function getPriceCalcMethod() + { + return $this->priceCalcMethod; + } + + /** + * Sets Price Calc Method + * + * @param $priceCalcMethod + * + * @return void + */ + public function setPriceCalcMethod($priceCalcMethod) + { + $this->priceCalcMethod = $priceCalcMethod; + } + + /** + * Returns the SKU Delimiter + * + * @return string + */ + public function getSkuDelimiter() + { + return $this->skuDelimiter; + } + + /** + * Sets the SKU Delimiter + * + * @param string $skuDelimiter + * @return void + */ + public function setSkuDelimiter($skuDelimiter) + { + $this->skuDelimiter = $skuDelimiter; + } + + /** + * Gets Sku + * + * @return string + */ + public function getSku() + { + $sku = ''; + + if ($this->getParentBeVariant()) { + $sku = $this->getParentBeVariant()->getSku(); + } elseif ($this->getProduct()) { + $sku = $this->getProduct()->getSku(); + } + + if ($this->isFeVariant) { + $sku .= $this->skuDelimiter . $this->id; + } else { + $sku .= $this->skuDelimiter . $this->sku; + } + + + return $sku; + } + + /** + * Sets Sku + * + * @param $sku + * + * @retrun void + */ + public function setSku($sku) + { + $this->sku = $sku; + } + + /** + * Gets Has Fe Variants + * + * @return int + */ + public function getHasFeVariants() + { + return $this->hasFeVariants; + } + + /** + * Sets Has Fe Variants + * + * @param $hasFeVariants + * + * @return void + */ + public function setHasFeVariants($hasFeVariants) + { + $this->hasFeVariants = $hasFeVariants; + } + + /** + * Gets Is Fe Variant + * + * @return bool + */ + public function getIsFeVariant() + { + return $this->isFeVariant; + } + + /** + * Sets Is Fe Variant + * + * @param bool $isFeVariant + */ + public function setIsFeVariant($isFeVariant) + { + $this->isFeVariant = $isFeVariant; + } + + /** + * Gets Quantity + * + * @return int + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * Gets Gross + * + * @return float + */ + public function getGross() + { + $this->calcGross(); + return $this->gross; + } + + /** + * Gets Net + * + * @return float + */ + public function getNet() + { + $this->calcNet(); + return $this->net; + } + + /** + * Gets Tax + * + * @return float + */ + public function getTax() + { + return $this->tax; + } + + /** + * Gets TaxClass + * + * @return \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + public function getTaxClass() + { + if ($this->getParentBeVariant()) { + $taxClass = $this->getParentBeVariant()->getTaxClass(); + } elseif ($this->getProduct()) { + $taxClass = $this->getProduct()->getTaxClass(); + } + return $taxClass; + } + + /** + * Sets Quantity + * + * @param $newQuantity + * + * @return void + */ + public function setQuantity($newQuantity) + { + $this->quantity = $newQuantity; + + $this->reCalc(); + } + + /** + * @param $newQuantity + */ + public function changeQuantity($newQuantity) + { + $this->quantity = $newQuantity; + + if ($this->beVariants) { + foreach ($this->beVariants as $beVariant) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $beVariant */ + $beVariant->changeQuantity($newQuantity); + } + } + + $this->reCalc(); + } + + /** + * @param $variantQuantityArray + * @internal param $id + * @internal param $newQuantity + */ + public function changeVariantsQuantity($variantQuantityArray) + { + foreach ($variantQuantityArray as $beVariantId => $quantity) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $beVariant */ + $beVariant = $this->beVariants[$beVariantId]; + + if (is_array($quantity)) { + $beVariant->changeVariantsQuantity($quantity); + $this->reCalc(); + } else { + $beVariant->changeQuantity($quantity); + $this->reCalc(); + } + } + } + + /** + * @param array $newVariants + * @return mixed + */ + public function addBeVariants($newVariants) + { + foreach ($newVariants as $newVariant) { + $this->addBeVariant($newVariant); + } + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\BeVariant $newBeVariant + * @return mixed + */ + public function addBeVariant(\Extcode\Cart\Domain\Model\Cart\BeVariant $newBeVariant) + { + $newBeVariantId = $newBeVariant->getId(); + + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $beVariant */ + $beVariant = $this->beVariants[$newBeVariantId]; + + if ($beVariant) { + if ($beVariant->getBeVariants()) { + $beVariant->addBeVariants($newBeVariant->getBeVariants()); + } else { + $newQuantity = $beVariant->getQuantity() + $newBeVariant->getQuantity(); + $beVariant->setQuantity($newQuantity); + } + } else { + $this->beVariants[$newBeVariantId] = $newBeVariant; + } + + $this->reCalc(); + } + + /** + * @return array + */ + public function getBeVariants() + { + return $this->beVariants; + } + + /** + * @param $beVariantId + * + * @return \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + public function getBeVariantById($beVariantId) + { + return $this->beVariants[$beVariantId]; + } + + /** + * @param $beVariantId + * + * @return \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + public function getBeVariant($beVariantId) + { + return $this->getBeVariantById($beVariantId); + } + + /** + * @param $beVariantsArray + * @return bool|int + */ + public function removeBeVariants($beVariantsArray) + { + foreach ($beVariantsArray as $beVariantId => $value) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $beVariant */ + $beVariant = $this->beVariants[$beVariantId]; + if ($beVariant) { + if (is_array($value)) { + $beVariant->removeBeVariants($value); + + if (!$beVariant->getBeVariants()) { + unset($this->beVariants[$beVariantId]); + } + + $this->reCalc(); + } else { + unset($this->beVariants[$beVariantId]); + + $this->reCalc(); + } + } else { + return -1; + } + } + + return true; + } + + /** + * @return void + */ + private function calcGross() + { + if ($this->getIsNetPrice() == false) { + if ($this->beVariants) { + $sum = 0.0; + foreach ($this->beVariants as $beVariant) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $beVariant */ + $sum += $beVariant->getGross(); + } + $this->gross = $sum; + } else { + $this->gross = $this->getPriceCalculated() * $this->quantity; + } + } else { + $this->calcNet(); + $this->calcTax(); + $this->gross = $this->net + $this->tax; + } + } + + /** + * @return void + */ + private function calcTax() + { + if ($this->getIsNetPrice() == false) { + $this->calcGross(); + $this->tax = ($this->gross / (1 + $this->getTaxClass()->getCalc())) * ($this->getTaxClass()->getCalc()); + } else { + $this->calcNet(); + $this->tax = ($this->net * $this->getTaxClass()->getCalc()); + } + } + + /** + * @return void + */ + private function calcNet() + { + if ($this->getIsNetPrice() == true) { + if ($this->beVariants) { + $sum = 0.0; + foreach ($this->beVariants as $beVariant) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $beVariant */ + $sum += $beVariant->getNet(); + } + $this->net = $sum; + } else { + $this->net = $this->getPriceCalculated() * $this->quantity; + } + } else { + $this->calcGross(); + $this->calcTax(); + $this->net = $this->gross - $this->tax; + } + } + + /** + * @return void + */ + private function reCalc() + { + if ($this->beVariants) { + $quantity = 0; + foreach ($this->beVariants as $beVariant) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $beVariant */ + $quantity += $beVariant->getQuantity(); + } + + if ($this->quantity != $quantity) { + $this->quantity = $quantity; + } + } + + if ($this->getIsNetPrice() == false) { + $this->calcGross(); + $this->calcTax(); + $this->calcNet(); + } else { + $this->calcNet(); + $this->calcTax(); + $this->calcGross(); + } + } + + /** + * @return array + */ + public function getAdditionalArray() + { + return $this->additional; + } + + /** + * @param $additional + * @return void + */ + public function setAdditionalArray($additional) + { + $this->additional = $additional; + } + + /** + * @param $key + * @return mixed + */ + public function getAdditional($key) + { + return $this->additional[$key]; + } + + /** + * @param string $key + * @param mixed $value + * @return void + */ + public function setAdditional($key, $value) + { + $this->additional[$key] = $value; + } + + /** + * @return int + */ + public function getMin() + { + return $this->min; + } + + /** + * @param int $min + * + * @return void + */ + public function setMin($min) + { + if ($min < 0 || $min > $this->max) { + throw new \InvalidArgumentException; + } + + $this->min = $min; + } + + /** + * @return int + */ + public function getMax() + { + return $this->max; + } + + /** + * @param int $max + * + * @return void + */ + public function setMax($max) + { + if ($max < 0 || $max < $this->min) { + throw new \InvalidArgumentException; + } + + $this->max = $max; + } +} diff --git a/Classes/Domain/Model/Cart/Cart.php b/Classes/Domain/Model/Cart/Cart.php new file mode 100644 index 00000000..fca6f910 --- /dev/null +++ b/Classes/Domain/Model/Cart/Cart.php @@ -0,0 +1,1380 @@ + + */ +class Cart +{ + + /** + * Tax Classes + * + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass[] + */ + private $taxClasses; + + /** + * Net + * + * @var float + */ + private $net; + + /** + * Gross + * + * @var float + */ + private $gross; + + /** + * Taxes + * + * @var array + */ + private $taxes; + + /** + * Count + * + * @var int + */ + private $count; + + /** + * Products + * + * @var \Extcode\Cart\Domain\Model\Cart\Product[] + */ + private $products; + + /** + * Shipping + * + * @var \Extcode\Cart\Domain\Model\Cart\Shipping + */ + private $shipping; + + /** + * Payment + * + * @var \Extcode\Cart\Domain\Model\Cart\Payment + */ + private $payment; + + /** + * Specials + * + * @var \Extcode\Cart\Domain\Model\Cart\Special[] + */ + private $specials; + + /** + * Max Service Attribute 1 + * + * @var float + */ + private $maxServiceAttr1 = 0.0; + + /** + * Max Service Attribute 2 + * + * @var float + */ + private $maxServiceAttr2 = 0.0; + + /** + * Max Service Attribute 3 + * + * @var float + */ + private $maxServiceAttr3 = 0.0; + + /** + * Sum Service Attribute 1 + * + * @var float + */ + private $sumServiceAttr1 = 0.0; + + /** + * Sum Service Attribute 2 + * + * @var float + */ + private $sumServiceAttr2 = 0.0; + + /** + * Sum Service Attribute 3 + * + * @var float + */ + private $sumServiceAttr3 = 0.0; + + /** + * Is Net Cart + * + * @var bool + */ + private $isNetCart; + + /** + * Order Number + * + * @var string + */ + private $orderNumber; + + /** + * Invoice Number + * + * @var string + */ + private $invoiceNumber; + + /** + * Additional + * + * @var array + */ + private $additional = array(); + + /** + * Order Id + * + * @var int + */ + private $orderId; + + /** + * Coupon + * + * @var \Extcode\Cart\Domain\Model\Cart\Coupon[] + */ + private $coupons = array(); + + /** + * __construct + * + * @param \Extcode\Cart\Domain\Model\Cart\TaxClass[] $taxClasses + * @param bool $isNetCart + * + * @return Cart + */ + public function __construct(array $taxClasses, $isNetCart = false) + { + $this->taxClasses = $taxClasses; + $this->net = 0.0; + $this->gross = 0.0; + $this->count = 0; + $this->products = array(); + + $this->maxServiceAttr1 = 0.0; + $this->maxServiceAttr2 = 0.0; + $this->maxServiceAttr3 = 0.0; + $this->sumServiceAttr1 = 0.0; + $this->sumServiceAttr2 = 0.0; + $this->sumServiceAttr3 = 0.0; + + $this->isNetCart = $isNetCart; + } + + /** + * __sleep + * + * @return array + */ + public function __sleep() + { + return array( + 'taxClasses', + 'net', + 'gross', + 'taxes', + 'count', + 'shipping', + 'payment', + 'specials', + 'service', + 'products', + 'coupons', + 'maxServiceAttr1', + 'maxServiceAttr2', + 'maxServiceAttr3', + 'sumServiceAttr1', + 'sumServiceAttr2', + 'sumServiceAttr3', + 'isNetCart', + 'orderId', + 'orderNumber', + 'invoiceNumber', + 'additional' + ); + } + + /** + * __wakeup + * + * @return void + */ + public function __wakeup() + { + } + + /** + * Gets the Tax Classes Array + * + * @return \Extcode\Cart\Domain\Model\Cart\TaxClass[] + */ + public function getTaxClasses() + { + return $this->taxClasses; + } + + /** + * Gets the Tax Class by Tax Class Id + * + * @param int $taxClassId Tax Class Id + * + * @return \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + public function getTaxClass($taxClassId) + { + return $this->taxClasses[$taxClassId]; + } + + /** + * Sets Is Net Cart + * + * @param bool + * + * @return void + */ + public function setIsNetCart($isNetCart) + { + $this->isNetCart = $isNetCart; + } + + /** + * Gets Is Net Cart + * + * @return bool + */ + public function getIsNetCart() + { + return $this->isNetCart; + } + + /** + * Sets Order Number if no Order Number is given else throws an exception + * + * @param string $orderNumber + * + * @throws \LogicException + * @return void + */ + public function setOrderNumber($orderNumber) + { + if (($this->orderNumber) && ($this->orderNumber != $orderNumber)) { + throw new \LogicException( + 'You can not redeclare the order number of your cart.', + 1413969668 + ); + } + + $this->orderNumber = $orderNumber; + } + + /** + * Gets Order Number + * + * @return string + */ + public function getOrderNumber() + { + return $this->orderNumber; + } + + /** + * Sets Invoice Number if no Invoice Number is given else throws an exception + * + * @param string $invoiceNumber + * + * @throws \LogicException + * @return void + */ + public function setInvoiceNumber($invoiceNumber) + { + if (($this->invoiceNumber) && ($this->invoiceNumber != $invoiceNumber)) { + throw new \LogicException( + 'You can not redeclare the invoice number of your cart.', + 1413969712 + ); + } + + $this->invoiceNumber = $invoiceNumber; + } + + /** + * Gets Invoice Number + * + * @return string + */ + public function getInvoiceNumber() + { + return $this->invoiceNumber; + } + + /** + * @param $net + * + * @return void + */ + public function addNet($net) + { + $this->net += $net; + } + + /** + * @return float + */ + public function getNet() + { + return $this->net; + } + + /** + * @param $net + * + * @return void + */ + public function setNet($net) + { + $this->net = $net; + } + + /** + * @param $net + * + * @return void + */ + public function subNet($net) + { + $this->net -= $net; + } + + /** + * @param $gross + * + * @return void + */ + public function addGross($gross) + { + $this->gross += $gross; + } + + /** + * @return float + */ + public function getGross() + { + return $this->gross; + } + + /** + * @param $gross + * + * @return void + */ + public function setGross($gross) + { + $this->gross = $gross; + } + + /** + * @param $gross + * + * @return void + */ + public function subGross($gross) + { + $this->gross -= $gross; + } + + /** + * @param float $tax + * @param \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass + * + * @return void + */ + public function addTax($tax, $taxClass) + { + $this->taxes[$taxClass->getId()] += $tax; + } + + /** + * @return array + */ + public function getTaxes() + { + return $this->taxes; + } + + /** + * @return array + */ + public function getServiceTaxes() + { + $taxes = array(); + + if ($this->payment) { + $tax = $this->payment->getTax(); + $taxes[$this->payment->getTaxClass()->getId()] += $tax; + } + if ($this->shipping) { + $tax = $this->shipping->getTax(); + $taxes[$this->shipping->getTaxClass()->getId()] += $tax; + } + if ($this->specials) { + foreach ($this->specials as $special) { + $tax = $special->getTax(); + $taxes[$special->getTaxClass()->getId()] += $tax; + } + } + + return $taxes; + } + + /** + * @return array + */ + public function getSubtotalTaxes() + { + $taxes = $this->taxes; + + if ($this->coupons) { + foreach ($this->coupons as $coupon) { + if ($this->getGross() >= $coupon->getCartMinPrice()) { + $tax = $coupon->getTax(); + $taxes[$coupon->getTaxClass()->getId()] -= $tax; + } + } + } + + return $taxes; + } + + /** + * @return array + */ + public function getTotalTaxes() + { + $taxes = $this->getSubtotalTaxes(); + + if ($this->payment) { + $tax = $this->payment->getTax(); + $taxes[$this->payment->getTaxClass()->getId()] += $tax; + } + if ($this->shipping) { + $tax = $this->shipping->getTax(); + $taxes[$this->shipping->getTaxClass()->getId()] += $tax; + } + + if ($this->specials) { + foreach ($this->specials as $special) { + $tax = $special->getTax(); + $taxes[$special->getTaxClass()->getId()] += $tax; + } + } + + return $taxes; + } + + /** + * @param int $taxClassId + * @param float $tax + * + * @return void + */ + public function setTax($taxClassId, $tax) + { + $this->taxes[$taxClassId] = $tax; + } + + /** + * @param float $tax + * @param \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass + * + * @return void + */ + public function subTax($tax, $taxClass) + { + $this->taxes[$taxClass->getId()] -= $tax; + } + + /** + * @param $count + * + * @return void + */ + public function addCount($count) + { + $this->count += $count; + } + + /** + * @return int + */ + public function getCount() + { + return $this->count; + } + + /** + * @param $count + * + * @return void + */ + public function setCount($count) + { + $this->count = $count; + } + + /** + * @param $count + * + * @return void + */ + public function subCount($count) + { + $this->count -= $count; + } + + /** + * @return Shipping + */ + public function getShipping() + { + return $this->shipping; + } + + /** + * @param Shipping $shipping + * + * @return void + */ + public function setShipping($shipping) + { + $this->shipping = $shipping; + } + + /** + * @return Payment + */ + public function getPayment() + { + return $this->payment; + } + + /** + * @param Payment $payment + * + * @return void + */ + public function setPayment($payment) + { + $this->payment = $payment; + } + + /** + * @return Special[] + */ + public function getSpecials() + { + return $this->specials; + } + + /** + * @param Special $newSpecial + * + * @return void + */ + public function addSpecial($newSpecial) + { + $this->specials[$newSpecial->getId()] = $newSpecial; + } + + /** + * @param Special $special + * @return void + */ + public function removeSpecial($special) + { + unset($this->specials[$special->getId()]); + } + + /** + * @return float + */ + public function getServiceNet() + { + $net = 0.0; + + if ($this->payment) { + $net += $this->payment->getNet(); + } + if ($this->shipping) { + $net += $this->shipping->getNet(); + } + if ($this->specials) { + foreach ($this->specials as $special) { + $net += $special->getNet(); + } + } + + return $net; + } + + /** + * @return float + */ + public function getServiceGross() + { + $gross = 0.0; + + if ($this->payment) { + $gross += $this->payment->getGross(); + } + if ($this->shipping) { + $gross += $this->shipping->getGross(); + } + if ($this->specials) { + foreach ($this->specials as $special) { + $gross += $special->getGross(); + } + }; + + return $gross; + } + + /** + * @return \Extcode\Cart\Domain\Model\Cart\Product[] + */ + public function getProducts() + { + return $this->products; + } + + /** + * @param $id + * + * @return \Extcode\Cart\Domain\Model\Cart\Product + */ + public function getProductById($id) + { + return $this->products[$id]; + } + + /** + * @param $id + * + * @return \Extcode\Cart\Domain\Model\Cart\Product + * + * @see getProductById + */ + public function getProduct($id) + { + return $this->getProductById($id); + } + + /** + * @return array + */ + public function toArray() + { + $cartArray = array( + 'net' => $this->net, + 'gross' => $this->gross, + 'count' => $this->count, + 'taxes' => $this->taxes, + 'maxServiceAttribute1' => $this->maxServiceAttr1, + 'maxServiceAttribute2' => $this->maxServiceAttr2, + 'maxServiceAttribute3' => $this->maxServiceAttr3, + 'sumServiceAttribute1' => $this->sumServiceAttr1, + 'sumServiceAttribute2' => $this->sumServiceAttr2, + 'sumServiceAttribute3' => $this->sumServiceAttr3, + 'additional' => $this->additional + ); + + if ($this->payment) { + $cartArray['payment'] = $this->payment->getName(); + } + + if ($this->shipping) { + $cartArray['payment'] = $this->shipping->getName(); + } + + if ($this->specials) { + $specials = array(); + foreach ($this->specials as $special) { + $specials[] = $special->getName(); + } + $cartArray['specials'] = $specials; + } + + return $cartArray; + } + + /** + * @return string + */ + public function toJson() + { + json_encode($this->toArray()); + } + + /** + * Return Coupons + * + * @return \Extcode\Cart\Domain\Model\Cart\Coupon[] + */ + public function getCoupons() + { + return $this->coupons; + } + + /** + * @return bool + */ + protected function areCouponsCombinable() + { + $areCombinable = true; + + if ($this->coupons) { + foreach ($this->coupons as $coupon) { + if (!$coupon->getIsCombinable()) { + $areCombinable = false; + break; + } + } + } + + return $areCombinable; + } + + /** + * Adds a Coupon to Cart + * + * @param \Extcode\Cart\Domain\Model\Product\Coupon $coupon + * + * @return int + */ + public function addCoupon($coupon) + { + if ($this->coupons[$coupon->getCode()]) { + $returnCode = -1; + } else { + if ((!empty($this->coupons)) && ( !$this->areCouponsCombinable() || !$coupon->getIsCombinable())) { + $returnCode = -2; + } else { + $newCoupon = new \Extcode\Cart\Domain\Model\Cart\Coupon( + $coupon->getTitle(), + $coupon->getCode(), + $coupon->getDiscount(), + $this->taxClasses[$coupon->getTaxClassId()], + $coupon->getCartMinPrice(), + $coupon->getIsCombinable() + ); + $newCoupon->setCart($this); + $this->coupons[$coupon->getCode()] = $newCoupon; + + $returnCode = 1; + } + } + + return $returnCode; + } + + /** + * Returns Coupon Gross + * + * @return float + */ + public function getCouponGross() + { + $gross = 0.0; + + if ($this->coupons) { + foreach ($this->coupons as $coupon) { + if (!$coupon->getIsRelativeDiscount()) { + if ($this->getGross() >= $coupon->getCartMinPrice()) { + $gross += $coupon->getGross(); + } + } + } + } + + return $gross; + } + + /** + * Returns Coupon Net + * + * @return float + */ + public function getCouponNet() + { + $net = 0.0; + + if ($this->coupons) { + foreach ($this->coupons as $coupon) { + if (!$coupon->getIsRelativeDiscount()) { + if ($this->getGross() >= $coupon->getCartMinPrice()) { + $net += $coupon->getNet(); + } + } + } + } + + return $net; + } + + /** + * Returns Coupon Taxes + * + * @return array + */ + public function getCouponTaxes() + { + $taxes = array(); + + if ($this->coupons) { + foreach ($this->coupons as $coupon) { + if (!$coupon->getIsRelativeDiscount()) { + if ($this->getGross() >= $coupon->getCartMinPrice()) { + $tax = $coupon->getTax(); + $taxes[$coupon->getTaxClass()->getId()] += $tax; + } + } + } + } + + return $taxes; + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\Product $newProduct + * + * @return void + */ + public function addProduct($newProduct) + { + $id = $newProduct->getId(); + $product = $this->products[$id]; + + if ($product) { + // change $newproduct in cart + $this->changeProduct($product, $newProduct); + $this->calcAll(); + } else { + // $newproduct is not in cart + $newProduct->setCart($this); + $this->products[$id] = $newProduct; + $this->calcAll(); + $this->addServiceAttributes($newProduct); + } + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\Product $product + * @param \Extcode\Cart\Domain\Model\Cart\Product $newProduct + * + * @internal param $id + * @internal param $newQuantity + * + * @return void + */ + public function changeProduct($product, $newProduct) + { + $newQuantity = $product->getQuantity() + $newProduct->getQuantity(); + + $this->subCount($product->getQuantity()); + $this->subGross($product->getGross()); + $this->subNet($product->getNet()); + $this->subTax($product->getTax(), $product->getTaxClass()); + + // if the new product has a variant then change it in product + if ($newProduct->getBeVariants()) { + $product->addBeVariants($newProduct->getBeVariants()); + } + + $product->changeQuantity($newQuantity); + + $this->addCount($product->getQuantity()); + $this->addGross($product->getGross()); + $this->addNet($product->getNet()); + $this->addTax($product->getTax(), $product->getTaxClass()); + + //update all service attributes + $this->updateServiceAttributes(); + } + + /** + * @param $productQuantityArray + * @internal param $id + * @internal param $newQuantity + * @return void + */ + public function changeProductsQuantity($productQuantityArray) + { + foreach ($productQuantityArray as $productPuid => $quantity) { + $product = $this->products[$productPuid]; + + if ($product) { + if (is_array($quantity)) { + $this->subCount($product->getQuantity()); + $this->subGross($product->getGross()); + $this->subNet($product->getNet()); + $this->subTax($product->getTax(), $product->getTaxClass()); + + $product->changeVariantsQuantity($quantity); + + $this->addCount($product->getQuantity()); + $this->addGross($product->getGross()); + $this->addNet($product->getNet()); + $this->addTax($product->getTax(), $product->getTaxClass()); + } else { + // only run, if quantity was realy changed + if ($product->getQuantity() != $quantity) { + $this->subCount($product->getQuantity()); + $this->subGross($product->getGross()); + $this->subNet($product->getNet()); + $this->subTax($product->getTax(), $product->getTaxClass()); + + $product->changeQuantity($quantity); + + $this->addCount($product->getQuantity()); + $this->addGross($product->getGross()); + $this->addNet($product->getNet()); + $this->addTax($product->getTax(), $product->getTaxClass()); + } + } + } + + //update all service attributes + $this->updateServiceAttributes(); + } + } + + /** + * @param array|string $productParams + * + * @return bool + */ + public function removeProductById($productParams) + { + if (is_array($productParams)) { + $productId = key($productParams); + $product = $this->products[$productId]; + if ($product) { + $this->removeproduct($product, $productParams[$productId]); + } else { + return -1; + } + } elseif (is_string($productParams)) { + $product = $this->products[$productParams]; + if ($product) { + $this->removeproduct($product); + } else { + return -1; + } + } + + $this->updateServiceAttributes(); + + return true; + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\Product $product + * + * @param array $productVariantIds + * + * @return bool + */ + public function removeproduct($product, $productVariantIds = null) + { + if (is_array($productVariantIds)) { + $product->removeBeVariants($productVariantIds); + + if (!$product->getBeVariants()) { + unset($this->products[$product->getId()]); + } + + $this->calcAll(); + } else { + $this->subCount($product->getQuantity()); + $this->subGross($product->getGross()); + $this->subNet($product->getNet()); + $this->subTax($product->getTax(), $product->getTaxClass()); + + unset($this->products[$product->getId()]); + } + + return true; + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\Product $newproduct + * + * @return void + */ + private function addServiceAttributes($newproduct) + { + if ($this->maxServiceAttr1 > $newproduct->getServiceAttribute1()) { + $this->maxServiceAttr1 = $newproduct->getServiceAttribute1(); + } + if ($this->maxServiceAttr2 > $newproduct->getServiceAttribute2()) { + $this->maxServiceAttr2 = $newproduct->getServiceAttribute2(); + } + if ($this->maxServiceAttr3 > $newproduct->getServiceAttribute3()) { + $this->maxServiceAttr3 = $newproduct->getServiceAttribute3(); + } + + $this->sumServiceAttr1 += $newproduct->getServiceAttribute1() * $newproduct->getQuantity(); + $this->sumServiceAttr2 += $newproduct->getServiceAttribute2() * $newproduct->getQuantity(); + $this->sumServiceAttr3 += $newproduct->getServiceAttribute3() * $newproduct->getQuantity(); + } + + /** + * @return void + */ + private function updateServiceAttributes() + { + $this->maxServiceAttr1 = 0.0; + $this->maxServiceAttr2 = 0.0; + $this->maxServiceAttr3 = 0.0; + $this->sumServiceAttr1 = 0.0; + $this->sumServiceAttr2 = 0.0; + $this->sumServiceAttr3 = 0.0; + + foreach ($this->products as $key => $product) { + if ($this->maxServiceAttr1 > $product->getServiceAttribute1()) { + $this->maxServiceAttr1 = $product->getServiceAttribute1(); + } + if ($this->maxServiceAttr2 > $product->getServiceAttribute2()) { + $this->maxServiceAttr2 = $product->getServiceAttribute2(); + } + if ($this->maxServiceAttr3 > $product->getServiceAttribute3()) { + $this->maxServiceAttr3 = $product->getServiceAttribute3(); + } + + $this->sumServiceAttr1 = $product->getServiceAttribute1() * $product->getQuantity(); + $this->sumServiceAttr2 = $product->getServiceAttribute2() * $product->getQuantity(); + $this->sumServiceAttr3 = $product->getServiceAttribute3() * $product->getQuantity(); + } + } + + /** + * @return float + */ + public function getMaxServiceAttribute1() + { + return $this->maxServiceAttr1; + } + + /** + * @return float + */ + public function getMaxServiceAttribute2() + { + return $this->maxServiceAttr2; + } + + /** + * @return float + */ + public function getMaxServiceAttribute3() + { + return $this->maxServiceAttr3; + } + + /** + * @return float + */ + public function getSumServiceAttribute1() + { + return $this->sumServiceAttr1; + } + + /** + * @return float + */ + public function getSumServiceAttribute2() + { + return $this->sumServiceAttr2; + } + + /** + * @return float + */ + public function getSumServiceAttribute3() + { + return $this->sumServiceAttr3; + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\Shipping $shipping + * + * @return void + */ + public function changeShipping(\Extcode\Cart\Domain\Model\Cart\Shipping $shipping) + { + $this->shipping = $shipping; + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\Payment $payment + * + * @return void + */ + public function changePayment(\Extcode\Cart\Domain\Model\Cart\Payment $payment) + { + $this->payment = $payment; + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\Special[] $specials + * + * @return void + */ + public function changeSpecials($specials) + { + $this->specials = $specials; + } + + /** + * @return void + */ + private function calcAll() + { + $this->calcCount(); + $this->calcGross(); + $this->calcTax(); + $this->calcNet(); + } + + /** + * @return void + */ + private function calcCount() + { + $this->count = 0; + if ($this->products) { + foreach ($this->products as $product) { + $this->addCount($product->getQuantity()); + } + } + } + + /** + * @return void + */ + private function calcGross() + { + $this->gross = 0.0; + if ($this->products) { + foreach ($this->products as $product) { + $this->addGross($product->getGross()); + } + } + } + + /** + * @return void + */ + private function calcNet() + { + $this->net = 0.0; + if ($this->products) { + foreach ($this->products as $product) { + $this->addNet($product->getNet()); + } + } + } + + /** + * @return void + */ + private function calcTax() + { + $this->taxes = array(); + if ($this->products) { + foreach ($this->products as $product) { + $this->addTax($product->getTax(), $product->getTaxClass()); + } + } + } + + /** + * @return void + */ + public function reCalc() + { + $this->calcGross(); + $this->calcNet(); + $this->calcTax(); + } + + /** + * @return array + */ + public function getAdditionalArray() + { + return $this->additional; + } + + /** + * @param array $additional + * @return void + */ + public function setAdditionalArray($additional) + { + $this->additional = $additional; + } + + /** + * @return void + */ + public function unsetAdditionalArray() + { + $this->additional = array(); + } + + /** + * @param $key + * @return mixed + */ + public function getAdditional($key) + { + return $this->additional[$key]; + } + + /** + * @param string $key + * @param mixed $value + * + * @return void + */ + public function setAdditional($key, $value) + { + $this->additional[$key] = $value; + } + + /** + * @param string $key + * + * @return void + */ + public function unsetAdditional($key) + { + if ($this->additional[$key]) { + unset($this->additional[$key]); + } + } + + /** + * @param int $orderId + */ + public function setOrderId($orderId) + { + $this->orderId = $orderId; + } + + /** + * @return int + */ + public function getOrderId() + { + return $this->orderId; + } + + /** + * @return float + */ + public function getSubtotalGross() + { + return $this->gross - $this->getCouponGross(); + } + + /** + * @return float + */ + public function getTotalGross() + { + return $this->gross - $this->getCouponGross() + $this->getServiceGross(); + } + + /** + * @return float + */ + public function getSubtotalNet() + { + return $this->net - $this->getCouponNet(); + } + + /** + * @return float + */ + public function getTotalNet() + { + return $this->net - $this->getCouponNet() + $this->getServiceNet(); + } + + /** + * @return bool + */ + protected function isOrderable() + { + $isOrderable = true; + + if ($this->products) { + foreach ($this->products as $product) { + if (! $product->getQuantityIsInRange()) { + $isOrderable = false; + break; + } + } + } else { + $isOrderable = false; + } + + return $isOrderable; + } + + /** + * @return bool + */ + public function getIsOrderable() + { + return $this->isOrderable(); + } +} diff --git a/Classes/Domain/Model/Cart/Coupon.php b/Classes/Domain/Model/Cart/Coupon.php new file mode 100644 index 00000000..4ccc2794 --- /dev/null +++ b/Classes/Domain/Model/Cart/Coupon.php @@ -0,0 +1,253 @@ + + */ +class Coupon +{ + + /** + * Cart + * + * @var \Extcode\Cart\Domain\Model\Cart\Cart + */ + protected $cart = null; + + /** + * Title + * + * @var string + */ + protected $title = ''; + + /** + * Code + * + * @var string + */ + protected $code = ''; + + /** + * Is Combinable + * + * @var bool + */ + protected $isCombinable = false; + + /** + * Is Relative Discount + * + * @var bool + */ + protected $isRelativeDiscount = false; + + /** + * Discount + * + * @var float + */ + protected $discount; + + /** + * Tax Class + * + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + protected $taxClass; + + /** + * Cart Min Price + * + * @var float + */ + protected $cartMinPrice = 0.0; + + /** + * __construct + * + * @param string $title + * @param string $code + * @param float $discount + * @param \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass + * @param float $cartMinPrice + * @param bool $isCombinable + * + * @throws \InvalidArgumentException + */ + public function __construct( + $title, + $code, + $discount, + $taxClass, + $cartMinPrice, + $isCombinable = false + ) { + if (!$title) { + throw new \InvalidArgumentException( + 'You have to specify a valid $title for constructor.', + 1448230010 + ); + } + if (!$code) { + throw new \InvalidArgumentException( + 'You have to specify a valid $code for constructor.', + 1448230020 + ); + } + if (!$discount) { + throw new \InvalidArgumentException( + 'You have to specify a valid $discount for constructor.', + 1448230030 + ); + } + if (!$taxClass) { + throw new \InvalidArgumentException( + 'You have to specify a valid $taxClass for constructor.', + 1448230040 + ); + } + + $this->title = $title; + $this->code = $code; + $this->discount = $discount; + $this->cartMinPrice = $cartMinPrice; + $this->taxClass = $taxClass; + $this->isCombinable = $isCombinable; + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\Cart $cart + * @return void + */ + public function setCart($cart) + { + $this->cart = $cart; + } + + /** + * Gets Title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Gets Code + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Returns is Combinable + * @return bool + */ + public function getIsCombinable() + { + return $this->isCombinable; + } + + /** + * Returns is Relative Discount + * @return bool + */ + public function getIsRelativeDiscount() + { + return $this->isRelativeDiscount; + } + + /** + * @return float + */ + public function getDiscount() + { + return $this->discount; + } + + /** + * Returns Gross of Discount + * + * @return float + */ + public function getGross() + { + return $this->discount; + } + + /** + * Returns Net of Discount + * + * @return float + */ + public function getNet() + { + $net = $this->discount / ($this->taxClass->getCalc() + 1); + return $net; + } + + /** + * Returns Tax Class + * + * @return \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + public function getTaxClass() + { + return $this->taxClass; + } + + /** + * Returns Tax of Discount + * + * @return float + */ + public function getTax() + { + $tax = $this->discount - ($this->discount / ($this->taxClass->getCalc() + 1)); + return $tax; + } + + /** + * Returns Cart Min Price + * + * @return float + */ + public function getCartMinPrice() + { + return $this->cartMinPrice; + } + + /** + * Return Is Useable For A Given Price + * + * @return bool + */ + public function getIsUseable() + { + $isUseable = $this->cartMinPrice <= $this->cart->getGross(); + return $isUseable; + } +} diff --git a/Classes/Domain/Model/Cart/Extra.php b/Classes/Domain/Model/Cart/Extra.php new file mode 100644 index 00000000..de7fac91 --- /dev/null +++ b/Classes/Domain/Model/Cart/Extra.php @@ -0,0 +1,276 @@ + + */ +class Extra +{ + /** + * Id + * + * @var int + */ + private $id; + + /** + * Condition + * + * @var float + */ + private $condition; + + /** + * Price + * + * @var float + */ + private $price; + + /** + * Gross + * + * @var float + */ + private $gross; + + /** + * Net + * + * @var float + */ + private $net; + + /** + * TaxClass + * + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + private $taxClass; + + /** + * Tax + * + * @var float + */ + private $tax; + + /** + * Is Net Price + * + * @var bool + */ + private $isNetPrice; + + /** + * __construct + * + * @param int $id + * @param float $condition + * @param float $price + * @param \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass + * @param bool $isNetPrice + * + * @internal param $gross + * + * @return Extra + */ + public function __construct( + $id, + $condition, + $price, + \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass, + $isNetPrice = false + ) { + $this->id = $id; + $this->condition = $condition; + $this->taxClass = $taxClass; + $this->price = $price; + + $this->isNetPrice = $isNetPrice; + + $this->reCalc(); + } + + /** + * Sets Is Net Price + * + * @param bool + * + * @return void + */ + public function setIsNetPrice($isNetPrice) + { + $this->isNetPrice = $isNetPrice; + } + + /** + * Gets Is Net Price + * + * @return bool + */ + public function getIsNetPrice() + { + return $this->isNetPrice; + } + + /** + * Gets Id + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Gets Condition + * + * @return float + */ + public function getCondition() + { + return $this->condition; + } + + /** + * Less Or Equal + * + * @param $condition + * + * @return bool + */ + public function leq($condition) + { + if ($condition < $this->condition) { + return false; + } + + return true; + } + + /** + * @return float + */ + public function getPrice() + { + return $this->price; + } + + /** + * @param $price + */ + public function setPrice($price) + { + $this->price = $price; + + $this->reCalc(); + } + + /** + * @return float + */ + public function getGross() + { + $this->calcGross(); + return $this->gross; + } + + /** + * @return float + */ + public function getNet() + { + $this->calcNet(); + return $this->net; + } + + /** + * @return array + */ + public function getTax() + { + $this->calcTax(); + return array('taxclassid' => $this->taxClass->getId(), 'tax' => $this->tax); + } + + /** + * @return \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + public function getTaxClass() + { + return $this->taxClass; + } + + /** + * + */ + private function calcGross() + { + if ($this->isNetPrice == false) { + $this->gross = $this->price; + } else { + $this->calcNet(); + $this->gross = $this->net + $this->tax; + } + } + + /** + * + */ + private function calcTax() + { + if ($this->isNetPrice == false) { + $this->tax = ($this->gross / (1 + $this->taxClass->getCalc())) * ($this->taxClass->getCalc()); + } else { + $this->tax = ($this->net * $this->taxClass->getCalc()); + } + } + + /** + * + */ + private function calcNet() + { + if ($this->isNetPrice == true) { + $this->net = $this->price; + } else { + $this->calcGross(); + $this->net = $this->gross - $this->tax; + } + } + + /** + * + */ + private function reCalc() + { + if ($this->isNetPrice == false) { + $this->calcGross(); + $this->calcTax(); + $this->calcNet(); + } else { + $this->calcNet(); + $this->calcTax(); + $this->calcGross(); + } + } +} diff --git a/Classes/Domain/Model/Cart/FeVariant.php b/Classes/Domain/Model/Cart/FeVariant.php new file mode 100644 index 00000000..c220a1a9 --- /dev/null +++ b/Classes/Domain/Model/Cart/FeVariant.php @@ -0,0 +1,143 @@ + + */ +class FeVariant +{ + /** + * Product + * + * @var \Extcode\Cart\Domain\Model\Cart\Product + */ + private $product = null; + + /** + * BeVariant + * + * @var \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + private $beVariant = null; + + /** + * Variant Data + * + * @var array + */ + private $variantData = array(); + + /** + * Title Glue + */ + protected $titleGlue = ' '; + + /** + * SKU Glue + */ + protected $skuGlue = '-'; + + /** + * Value Glue + */ + protected $valueGlue = ' '; + + /** + * __construct + * + * @param array $variantData + * + * @return \Extcode\Cart\Domain\Model\Cart\FeVariant + */ + public function __construct( + $variantData = array() + ) { + $this->variantData = $variantData; + } + + /** + * @return string + */ + public function getId() + { + return sha1(json_encode($this->variantData)); + } + + /** + * @return \Extcode\Cart\Domain\Model\Cart\Product + */ + public function getProduct() + { + return $this->product; + } + + /** + * @return \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + public function getVariant() + { + return $this->variant; + } + + /** + * @return array + */ + public function getVariantData() { + return $this->variantData; + } + + /** + * @return string + */ + public function getTitle() + { + $titleArr = array(); + foreach ($this->variantData as $variant) { + $titleArr[] = $variant['title']; + } + return join($this->titleGlue, $titleArr); + } + + /** + * @return string + */ + public function getSku() + { + $skuArr = array(); + foreach ($this->variantData as $variant) { + $skuArr[] = $variant['sku']; + } + return join($this->skuGlue, $skuArr); + } + + /** + * @return string + */ + public function getValue() + { + $valueArr = array(); + foreach ($this->variantData as $variant) { + $valueArr[] = $variant['value']; + } + return join($this->valueGlue, $valueArr); + } +} diff --git a/Classes/Domain/Model/Cart/Payment.php b/Classes/Domain/Model/Cart/Payment.php new file mode 100644 index 00000000..b9b5e1cb --- /dev/null +++ b/Classes/Domain/Model/Cart/Payment.php @@ -0,0 +1,27 @@ + + */ +class Payment extends \Extcode\Cart\Domain\Model\Cart\AbstractService +{ + +} diff --git a/Classes/Domain/Model/Cart/Product.php b/Classes/Domain/Model/Cart/Product.php new file mode 100644 index 00000000..b8c884d6 --- /dev/null +++ b/Classes/Domain/Model/Cart/Product.php @@ -0,0 +1,1016 @@ + + */ +class Product +{ + + /** + * Product Id + * + * @var int + */ + private $productId; + + /** + * Table Id + * + * @var int + */ + private $tableId; + + /** + * Content Id + * + * @var int + */ + private $contentId; + + /** + * Cart + * + * @var Cart + */ + private $cart = null; + + /** + * Title + * + * @var string + */ + private $title; + + /** + * SKU + * + * @var string + */ + private $sku; + + /** + * Price + * + * @var float + */ + private $price; + + /** + * Special Price + * + * @var float + */ + private $specialPrice = null; + + /** + * Quantity + * + * @var int + */ + private $quantity; + + /** + * Gross + * + * @var float + */ + private $gross; + + /** + * Net + * + * @var float + */ + private $net; + + /** + * Tax Class + * + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + private $taxClass; + + /** + * Tax + * + * @var float + */ + private $tax; + + /** + * Error + * + * @var string + */ + private $error; + + /** + * Service Attribute 1 + * + * @var float + */ + private $serviceAttribute1; + + /** + * Service Attribute 2 + * + * @var float + */ + private $serviceAttribute2; + + /** + * Service Attribute 3 + * + * @var float + */ + private $serviceAttribute3; + + /** + * Is Net Price + * + * @var bool + */ + private $isNetPrice; + + /** + * Variants + * + * @var array BeVariant + */ + private $beVariants; + + /** + * Frontend Variant + * + * @var \Extcode\Cart\Domain\Model\Cart\FeVariant + */ + private $feVariant; + + /** + * Additional + * + * @var array Additional + */ + private $additional = array(); + + /** + * Min Number In Cart + * + * @var int + */ + private $minNumberInCart = 0; + + /** + * Max Number in Cart + * + * @var int + */ + private $maxNumberInCart = 0; + + /** + * __construct + * + * @param int $productId + * @param int $tableId + * @param int $contentId + * @param string $sku + * @param string $title + * @param float $price + * @param \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass + * @param int $quantity + * @param bool $isNetPrice + * @param \Extcode\Cart\Domain\Model\Cart\FeVariant $feVariant + * + * @throws \InvalidArgumentException + */ + public function __construct( + $productId, + $tableId, + $contentId, + $sku, + $title, + $price, + $taxClass, + $quantity, + $isNetPrice = false, + $feVariant = null + ) { + if (!$productId) { + throw new \InvalidArgumentException( + 'You have to specify a valid $productId for constructor.', + 1413999100 + ); + } + if (!$sku) { + throw new \InvalidArgumentException( + 'You have to specify a valid $sku for constructor.', + 1413999110 + ); + } + if (!$title) { + throw new \InvalidArgumentException( + 'You have to specify a valid $title for constructor.', + 1413999120 + ); + } + if ($price === null) { + throw new \InvalidArgumentException( + 'You have to specify a valid $price for constructor.', + 1413999130 + ); + } + if (!$taxClass) { + throw new \InvalidArgumentException( + 'You have to specify a valid $taxClass for constructor.', + 1413999140 + ); + } + if (!$quantity) { + throw new \InvalidArgumentException( + 'You have to specify a valid $quantity for constructor.', + 1413999150 + ); + } + + $this->productId = $productId; + $this->tableId = $tableId != null ? $tableId : 0; + $this->contentId = $contentId; + $this->sku = $sku; + $this->title = $title; + $this->price = $price; + $this->taxClass = $taxClass; + $this->quantity = $quantity; + $this->isNetPrice = $isNetPrice; + + if ($feVariant) { + $this->feVariant = $feVariant; + } + + $this->calcGross(); + $this->calcTax(); + $this->calcNet(); + } + + /** + * @param $cart + * @return void + */ + public function setCart($cart) + { + $this->cart = $cart; + } + + /** + * @param string $sku + */ + public function setSku($sku) + { + $this->sku = $sku; + } + + /** + * @return string + */ + public function getSku() + { + return $this->sku; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @param string $title + * @return void + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * @return bool + */ + public function getIsNetPrice() + { + return $this->isNetPrice; + } + + /** + * @param array $newVariants + * @return mixed + */ + public function addBeVariants($newVariants) + { + foreach ($newVariants as $newVariant) { + $this->addBeVariant($newVariant); + } + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\BeVariant $newVariant + * @return mixed + */ + public function addBeVariant(\Extcode\Cart\Domain\Model\Cart\BeVariant $newVariant) + { + $newVariantsId = $newVariant->getId(); + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $variant */ + $variant = $this->beVariants[$newVariantsId]; + + if ($variant) { + if ($variant->getBeVariants()) { + $variant->addBeVariants($newVariant->getBeVariants()); + } else { + $newQuantity = $variant->getQuantity() + $newVariant->getQuantity(); + $variant->setQuantity($newQuantity); + } + } else { + $this->beVariants[$newVariantsId] = $newVariant; + } + + $this->reCalc(); + } + + /** + * @param array $variantQuantity + */ + public function changeVariantsQuantity($variantQuantity) + { + foreach ($variantQuantity as $variantId => $quantity) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $variant */ + $variant = $this->beVariants[$variantId]; + + if (ctype_digit($quantity)) { + $quantity = intval($quantity); + $variant->changeQuantity($quantity); + } elseif (is_array($quantity)) { + $variant->changeVariantsQuantity($quantity); + } + + $this->reCalc(); + } + } + + /** + * @return \Extcode\Cart\Domain\Model\Cart\FeVariant + */ + public function getFeVariant() + { + return $this->feVariant; + } + + /** + * @return array + */ + public function getBeVariants() + { + return $this->beVariants; + } + + /** + * @param $variantId + * @return \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + public function getBeVariantById($variantId) + { + return $this->beVariants[$variantId]; + } + + /** + * @param $variantId + * @return \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + public function getBeVariant($variantId) + { + return $this->getBeVariantById($variantId); + } + + /** + * @param $variantsArray + * @return bool|int + */ + public function removeBeVariants($variantsArray) + { + foreach ($variantsArray as $variantId => $value) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $variant */ + $variant = $this->beVariants[$variantId]; + if ($variant) { + if (is_array($value)) { + $variant->removeBeVariants($value); + + if (!$variant->getBeVariants()) { + unset($this->beVariants[$variantId]); + } + + $this->reCalc(); + } else { + unset($this->beVariants[$variantId]); + + $this->reCalc(); + } + } else { + return -1; + } + } + + return true; + } + + /** + * @param $variantId + * @return array + */ + public function removeVariantById($variantId) + { + unset($this->beVariants[$variantId]); + + $this->reCalc(); + } + + /** + * @param $variantId + * @return array + */ + public function removeVariant($variantId) + { + $this->removeVariantById($variantId); + } + + /** + * @param $variantId + * @param $newQuantity + * @internal param $id + */ + public function changeVariantById($variantId, $newQuantity) + { + $this->beVariants[$variantId]->changeQuantity($newQuantity); + + $this->reCalc(); + } + + /** + * @return int + */ + public function getProductId() + { + return $this->productId; + } + + /** + * @return int + */ + public function getTableId() + { + return $this->tableId; + } + + /** + * @return int + */ + public function getContentId() + { + return $this->contentId; + } + + /** + * @return string + */ + public function getId() + { + if (!$this->contentId) { + $id = $this->getTableProductId(); + } else { + $id = $this->getContentProductId(); + } + return $id; + } + + /** + * @return string + */ + protected function getTableProductId() + { + $tableProductId = $this->getTableId() . '_' . $this->getProductId(); + if ($this->getFeVariant()) { + $tableProductId .= '_' . $this->getFeVariant()->getId(); + } + return 't_' . $tableProductId; + } + + /** + * @return string + */ + protected function getContentProductId() + { + return 'c_' . $this->getContentId() . '_' . $this->getProductId(); + } + + /** + * @return float + */ + public function getPrice() + { + return $this->price; + } + + /** + * Returns Special Price + * + * @return float + */ + public function getSpecialPrice() + { + return $this->specialPrice; + } + + /** + * Sets Special Price + * + * @param float $specialPrice + */ + public function setSpecialPrice($specialPrice) + { + $this->specialPrice = $specialPrice; + } + + /** + * Returns Best Price (min of Price and Special Price) + * + * @return float + */ + public function getBestPrice() + { + $bestPrice = $this->price; + + if ($this->specialPrice && ($this->specialPrice < $bestPrice)) { + $bestPrice = $this->specialPrice; + } + + return $bestPrice; + } + + /** + * Returns Special Price + * + * @return float + */ + public function getSpecialPriceDiscount() + { + $discount = 0.0; + if (($this->price != 0.0) && ($this->specialPrice)) { + $discount = (($this->price - $this->specialPrice) / $this->price) * 100; + } + return $discount; + } + + /** + * @return float + */ + public function getPriceTax() + { + return ($this->getBestPrice() / (1 + $this->taxClass->getCalc())) * ($this->taxClass->getCalc()); + } + + /** + * @return \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + public function getTaxClass() + { + return $this->taxClass; + } + + /** + * @param int $newQuantity + * @return void + */ + public function changeQuantity($newQuantity) + { + if ($this->quantity != $newQuantity) { + if ($newQuantity === 0) { + $this->cart->removeproduct($this); + } else { + $this->quantity = $newQuantity; + $this->reCalc(); + } + } + } + + /** + * @return int + */ + public function getQuantity() + { + return $this->quantity; + } + + /** + * Quantity Leaving Range + * + * returns 0 if quantity is in rage + * returns -1 if minimum was not reached + * returns 1 if maximum was exceeded + * + * @return int + */ + protected function isQuantityLeavingRange() + { + $outOfRange = 0; + + if ($this->getQuantityBelowRange()) { + $outOfRange = -1; + } + if ($this->getQuantityAboveRange()) { + $outOfRange = 1; + } + + return $outOfRange; + } + + /** + * Quantity In Range + * + * @return bool + */ + protected function isQuantityInRange() + { + $inRange = true; + if ($this->isQuantityLeavingRange() != 0) { + $inRange = false; + } + return $inRange; + } + + /** + * @return bool + */ + public function getQuantityIsInRange() + { + return $this->isQuantityInRange(); + } + + /** + * @return int + */ + public function getQuantityIsLeavingRange() + { + return $this->isQuantityLeavingRange(); + } + + /** + * Returns true if Quantity in cart is below Min Number In Cart + * @return bool + */ + public function getQuantityBelowRange() + { + $belowRange = false; + + if ($this->quantity < $this->minNumberInCart) { + $belowRange = true; + } + + return $belowRange; + } + + /** + * Returns true if Quantity in cart is above Max Number In Cart + * + * @return bool + */ + public function getQuantityAboveRange() + { + $aboveRange = false; + + if (($this->maxNumberInCart > 0) && ($this->quantity > $this->maxNumberInCart)) { + $aboveRange = true; + } + + return $aboveRange; + + } + + /** + * @return float + */ + public function getGross() + { + $gross = 0.0; + if ($this->isQuantityInRange()) { + $this->calcGross(); + $gross = $this->gross; + } + return $gross; + } + + /** + * @return float + */ + public function getNet() + { + $net = 0.0; + if ($this->isQuantityInRange()) { + $this->calcNet(); + $net = $this->net; + } + return $net; + } + + /** + * @return float + */ + public function getTax() + { + $tax = 0.0; + if ($this->isQuantityInRange()) { + $this->calcTax(); + $tax = $this->tax; + } + return $tax; + } + + /** + * @return mixed + */ + public function getError() + { + return $this->error; + } + + /** + * @return float + */ + public function getServiceAttribute1() + { + return $this->serviceAttribute1; + } + + /** + * @param float $serviceAttribute1 + */ + public function setServiceAttribute1($serviceAttribute1) + { + $this->serviceAttribute1 = floatval($serviceAttribute1); + } + + /** + * @return float + */ + public function getServiceAttribute2() + { + return $this->serviceAttribute2; + } + + /** + * @param float $serviceAttribute2 + */ + public function setServiceAttribute2($serviceAttribute2) + { + $this->serviceAttribute2 = floatval($serviceAttribute2); + } + + /** + * @return float + */ + public function getServiceAttribute3() + { + return $this->serviceAttribute3; + } + + /** + * @param float $serviceAttribute3 + */ + public function setServiceAttribute3($serviceAttribute3) + { + $this->serviceAttribute3 = floatval($serviceAttribute3); + } + + /** + * @return array + */ + public function toArray() + { + $productArr = array( + 'productId' => $this->productId, + 'tableId' => $this->tableId, + 'contentId' => $this->contentId, + 'id' => $this->getId(), + 'sku' => $this->sku, + 'title' => $this->title, + 'price' => $this->price, + 'specialPrice' => $this->specialPrice, + 'taxClass' => $this->taxClass, + 'quantity' => $this->quantity, + 'price_total' => $this->gross, + 'price_total_gross' => $this->gross, + 'price_total_net' => $this->net, + 'tax' => $this->tax, + 'additional' => $this->additional + ); + + if ($this->beVariants) { + $variantArr = array(); + + foreach ($this->beVariants as $variant) { + /** @var $variant \Extcode\Cart\Domain\Model\Cart\BeVariant */ + array_push($variantArr, array($variant->getId() => $variant->toArray())); + } + + array_push($productArr, array('variants' => $variantArr)); + } + + return $productArr; + } + + /** + * @return string + */ + public function toJson() + { + json_encode($this->toArray()); + } + + /** + * @return void + */ + private function calcGross() + { + if ($this->isNetPrice == false) { + if ($this->beVariants) { + $sum = 0.0; + foreach ($this->beVariants as $variant) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $variant */ + $sum += $variant->getGross(); + } + $this->gross = $sum; + } else { + $this->gross = $this->getBestPrice() * $this->quantity; + } + } else { + $this->calcNet(); + $this->calcTax(); + $this->gross = $this->net + $this->tax; + } + } + + /** + * @return void + */ + private function calcTax() + { + if ($this->isNetPrice == false) { + $this->tax = ($this->gross / (1 + $this->taxClass->getCalc())) * ($this->taxClass->getCalc()); + } else { + $this->tax = ($this->net * $this->taxClass->getCalc()); + } + } + + /** + * @return void + */ + private function calcNet() + { + if ($this->isNetPrice == true) { + if ($this->beVariants) { + $sum = 0.0; + foreach ($this->beVariants as $variant) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $variant */ + $sum += $variant->getNet(); + } + $this->net = $sum; + } else { + $this->net = $this->getBestPrice() * $this->quantity; + } + } else { + $this->calcGross(); + $this->calcTax(); + $this->net = $this->gross - $this->tax; + } + } + + /** + * @return void + */ + private function reCalc() + { + if ($this->beVariants) { + $quantity = 0; + foreach ($this->beVariants as $variant) { + /** @var \Extcode\Cart\Domain\Model\Cart\BeVariant $variant */ + $quantity += $variant->getQuantity(); + } + + if ($this->quantity != $quantity) { + $this->quantity = $quantity; + } + } + + $this->calcGross(); + $this->calcTax(); + $this->calcNet(); + } + + /** + * @return array + */ + public function getAdditionalArray() + { + return $this->additional; + } + + /** + * @param $additional + * @return void + */ + public function setAdditionalArray($additional) + { + $this->additional = $additional; + } + + /** + * @param $key + * @return mixed + */ + public function getAdditional($key) + { + return $this->additional[$key]; + } + + /** + * @param string $key + * @param mixed $value + * + * @return void + */ + public function setAdditional($key, $value) + { + $this->additional[$key] = $value; + } + + /** + * @return int + */ + public function getMinNumberInCart() + { + return $this->minNumberInCart; + } + + /** + * @param int $minNumberInCart + * + * @return void + */ + public function setMinNumberInCart($minNumberInCart) + { + if ($minNumberInCart < 0 || + ($this->maxNumberInCart > 0 && $minNumberInCart > $this->maxNumberInCart) + ) { + throw new \InvalidArgumentException; + } + + $this->minNumberInCart = $minNumberInCart; + } + + /** + * @return int + */ + public function getMaxNumberInCart() + { + return $this->maxNumberInCart; + } + + /** + * @param int $maxNumberInCart + * + * @return void + */ + public function setMaxNumberInCart($maxNumberInCart) + { + if ($maxNumberInCart < 0 || $maxNumberInCart < $this->minNumberInCart) { + throw new \InvalidArgumentException; + } + + $this->maxNumberInCart = $maxNumberInCart; + } +} diff --git a/Classes/Domain/Model/Cart/Shipping.php b/Classes/Domain/Model/Cart/Shipping.php new file mode 100644 index 00000000..21459749 --- /dev/null +++ b/Classes/Domain/Model/Cart/Shipping.php @@ -0,0 +1,27 @@ + + */ +class Shipping extends \Extcode\Cart\Domain\Model\Cart\AbstractService +{ + +} diff --git a/Classes/Domain/Model/Cart/Special.php b/Classes/Domain/Model/Cart/Special.php new file mode 100644 index 00000000..5912adc0 --- /dev/null +++ b/Classes/Domain/Model/Cart/Special.php @@ -0,0 +1,27 @@ + + */ +class Special extends \Extcode\Cart\Domain\Model\Cart\AbstractService +{ + +} diff --git a/Classes/Domain/Model/Cart/TaxClass.php b/Classes/Domain/Model/Cart/TaxClass.php new file mode 100644 index 00000000..6b0ec2af --- /dev/null +++ b/Classes/Domain/Model/Cart/TaxClass.php @@ -0,0 +1,141 @@ + + */ +class TaxClass +{ + /** + * Id + * + * @var int + * @validate NotEmpty + */ + private $id; + + /** + * Value + * + * @var string + * @validate NotEmpty + */ + private $value; + + /** + * Calc + * + * @var float + * @validate NotEmpty + */ + private $calc; + + /** + * Title + * + * @var string + * @validate NotEmpty + */ + private $title; + + /** + * __construct + * + * @param int $id + * @param string $value + * @param float $calc + * @param string $title + * + * @throws \InvalidArgumentException + * @return \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + public function __construct($id, $value, $calc, $title) + { + if (!$id) { + throw new \InvalidArgumentException( + 'You have to specify a valid $id for constructor.', + 1413981328 + ); + } + if (empty($value) && ($value !== '0')) { + throw new \InvalidArgumentException( + 'You have to specify a valid $value for constructor.', + 1413981329 + ); + } + if (($calc === null) || ($calc < 0.0)) { + throw new \InvalidArgumentException( + 'You have to specify a valid $calc for constructor.', + 1413981330 + ); + } + if (empty($title) && ($title !== '0')) { + throw new \InvalidArgumentException( + 'You have to specify a valid $title for constructor.', + 1413981331 + ); + } + + $this->id = $id; + $this->value = $value; + $this->calc = $calc; + $this->title = $title; + } + + /** + * Gets Id + * + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * Gets Value + * + * @return mixed|string + */ + public function getValue() + { + return $this->value; + } + + /** + * Gets Calc + * + * @return int + */ + public function getCalc() + { + return $this->calc; + } + + /** + * Gets Title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } +} diff --git a/Classes/Domain/Model/Category.php b/Classes/Domain/Model/Category.php new file mode 100644 index 00000000..5244c5c0 --- /dev/null +++ b/Classes/Domain/Model/Category.php @@ -0,0 +1,26 @@ + + */ +class Category extends \TYPO3\CMS\Extbase\Domain\Model\Category +{ +} diff --git a/Classes/Domain/Model/Order/AbstractService.php b/Classes/Domain/Model/Order/AbstractService.php new file mode 100644 index 00000000..0e37c27e --- /dev/null +++ b/Classes/Domain/Model/Order/AbstractService.php @@ -0,0 +1,263 @@ + + */ +abstract class AbstractService extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + + /** + * Name + * + * @var string + * @validate NotEmpty + */ + protected $name = ''; + + /** + * Status + * + * @var string + * @validate NotEmpty + */ + protected $status = 'open'; + + /** + * Net + * + * @var float + * @validate NotEmpty + */ + protected $net = 0.0; + + /** + * Gross + * + * @var float + * @validate NotEmpty + */ + protected $gross = 0.0; + + /** + * Order Tax Class + * + * @var \Extcode\Cart\Domain\Model\Order\TaxClass + * @validate NotEmpty + */ + protected $taxClass; + + /** + * Tax + * + * @var float + * @validate NotEmpty + */ + protected $tax = 0.0; + + /** + * Note + * + * @var string + */ + protected $note = ''; + + /** + * Returns ShippingArray + * + * @return array + */ + public function toArray() + { + $service = [ + 'name' => $this->getName(), + 'status' => $this->getStatus(), + 'net' => $this->getNet(), + 'gross' => $this->getGross(), + 'tax' => $this->getTax(), + ]; + + if ($this->getTaxClass()) { + $service['taxClass'] = $this->getTaxClass()->toArray(); + } else { + $service['taxClass'] = null; + } + + $service['note'] = $this->getNote(); + + return $service; + } + + /** + * Returns Name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Sets Name + * + * @param string $name + * + * @return void + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * Returns Status + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Sets Status + * + * @param string $status + * + * @return void + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * Returns Gross + * + * @return float + */ + public function getGross() + { + return $this->gross; + } + + /** + * Sets Gross + * + * @param float $gross + * + * @return void + */ + public function setGross($gross) + { + $this->gross = $gross; + } + + /** + * Returns Net + * + * @return float + * + * @return void + */ + public function getNet() + { + return $this->net; + } + + /** + * Sets Net + * + * @param float $net + * + * @return void + */ + public function setNet($net) + { + $this->net = $net; + } + + /** + * Gets Tax Class + * + * @return \Extcode\Cart\Domain\Model\Order\TaxClass + */ + public function getTaxClass() + { + return $this->taxClass; + } + + /** + * Sets Tax Class + * + * @param \Extcode\Cart\Domain\Model\Order\TaxClass $taxClass + * + * @return void + */ + public function setTaxClass(\Extcode\Cart\Domain\Model\Order\TaxClass $taxClass) + { + $this->taxClass = $taxClass; + } + + /** + * Gets Tax + * + * @return float + */ + public function getTax() + { + return $this->tax; + } + + /** + * Sets Tax + * + * @param float $tax + * + * @return void + */ + public function setTax($tax) + { + $this->tax = $tax; + } + + /** + * Sets Note + * + * @param string $note + * + * @return void + */ + public function setNote($note) + { + $this->note = $note; + } + + /** + * Gets Note + * + * @return string + */ + public function getNote() + { + return $this->note; + } +} diff --git a/Classes/Domain/Model/Order/Address.php b/Classes/Domain/Model/Order/Address.php new file mode 100644 index 00000000..b9820248 --- /dev/null +++ b/Classes/Domain/Model/Order/Address.php @@ -0,0 +1,352 @@ + + */ +class Address extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + + /** + * Title + * + * @var string + */ + protected $title = ''; + + /** + * Salutation + * + * @var string + * @validate NotEmpty + */ + protected $salutation; + + /** + * FirstName + * + * @var string + * @validate NotEmpty + */ + protected $firstName; + + /** + * LastName + * + * @var string + * @validate NotEmpty + */ + protected $lastName; + + /** + * Email + * + * @var string + * @validate NotEmpty + */ + protected $email; + + /** + * Company + * + * @var string + */ + protected $company = ''; + + /** + * Street + * + * @var string + * @validate NotEmpty + */ + protected $street; + + /** + * Zip + * + * @var string + * @validate NotEmpty + */ + protected $zip; + + /** + * City + * + * @var string + * @validate NotEmpty + */ + protected $city; + + /** + * Country + * + * @var string + * @validate NotEmpty + */ + protected $country; + + /** + * Phone + * + * @var string + */ + protected $phone = ''; + + /** + * Fax + * + * @var string + */ + protected $fax = ''; + + /** + * Returns AddressArray + * + * @return array + */ + public function toArray() + { + $address = array( + 'salutation' => $this->getSalutation(), + 'title' => $this->getTitle(), + 'firstName' => $this->getFirstName(), + 'lastName' => $this->getLastName(), + 'company' => $this->getCompany(), + 'street' => $this->getStreet(), + 'zip' => $this->getZip(), + 'city' => $this->getCity(), + 'country' => $this->getCountry(), + 'email' => $this->getEmail(), + 'phone' => $this->getPhone(), + 'fax' => $this->getFax(), + ); + + return $address; + } + + /** + * Get Title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Sets Title + * + * @param string $title + * + * @return void + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * @return string + */ + public function getSalutation() + { + return $this->salutation; + } + + /** + * @param string $salutation + * @return void + */ + public function setSalutation($salutation) + { + $this->salutation = $salutation; + } + + /** + * @return string + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * @param string $firstName + * @return void + */ + public function setFirstName($firstName) + { + $this->firstName = $firstName; + } + + /** + * @return string + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * @param string $email + * @return void + */ + public function setEmail($email) + { + $this->email = $email; + } + + /** + * @return string + */ + public function getCompany() + { + return $this->company; + } + + /** + * @param string $company + * @return void + */ + public function setCompany($company) + { + $this->company = $company; + } + + /** + * @param string $lastName + * @return void + */ + public function setLastName($lastName) + { + $this->lastName = $lastName; + } + + /** + * @return string + */ + public function getStreet() + { + return $this->street; + } + + /** + * @param string $street + * @return void + */ + public function setStreet($street) + { + $this->street = $street; + } + + /** + * @return string + */ + public function getCity() + { + return $this->city; + } + + /** + * @param string $city + * @return void + */ + public function setCity($city) + { + $this->city = $city; + } + + /** + * @return string + */ + public function getZip() + { + return $this->zip; + } + + /** + * @param string $zip + * @return void + */ + public function setZip($zip) + { + $this->zip = $zip; + } + + /** + * @return string + */ + public function getCountry() + { + return $this->country; + } + + /** + * @param string $country + * @return void + */ + public function setCountry($country) + { + $this->country = $country; + } + + /** + * @return string + */ + public function getPhone() + { + return $this->phone; + } + + /** + * @param string $phone + * @return void + */ + public function setPhone($phone) + { + $this->phone = $phone; + } + + /** + * @return string + */ + public function getFax() + { + return $this->fax; + } + + /** + * @param string $fax + * @return void + */ + public function setFax($fax) + { + $this->fax = $fax; + } +} diff --git a/Classes/Domain/Model/Order/Coupon.php b/Classes/Domain/Model/Order/Coupon.php new file mode 100644 index 00000000..c3755d43 --- /dev/null +++ b/Classes/Domain/Model/Order/Coupon.php @@ -0,0 +1,179 @@ + + */ +class Coupon extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + + /** + * Item + * + * @var \Extcode\Cart\Domain\Model\Order\Item + */ + protected $item; + + /** + * Title + * + * @var string + * @validate NotEmpty + */ + protected $title = ''; + + /** + * Code + * + * @var string + * @validate NotEmpty + */ + protected $code = ''; + + /** + * Discount + * + * @var float + * @validate NotEmpty + */ + protected $discount = 0.0; + + /** + * Tax Class + * + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + * @validate NotEmpty + */ + protected $taxClass; + + /** + * Tax + * + * @var float + * @validate NotEmpty + */ + protected $tax = 0.0; + + /** + * __construct + * + * @param string $title + * @param string $code + * @param float $discount + * @param \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass + * @param float $tax + * + * @throws \InvalidArgumentException + */ + public function __construct( + $title, + $code, + $discount, + $taxClass, + $tax + ) { + if (!$title) { + throw new \InvalidArgumentException( + 'You have to specify a valid $title for constructor.', + 1455452810 + ); + } + if (!$code) { + throw new \InvalidArgumentException( + 'You have to specify a valid $code for constructor.', + 1455452820 + ); + } + if (!$discount) { + throw new \InvalidArgumentException( + 'You have to specify a valid $discount for constructor.', + 1455452830 + ); + } + if (!$taxClass) { + throw new \InvalidArgumentException( + 'You have to specify a valid $taxClass for constructor.', + 1455452840 + ); + } + if (!$tax) { + throw new \InvalidArgumentException( + 'You have to specify a valid $tax for constructor.', + 1455452850 + ); + } + + $this->title = $title; + $this->code = $code; + $this->discount = $discount; + $this->taxClass = $taxClass; + $this->tax = $tax; + } + + /** + * Returns Title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Returns Code + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Returns Discount + * + * @return float + */ + public function getDiscount() + { + return $this->discount; + } + + /** + * Returns TaxClass + * + * @return \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + public function getTaxClass() + { + return $this->taxClass; + } + + /** + * Returns Tax + * + * @return float + */ + public function getTax() + { + return $this->tax; + } +} diff --git a/Classes/Domain/Model/Order/Item.php b/Classes/Domain/Model/Order/Item.php new file mode 100644 index 00000000..943221b4 --- /dev/null +++ b/Classes/Domain/Model/Order/Item.php @@ -0,0 +1,928 @@ + + */ +class Item extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + + /** + * FeUser + * + * @var \TYPO3\CMS\Extbase\Domain\Model\FrontendUser + */ + protected $feUser = null; + + /** + * Order Number + * + * @var string + */ + protected $orderNumber; + + /** + * Order Date + * + * @var \DateTime + */ + protected $orderDate = null; + + /** + * Invoice Number + * + * @var string + */ + protected $invoiceNumber; + + /** + * Invoice Date + * + * @var \DateTime + */ + protected $invoiceDate = null; + + /** + * Billing Address + * + * @lazy + * @var \Extcode\Cart\Domain\Model\Order\Address + */ + protected $billingAddress; + + /** + * Shipping Address + * + * @lazy + * @var \Extcode\Cart\Domain\Model\Order\Address + */ + protected $shippingAddress; + + /** + * Additional Data + * + * @var string + */ + protected $additionalData; + + /** + * Currency + * + * @var string + * @validate NotEmpty + */ + protected $currency = '€'; + + /** + * Gross + * + * @var float + * @validate NotEmpty + */ + protected $gross = 0.0; + + /** + * Total Gross + * + * @var float + * @validate NotEmpty + */ + protected $totalGross = 0.0; + + /** + * Net + * + * @var float + * @validate NotEmpty + */ + protected $net = 0.0; + + /** + * Total Net + * + * @var float + * @validate NotEmpty + */ + protected $totalNet = 0.0; + + /** + * TaxClass + * + * @lazy + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage + */ + protected $taxClass; + + /** + * Tax + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage + */ + protected $tax; + + /** + * TotalTax + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage + */ + protected $totalTax; + + /** + * Products + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage + * @lazy + */ + protected $products; + + /** + * Coupons + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage + * @lazy + */ + protected $coupons; + + /** + * Payment + * + * @var \Extcode\Cart\Domain\Model\Order\Payment + */ + protected $payment; + + /** + * Shipping + * + * @var \Extcode\Cart\Domain\Model\Order\Shipping + */ + protected $shipping; + + /** + * Order Pdf + * + * @var string + */ + protected $orderPdf; + + /** + * Invoice Pdf + * + * @var string + */ + protected $invoicePdf; + + /** + * crdate + * + * @var \DateTime + */ + protected $crdate; + + /** + * Accept Terms + * + * @var bool + */ + protected $acceptTerm; + + /** + * Accept Conditions + * + * @var bool + */ + protected $acceptConditions; + + /** + * Comment + * + * @var string + */ + protected $comment; + + /** + * __construct + * + * @return \Extcode\Cart\Domain\Model\Order\Item + */ + public function __construct() + { + $this->initStorageObjects(); + } + + /** + * Initializes all \TYPO3\CMS\Extbase\Persistence\ObjectStorage properties. + * + * @return void + */ + protected function initStorageObjects() + { + $this->products = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->coupons = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->taxClass = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->tax = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->totalTax = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + } + + /** + * @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $feUser + * @return void + */ + public function setFeUser($feUser) + { + $this->feUser = $feUser; + } + + /** + * @return \TYPO3\CMS\Extbase\Domain\Model\FrontendUser + */ + public function getFeUser() + { + return $this->feUser; + } + + /** + * Returns the orderNumber + * + * @return string $orderNumber + */ + public function getOrderNumber() + { + return $this->orderNumber; + } + + /** + * Sets the orderNumber + * + * @param string $orderNumber + * @return string + * + * @throws ResetPropertyException + */ + public function setOrderNumber($orderNumber) + { + if (!$this->orderNumber) { + $this->orderNumber = $orderNumber; + } else { + if ($this->orderNumber != $orderNumber) { + throw new ResetPropertyException('Could not reset orderNumber', 1395306283); + } + } + return $this->orderNumber; + } + + /** + * Gets Order Date + * + * @return \DateTime + */ + public function getOrderDate() + { + return $this->orderDate; + } + + /** + * Sets Order Date + * + * @param \DateTime $orderDate + * + * @return void + */ + public function setOrderDate(\DateTime $orderDate) + { + $this->orderDate = $orderDate; + } + + /** + * Returns the invoiceNumber + * + * @return string + */ + public function getInvoiceNumber() + { + return $this->invoiceNumber; + } + + /** + * Sets the invoiceNumber + * + * @param string $invoiceNumber + * + * @return string + * @throws ResetPropertyException + */ + public function setInvoiceNumber($invoiceNumber) + { + if (!$this->invoiceNumber) { + $this->invoiceNumber = $invoiceNumber; + } else { + if ($this->invoiceNumber != $invoiceNumber) { + throw new ResetPropertyException('Could not reset invoiceNumber', 1395307266); + } + } + return $this->invoiceNumber; + } + + /** + * Gets Invoice Date + * + * @return \DateTime + */ + public function getInvoiceDate() + { + return $this->invoiceDate; + } + + /** + * Sets Invoice Date + * + * @param \DateTime $invoiceDate + * + * @return void + */ + public function setInvoiceDate(\DateTime $invoiceDate) + { + $this->invoiceDate = $invoiceDate; + } + + /** + * Gets Billing Address + * + * @return string + */ + public function getBillingAddress() + { + return $this->billingAddress; + } + + /** + * Set Billing Address + * + * @param string $billingAddress + * + * @return void + */ + public function setBillingAddress($billingAddress) + { + $this->billingAddress = $billingAddress; + } + + /** + * Gets Shipping Address + * + * @return string + */ + public function getShippingAddress() + { + return $this->shippingAddress; + } + + /** + * Set Shopping Address + * + * @param \Extcode\Cart\Domain\Model\Order\Address $shippingAddress + * + * @return void + */ + public function setShippingAddress(\Extcode\Cart\Domain\Model\Order\Address $shippingAddress) + { + $this->shippingAddress = $shippingAddress; + } + + /** + * Remove Shopping Address + * + * @return void + */ + public function removeShippingAddress() + { + $this->shippingAddress = null; + } + + /** + * @return string + */ + public function getAdditionalData() + { + return $this->additionalData; + } + + /** + * @param string $additionalData + */ + public function setAdditionalData($additionalData) + { + $this->additionalData = $additionalData; + } + + /** + * Returns Currency + * + * @return string + */ + public function getCurrency() + { + return $this->currency; + } + + /** + * Sets Currency + * + * @param string $currency + * + * @return void + */ + public function setCurrency($currency) + { + $this->currency = $currency; + } + + /** + * Returns Gross + * + * @return float $gross + */ + public function getGross() + { + return $this->gross; + } + + /** + * Sets Gross + * + * @param float $gross + * @return void + */ + public function setGross($gross) + { + $this->gross = $gross; + } + + /** + * Returns Total Gross + * + * @return float $totalGross + */ + public function getTotalGross() + { + return $this->totalGross; + } + + /** + * Sets Total Gross + * + * @param float $totalGross + * + * @return void + */ + public function setTotalGross($totalGross) + { + $this->totalGross = $totalGross; + } + + /** + * Returns Met + * + * @return float $net + */ + public function getNet() + { + return $this->net; + } + + /** + * Sets Net + * + * @param float $net + * + * @return void + */ + public function setNet($net) + { + $this->net = $net; + } + + /** + * Returns Total Net + * + * @return float $totalNet + */ + public function getTotalNet() + { + return $this->totalNet; + } + + /** + * Sets Total Net + * + * @param float $totalNet + * + * @return void + */ + public function setTotalNet($totalNet) + { + $this->totalNet = $totalNet; + } + + /** + * Sets Payment + * + * @param \Extcode\Cart\Domain\Model\Order\Payment $payment + * + * @return void + */ + public function setPayment(\Extcode\Cart\Domain\Model\Order\Payment $payment) + { + $this->payment = $payment; + } + + /** + * Gets Payment + * + * @return \Extcode\Cart\Domain\Model\Order\Payment + */ + public function getPayment() + { + return $this->payment; + } + + /** + * Sets Shipping + * + * @param \Extcode\Cart\Domain\Model\Order\Shipping $shipping + * + * @return void + */ + public function setShipping(\Extcode\Cart\Domain\Model\Order\Shipping $shipping) + { + $this->shipping = $shipping; + } + + /** + * Gets Shipping + * + * @return \Extcode\Cart\Domain\Model\Order\Shipping + */ + public function getShipping() + { + return $this->shipping; + } + + /** + * Returns Order PDF + * + * @return string $orderPdf + */ + public function getOrderPdf() + { + return $this->orderPdf; + } + + /** + * Sets Order PDF + * + * @param string $orderPdf + * + * @return void + */ + public function setOrderPdf($orderPdf) + { + $this->orderPdf = $orderPdf; + } + + /** + * Sets Invoice PDF + * + * @return string + */ + public function getInvoicePdf() + { + return $this->invoicePdf; + } + + /** + * Sets Invoice PDF + * + * @param string $invoicePdf + * + * @return void + */ + public function setInvoicePdf($invoicePdf) + { + $this->invoicePdf = $invoicePdf; + } + + /** + * Adds a TaxClass + * + * @param \Extcode\Cart\Domain\Model\Order\TaxClass $taxClass + * + * @return void + */ + public function addTaxClass(\Extcode\Cart\Domain\Model\Order\TaxClass $taxClass) + { + $this->taxClass->attach($taxClass); + } + + /** + * Removes a OrderTaxClass + * + * @param \Extcode\Cart\Domain\Model\Order\TaxClass $taxClassToRemove + * + * @return void + */ + public function removeTaxClass(\Extcode\Cart\Domain\Model\Order\TaxClass $taxClassToRemove) + { + $this->taxClass->detach($taxClassToRemove); + } + + /** + * Returns TaxClass + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Order\TaxClass> $taxClass + */ + public function getTaxClass() + { + return $this->taxClass; + } + + /** + * Sets TaxClass + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage <\Extcode\Cart\Domain\Model\Order\TaxClass> $taxClass + * + * @return void + */ + public function setTaxClass($taxClass) + { + $this->taxClass = $taxClass; + } + + /** + * Adds a Product + * + * @param \Extcode\Cart\Domain\Model\Order\Product $product + * + * @return void + */ + public function addProduct(\Extcode\Cart\Domain\Model\Order\Product $product) + { + $this->products->attach($product); + } + + /** + * Removes a Product + * + * @param \Extcode\Cart\Domain\Model\Order\Product $productToRemove + * + * @return void + */ + public function removeProduct(\Extcode\Cart\Domain\Model\Order\Product $productToRemove) + { + $this->products->detach($productToRemove); + } + + /** + * Returns product + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Order\Product> $products + */ + public function getProducts() + { + return $this->products; + } + + /** + * Sets Product + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Order\Product> $products + * + * @return void + */ + public function setProducts($products) + { + $this->products = $products; + } + + /** + * Adds a Coupon + * + * @param \Extcode\Cart\Domain\Model\Order\Coupon $coupon + * + * @return void + */ + public function addCoupon(\Extcode\Cart\Domain\Model\Order\Coupon $coupon) + { + $this->coupons->attach($coupon); + } + + /** + * Removes a Coupon + * + * @param \Extcode\Cart\Domain\Model\Order\Coupon $couponToRemove + * + * @return void + */ + public function removeCoupon(\Extcode\Cart\Domain\Model\Order\Coupon $couponToRemove) + { + $this->coupons->detach($couponToRemove); + } + + /** + * Returns Coupons + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Order\Coupon> $coupon + */ + public function getCoupons() + { + return $this->coupons; + } + + /** + * Sets Coupons + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Order\Coupon> $coupons + * + * @return void + */ + public function setCoupons($coupons) + { + $this->coupons = $coupons; + } + + /** + * Adds a Tax + * + * @param \Extcode\Cart\Domain\Model\Order\Tax $tax + * @return void + */ + public function addTax($tax) + { + $this->tax->attach($tax); + } + + /** + * Removes a Tax + * + * @param \Extcode\Cart\Domain\Model\Order\Tax $taxToRemove + * @return void + */ + public function removeTax($taxToRemove) + { + $this->tax->detach($taxToRemove); + } + + /** + * Returns the Tax + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\OrderTax> + */ + public function getTax() + { + return $this->tax; + } + + /** + * Sets the Tax + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Order\Tax> $tax + * @return void + */ + public function setTax($tax) + { + $this->tax = $tax; + } + + /** + * Adds a TotalTax + * + * @param \Extcode\Cart\Domain\Model\Order\Tax $totalTax + * @return void + */ + public function addTotalTax($totalTax) + { + $this->totalTax->attach($totalTax); + } + + /** + * Removes a TotalTax + * + * @param \Extcode\Cart\Domain\Model\Order\Tax $totalTaxToRemove + * @return void + */ + public function removeTotalTax($totalTaxToRemove) + { + $this->totalTax->detach($totalTaxToRemove); + } + + /** + * Returns the TotalTax + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Order\Tax> $totalTax + */ + public function getTotalTax() + { + return $this->totalTax; + } + + /** + * Sets the TotalTax + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Order\Tax> $totalTax + * @return void + */ + public function setTotalTax($totalTax) + { + $this->totalTax = $totalTax; + } + + /** + * Returns the crdate + * + * @return \DateTime $crdate + */ + public function getCrdate() + { + return $this->crdate; + } + + /** + * Sets the crdate + * + * @param \DateTime $crdate + * @return void + */ + public function setCrdate($crdate) + { + $this->crdate = $crdate; + } + + /** + * @return bool + */ + public function getAcceptConditions() + { + return $this->acceptConditions; + } + + /** + * @param bool $acceptConditions + * @return void + */ + public function setAcceptConditions($acceptConditions) + { + $this->acceptConditions = $acceptConditions; + } + + /** + * @return bool + */ + public function getAcceptTerm() + { + return $this->acceptTerm; + } + + /** + * @param bool $acceptTerm + * @return void + */ + public function setAcceptTerm($acceptTerm) + { + $this->acceptTerm = $acceptTerm; + } + + /** + * @return string + */ + public function getComment() + { + return $this->comment; + } + + /** + * @param string $comment + * @return void + */ + public function setComment($comment) + { + $this->comment = $comment; + } +} diff --git a/Classes/Domain/Model/Order/Payment.php b/Classes/Domain/Model/Order/Payment.php new file mode 100644 index 00000000..2f4dc4ea --- /dev/null +++ b/Classes/Domain/Model/Order/Payment.php @@ -0,0 +1,143 @@ + + */ +class Payment extends \Extcode\Cart\Domain\Model\Order\AbstractService +{ + + /** + * Provider + * + * @var string + */ + protected $provider = ''; + + /** + * Transactions + * + * @lazy + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage + */ + protected $transactions = null; + + /** + * __construct + * + * @return \Extcode\Cart\Domain\Model\Order\Payment + */ + public function __construct() + { + $this->initStorageObjects(); + } + + /** + * Initializes all \TYPO3\CMS\Extbase\Persistence\ObjectStorage properties. + * + * @return void + */ + protected function initStorageObjects() + { + $this->transactions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + } + + /** + * Returns PaymentArray + * + * @return array + */ + public function toArray() + { + $payment = parent::toArray(); + + $payment['provider'] = $this->getProvider(); + + return $payment; + } + + /** + * Returns Provider + * + * @return string + */ + public function getProvider() + { + return $this->provider; + } + + /** + * Sets Provider + * + * @param string $provider + * + * @return void + */ + public function setProvider($provider) + { + $this->provider = $provider; + } + + /** + * Adds a Transaction + * + * @param \Extcode\Cart\Domain\Model\Order\Transaction $transaction + * + * @return void + */ + public function addTransaction(\Extcode\Cart\Domain\Model\Order\Transaction $transaction) + { + $this->transactions->attach($transaction); + } + + /** + * Removes a Transaction + * + * @param \Extcode\Cart\Domain\Model\Order\Transaction $transactionsToRemove + * + * @return void + */ + public function removeTransaction(\Extcode\Cart\Domain\Model\Order\Transaction $transactionsToRemove) + { + $this->transactions->detach($transactionsToRemove); + } + + /** + * Returns transactions + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage + */ + public function getTransactions() + { + return $this->transactions; + } + + /** + * Sets Transaction + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Order\Transaction> $transactions + * + * @return void + */ + public function setTransactions($transactions) + { + $this->transactions = $transactions; + } +} diff --git a/Classes/Domain/Model/Order/Product.php b/Classes/Domain/Model/Order/Product.php new file mode 100644 index 00000000..04e5894f --- /dev/null +++ b/Classes/Domain/Model/Order/Product.php @@ -0,0 +1,407 @@ + + */ +class Product extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + + /** + * Item + * + * @var \Extcode\Cart\Domain\Model\Order\Item + */ + protected $item; + + /** + * Sku + * + * @var string + * @validate NotEmpty + */ + protected $sku; + + /** + * Title + * + * @var string + * @validate NotEmpty + */ + protected $title; + + /** + * Count + * + * @var int + * @validate NotEmpty + */ + protected $count = 0; + + /** + * Price + * + * @var float + * @validate NotEmpty + */ + protected $price = 0.0; + + /** + * Discount + * + * @var float + * @validate NotEmpty + */ + protected $discount = 0.0; + + /** + * Gross + * + * @var float + * @validate NotEmpty + */ + protected $gross = 0.0; + + /** + * Gross + * + * @var float + * @validate NotEmpty + */ + protected $net = 0.0; + + /** + * Order Tax Class + * + * @var \Extcode\Cart\Domain\Model\Order\TaxClass + * @validate NotEmpty + */ + protected $taxClass; + + /** + * Tax + * + * @var float + * @validate NotEmpty + */ + protected $tax = 0.0; + + /** + * Additional Data + * + * @var string + */ + protected $additionalData; + + /** + * Product Additional + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage + */ + protected $productAdditional; + + /** + * __construct + * + * @param string $sku + * @param string $title + * @param int $count + * + * @return \Extcode\Cart\Domain\Model\Order\Product + */ + public function __construct( + $sku, + $title, + $count + ) { + if (!$sku) { + throw new \InvalidArgumentException( + 'You have to specify a valid $sku for constructor.', + 1456830010 + ); + } + if (!$title) { + throw new \InvalidArgumentException( + 'You have to specify a valid $title for constructor.', + 1456830020 + ); + } + if (!$count) { + throw new \InvalidArgumentException( + 'You have to specify a valid $count for constructor.', + 1456830030 + ); + } + + $this->sku = $sku; + $this->title = $title; + $this->count = $count; + + $this->initStorageObjects(); + } + + /** + * Initializes all \TYPO3\CMS\Extbase\Persistence\ObjectStorage properties. + * + * @return void + */ + protected function initStorageObjects() + { + $this->productAdditional = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + } + + /** + * Gets Additional Data + * + * @return string + */ + public function getAdditionalData() + { + return $this->additionalData; + } + + /** + * Sets Additional Data + * + * @param string $additionalData + * + * @return void + */ + public function setAdditionalData($additionalData) + { + $this->additionalData = $additionalData; + } + + /** + * Gets Count + * + * @return int + */ + public function getCount() + { + return $this->count; + } + + /** + * Sets Price + * + * @param float $price + * + * @return void + */ + public function setPrice($price) + { + $this->price = $price; + } + + /** + * Gets Price + * + * @return float + */ + public function getPrice() + { + return $this->price; + } + + /** + * Sets Discount + * + * @param float $discount + * + * @return void + */ + public function setDiscount($discount) + { + $this->discount = $discount; + } + + /** + * Gets Discount + * + * @return float + */ + public function getDiscount() + { + return $this->discount; + } + + /** + * Sets Gross + * + * @param float $gross + * + * @return void + */ + public function setGross($gross) + { + $this->gross = $gross; + } + + /** + * Gets Gross + * + * @return float + */ + public function getGross() + { + return $this->gross; + } + + /** + * Sets Net + * + * @param float $net + * + * @return void + */ + public function setNet($net) + { + $this->net = $net; + } + + /** + * Gets Net + * + * @return float + */ + public function getNet() + { + return $this->net; + } + + /** + * Gets Sku + * + * @return string + */ + public function getSku() + { + return $this->sku; + } + + /** + * Gets Tax Class + * + * @return \Extcode\Cart\Domain\Model\Order\TaxClass + */ + public function getTaxClass() + { + return $this->taxClass; + } + + /** + * Sets Tax Class + * + * @param \Extcode\Cart\Domain\Model\Order\TaxClass $taxClass + * + * @return void + */ + public function setTaxClass(\Extcode\Cart\Domain\Model\Order\TaxClass $taxClass) + { + $this->taxClass = $taxClass; + } + + /** + * Gets Tax + * + * @return float + */ + public function getTax() + { + return $this->tax; + } + + /** + * Sets Tax + * + * @param float $tax + * + * @return void + */ + public function setTax($tax) + { + $this->tax = $tax; + } + + /** + * Gets Title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Adds a ProductAdditional + * + * @param \Extcode\Cart\Domain\Model\Order\ProductAdditional $productAdditional + * + * @return void + */ + public function addProductAdditional(\Extcode\Cart\Domain\Model\Order\ProductAdditional $productAdditional) + { + $this->productAdditional->attach($productAdditional); + } + + /** + * Removes a ProductAdditional + * + * @param \Extcode\Cart\Domain\Model\Order\ProductAdditional $productAdditional + * + * @return void + */ + public function removeProductAdditional(\Extcode\Cart\Domain\Model\Order\ProductAdditional $productAdditional) + { + $this->productAdditional->detach($productAdditional); + } + + /** + * Returns the ProductAdditional + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Order\ProductAdditional> + */ + public function getProductAdditional() + { + return $this->productAdditional; + } + + /** + * Sets the ProductAdditional + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Order\ProductAdditional> $productAdditional + */ + public function setProductAdditional(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $productAdditional) + { + $this->productAdditional = $productAdditional; + } + + /** + * Gets Item + * + * @return \Extcode\Cart\Domain\Model\Order\Item + */ + public function getItem() + { + return $this->item; + } +} diff --git a/Classes/Domain/Model/Order/ProductAdditional.php b/Classes/Domain/Model/Order/ProductAdditional.php new file mode 100644 index 00000000..5dbb9e72 --- /dev/null +++ b/Classes/Domain/Model/Order/ProductAdditional.php @@ -0,0 +1,149 @@ + + */ +class ProductAdditional extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + /** + * Additional Type + * + * @var string + * @validate NotEmpty + */ + protected $additionalType; + + /** + * Additional Key + * + * @var string + * @validate NotEmpty + */ + protected $additionalKey; + + /** + * Additional Value + * + * @var string + * @validate NotEmpty + */ + protected $additionalValue; + + /** + * Additional Data + * + * @var string + */ + protected $additionalData = ''; + + /** + * __construct + * + * @param string $additionalType + * @param string $additionalKey + * @param string $additionalValue + * @param string $additionalData + * + * @throws \InvalidArgumentException + */ + public function __construct( + $additionalType, + $additionalKey, + $additionalValue, + $additionalData = '' + ) { + if (!$additionalType) { + throw new \InvalidArgumentException( + 'You have to specify a valid $additionalType for constructor.', + 1456828210 + ); + } + if (!$additionalKey) { + throw new \InvalidArgumentException( + 'You have to specify a valid $additionalKey for constructor.', + 1456828220 + ); + } + if (!$additionalValue) { + throw new \InvalidArgumentException( + 'You have to specify a valid $additionalValue for constructor.', + 1456828230 + ); + } + + $this->additionalType = $additionalType; + $this->additionalKey = $additionalKey; + $this->additionalValue = $additionalValue; + $this->additionalData = $additionalData; + } + + /** + * Returns Additional Type + * + * @return string + */ + public function getAdditionalType() + { + return $this->additionalType; + } + + /** + * Returns Additional Key + * + * @return string + */ + public function getAdditionalKey() + { + return $this->additionalKey; + } + + /** + * Returns Additional Value + * + * @return string + */ + public function getAdditionalValue() + { + return $this->additionalValue; + } + + /** + * Returns Additional Data + * + * @return string + */ + public function getAdditionalData() + { + return $this->additionalData; + } + + /** + * Sets Additional Data + * + * @param string $additionalData + * + * @return void + */ + public function setAdditionalData($additionalData) + { + $this->additionalData = $additionalData; + } +} diff --git a/Classes/Domain/Model/Order/Shipping.php b/Classes/Domain/Model/Order/Shipping.php new file mode 100644 index 00000000..43471681 --- /dev/null +++ b/Classes/Domain/Model/Order/Shipping.php @@ -0,0 +1,27 @@ + + */ +class Shipping extends \Extcode\Cart\Domain\Model\Order\AbstractService +{ + +} diff --git a/Classes/Domain/Model/Order/Tax.php b/Classes/Domain/Model/Order/Tax.php new file mode 100644 index 00000000..4cce3d0e --- /dev/null +++ b/Classes/Domain/Model/Order/Tax.php @@ -0,0 +1,90 @@ + + */ +class Tax extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + /** + * Tax + * + * @var float + * @validate NotEmpty + */ + protected $tax; + + /** + * TaxClass + * + * @var \Extcode\Cart\Domain\Model\Order\TaxClass + * @validate NotEmpty + */ + protected $taxClass; + + /** + * __construct + * + * @param float $tax + * @param \Extcode\Cart\Domain\Model\Order\TaxClass $taxClass + * + * @return \Extcode\Cart\Domain\Model\Order\TaxClass + */ + public function __construct( + $tax, + $taxClass + ) { + if (!$tax) { + throw new \InvalidArgumentException( + 'You have to specify a valid $tax for constructor.', + 1456836510 + ); + } + if (!$taxClass) { + throw new \InvalidArgumentException( + 'You have to specify a valid $taxClass for constructor.', + 1456836520 + ); + } + + $this->tax = $tax; + $this->taxClass = $taxClass; + } + + /** + * Gets Tax + * + * @return float + */ + public function getTax() + { + return $this->tax; + } + + /** + * Gets Tax Class + * + * @return \Extcode\Cart\Domain\Model\Order\TaxClass + */ + public function getTaxClass() + { + return $this->taxClass; + } +} diff --git a/Classes/Domain/Model/Order/TaxClass.php b/Classes/Domain/Model/Order/TaxClass.php new file mode 100644 index 00000000..f4cc81c1 --- /dev/null +++ b/Classes/Domain/Model/Order/TaxClass.php @@ -0,0 +1,134 @@ + + */ +class TaxClass extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + + /** + * Title + * + * @var string + * @validate NotEmpty + */ + protected $title; + + /** + * Value + * + * @var string + * @validate NotEmpty + */ + protected $value; + + /** + * Calc + * + * @var float + * @validate NotEmpty + */ + protected $calc = 0.0; + + /** + * __construct + * + * @param string $title + * @param string $value + * @param float $calc + * + * @return \Extcode\Cart\Domain\Model\Order\TaxClass + */ + public function __construct( + $title, + $value, + $calc + ) { + if (!$title) { + throw new \InvalidArgumentException( + 'You have to specify a valid $title for constructor.', + 1456830910 + ); + } + if (empty($value) && $value !== '0') { + throw new \InvalidArgumentException( + 'You have to specify a valid $value for constructor.', + 1456830920 + ); + } + if ($calc === null) { + throw new \InvalidArgumentException( + 'You have to specify a valid $calc for constructor.', + 1456830930 + ); + } + + $this->title = $title; + $this->value = $value; + $this->calc = $calc; + } + + /** + * Returns TaxClassArray + * + * @return array + */ + public function toArray() + { + $taxClassArray = array( + 'title' => $this->getTitle(), + 'value' => $this->getValue(), + 'calc' => $this->getCalc(), + ); + + return $taxClassArray; + } + + /** + * Gets Calc + * + * @return float + */ + public function getCalc() + { + return $this->calc; + } + + /** + * Gets Title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Gets Value + * + * @return string + */ + public function getValue() + { + return $this->value; + } +} diff --git a/Classes/Domain/Model/Order/Transaction.php b/Classes/Domain/Model/Order/Transaction.php new file mode 100644 index 00000000..67a6805f --- /dev/null +++ b/Classes/Domain/Model/Order/Transaction.php @@ -0,0 +1,50 @@ + + */ +class Transaction extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + /** + * txnId + * + * @var string + * @validate NotEmpty + */ + protected $txnId = ''; + + /** + * @return string + */ + public function getTxnId() + { + return $this->txnId; + } + + /** + * @param string $txnId + * @return void + */ + public function setTxnId($txnId) + { + $this->txnId = $txnId; + } +} diff --git a/Classes/Domain/Model/Product/AbstractProduct.php b/Classes/Domain/Model/Product/AbstractProduct.php new file mode 100644 index 00000000..f707bea1 --- /dev/null +++ b/Classes/Domain/Model/Product/AbstractProduct.php @@ -0,0 +1,113 @@ + + */ +class AbstractProduct extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + + /** + * SKU + * + * @var string + */ + protected $sku = ''; + + /** + * Title + * + * @var string + */ + protected $title = ''; + + /** + * Description + * + * @var string + */ + protected $description = ''; + + /** + * Returns SKU + * + * @return string $sku + */ + public function getSku() + { + return $this->sku; + } + + /** + * Sets SKU + * + * @param string $sku + * + * @return void + */ + public function setSku($sku) + { + $this->sku = $sku; + } + + /** + * Returns Title + * + * @return string $title + */ + public function getTitle() + { + return $this->title; + } + + /** + * Sets Title + * + * @param string $title + * + * @return void + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * Returns Description + * + * @return string $description + */ + public function getDescription() + { + return $this->description; + } + + /** + * Sets Description + * + * @param string $description + * + * @return void + */ + public function setDescription($description) + { + $this->description = $description; + } +} diff --git a/Classes/Domain/Model/Product/BeVariant.php b/Classes/Domain/Model/Product/BeVariant.php new file mode 100644 index 00000000..1bedc7ed --- /dev/null +++ b/Classes/Domain/Model/Product/BeVariant.php @@ -0,0 +1,443 @@ + + */ +class BeVariant extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + + /** + * Product + * + * @var \Extcode\Cart\Domain\Model\Product\Product + */ + protected $product = null; + + /** + * Variant Attribute 1 + * + * @var \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption + */ + protected $beVariantAttributeOption1 = null; + + /** + * Variant Attribute 2 + * + * @var \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption + */ + protected $beVariantAttributeOption2 = null; + + /** + * Variant Attribute 3 + * + * @var \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption + */ + protected $beVariantAttributeOption3 = null; + + /** + * Price + * + * @var float + */ + protected $price = 0.0; + + /** + * Price Calc Method + * + * @var int + */ + protected $priceCalcMethod = 0; + + /** + * Price Measure + * + * @var float + */ + protected $priceMeasure = 0.0; + + /** + * Price Measure Unit + * + * @var string + */ + protected $priceMeasureUnit = ''; + + /** + * stock + * + * @var int + */ + protected $stock = 0; + + /** + * Returns the Product + * + * @return \Extcode\Cart\Domain\Model\Product\Product + */ + public function getProduct() + { + return $this->product; + } + + /** + * Returns the Variant Attribute 1 + * + * @return \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption + */ + public function getBeVariantAttributeOption1() + { + return $this->beVariantAttributeOption1; + } + + /** + * Sets the Variant Attribute 1 + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption $beVariantAttributeOption1 + * @return void + */ + public function setBeVariantAttributeOption1( + \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption $beVariantAttributeOption1 + ) { + $this->beVariantAttributeOption1 = $beVariantAttributeOption1; + } + + /** + * Returns the Variant Attribute 2 + * + * @return \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption + */ + public function getBeVariantAttributeOption2() + { + return $this->beVariantAttributeOption2; + } + + /** + * Sets the Variant Attribute 2 + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption $beVariantAttributeOption2 + * @return void + */ + public function setBeVariantAttributeOption2( + \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption $beVariantAttributeOption2 + ) { + $this->beVariantAttributeOption2 = $beVariantAttributeOption2; + } + + /** + * Returns the Variant Attribute 3 + * + * @return \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption + */ + public function getBeVariantAttributeOption3() + { + return $this->beVariantAttributeOption3; + } + + /** + * Sets the Variant Attribute 3 + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption $beVariantAttributeOption3 + * @return void + */ + public function setBeVariantAttributeOption3( + \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption $beVariantAttributeOption3 + ) { + $this->beVariantAttributeOption3 = $beVariantAttributeOption3; + } + + /** + * Gets Price Calculated + * + * @return float + */ + public function getPriceCalculated() + { + $price = $this->getPrice(); + + $parentPrice = $this->getProduct()->getBestSpecialPrice(); + + switch ($this->priceCalcMethod) { + case 3: + $discount = -1 * (($price / 100) * ($parentPrice)); + break; + case 5: + $discount = ($price / 100) * ($parentPrice); + break; + default: + $discount = 0; + } + + if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) { + foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount'] as $funcRef) { + if ($funcRef) { + $params = array( + 'price_calc_method' => $this->priceCalcMethod, + 'price' => &$price, + 'parent_price' => &$parentPrice, + 'discount' => &$discount, + ); + + \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); + } + } + } + + switch ($this->priceCalcMethod) { + case 1: + $parentPrice = 0.0; + break; + case 2: + $price = -1 * $price; + break; + case 4: + break; + default: + $price = 0.0; + } + + return $parentPrice + $price + $discount; + } + + /** + * Returns the price + * + * @return float $price + */ + public function getPrice() + { + return $this->price; + } + + /** + * Sets the price + * + * @param float $price + * @return void + */ + public function setPrice($price) + { + $this->price = $price; + } + + /** + * @return int + */ + public function getPriceCalcMethod() + { + return $this->priceCalcMethod; + } + + /** + * @param int $priceCalcMethod + * @return void + */ + public function setPriceCalcMethod($priceCalcMethod) + { + $this->priceCalcMethod = $priceCalcMethod; + } + + /** + * Returns the Base Price + * + * @return float $price + */ + public function getBasePrice() + { + #TODO: respects different measuring units between variant and product + if (!$this->getProduct()->getBasePriceMeasure() > 0) { + return null; + } + if (!$this->getPriceMeasure() > 0) { + return null; + } + $ratio = $this->getProduct()->getBasePriceMeasure() / $this->getPriceMeasure(); + + $price = round($this->price * $ratio * 100.0) / 100.0; + + return $price; + } + + /** + * Returns the Price Measure + * + * @return float $priceMeasure + */ + public function getPriceMeasure() + { + return $this->priceMeasure; + } + + /** + * Sets the Price Measure + * + * @param float $priceMeasure + * @return void + */ + public function setPriceMeasure($priceMeasure) + { + $this->priceMeasure = $priceMeasure; + } + + /** + * Returns the Price Measure Unit + * + * @return string $priceMeasureUnit + */ + public function getPriceMeasureUnit() + { + return $this->priceMeasureUnit; + } + + /** + * Sets the Price Measure Unit + * + * @param string $priceMeasureUnit + * @return void + */ + public function setPriceMeasureUnit($priceMeasureUnit) + { + $this->priceMeasureUnit = $priceMeasureUnit; + } + + /** + * Check Measure Unit Compatibility + * + * @return bool + */ + public function getIsMeasureUnitCompatibility() + { + foreach ($this->product->getMeasureUnits() as $measureUnit) { + if (array_key_exists($this->product->getBasePriceMeasureUnit(), $measureUnit) + && array_key_exists($this->priceMeasureUnit, $measureUnit) + ) { + return true; + } + } + + return false; + } + + /** + * Get Measure Unit Faktor + * + * @return bool + */ + public function getMeasureUnitFactor() + { + $factor = 1.0; + + foreach ($this->product->getMeasureUnits() as $measureUnit) { + if ($measureUnit[$this->priceMeasureUnit]) { + $factor = $factor / ($this->priceMeasure / $measureUnit[$this->priceMeasureUnit]); + } + if ($measureUnit[$this->product->getBasePriceMeasureUnit()]) { + $factor = $factor * (1 / $measureUnit[$this->product->getBasePriceMeasureUnit()]); + } + } + + return $factor; + } + + /** + * Returns Calculated Base Price + * + * @return float|bool + */ + public function getCalculatedBasePrice() + { + if ($this->getIsMeasureUnitCompatibility()) { + return $this->getPriceCalculated() * $this->getMeasureUnitFactor(); + } + + return false; + } + + /** + * Returns the Stock + * + * @return int + */ + public function getStock() + { + return $this->stock; + } + + /** + * Set the Stock + * + * @param int $stock + */ + public function setStock($stock) + { + $this->stock = $stock; + } + + /** + * Returns the calculated SKU + * + * @return string + */ + public function getSku() + { + $skuArray = array(); + + if ($this->getProduct()->getBeVariantAttribute1()) { + $skuArray[] = $this->getProduct()->getBeVariantAttribute1()->getSku(); + $skuArray[] = $this->getBeVariantAttributeOption1()->getSku(); + } + + if ($this->getProduct()->getBeVariantAttribute2()) { + $skuArray[] = $this->getProduct()->getBeVariantAttribute2()->getSku(); + $skuArray[] = $this->getBeVariantAttributeOption2()->getSku(); + } + + if ($this->getProduct()->getBeVariantAttribute3()) { + $skuArray[] = $this->getProduct()->getBeVariantAttribute3()->getSku(); + $skuArray[] = $this->getBeVariantAttributeOption3()->getSku(); + } + + return join('-', $skuArray); + } + + /** + * Returns the calculated Title + * + * @return string + */ + public function getTitle() + { + $titleArray = array(); + + if ($this->getProduct()->getBeVariantAttribute1()) { + $titleArray[] = $this->getBeVariantAttributeOption1()->getTitle(); + } + + if ($this->getProduct()->getBeVariantAttribute2()) { + $titleArray[] = $this->getBeVariantAttributeOption2()->getTitle(); + } + + if ($this->getProduct()->getBeVariantAttribute3()) { + $titleArray[] = $this->getBeVariantAttributeOption3()->getTitle(); + } + + return join(' ', $titleArray); + } +} diff --git a/Classes/Domain/Model/Product/BeVariantAttribute.php b/Classes/Domain/Model/Product/BeVariantAttribute.php new file mode 100644 index 00000000..cc226382 --- /dev/null +++ b/Classes/Domain/Model/Product/BeVariantAttribute.php @@ -0,0 +1,101 @@ + + */ +class BeVariantAttribute extends \Extcode\Cart\Domain\Model\Product\AbstractProduct +{ + /** + * BeVariantAttributeOptions + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption> + */ + protected $beVariantAttributeOptions = null; + + /** + * __construct + * + * @return \Extcode\Cart\Domain\Model\Product\BeVariantAttribute + */ + public function __construct() + { + $this->initStorageObjects(); + } + + /** + * Initializes all \TYPO3\CMS\Extbase\Persistence\ObjectStorage properties. + * + * @return void + */ + protected function initStorageObjects() + { + $this->beVariantAttributeOptions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + } + + /** + * Adds BeVariantAttributeOption + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption $beVariantAttributeOption + * + * @return void + */ + public function addBeVariantAttributeOption( + \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption $beVariantAttributeOption + ) { + $this->beVariantAttributeOptions->attach($beVariantAttributeOption); + } + + /** + * Removes BeVariantAttributeOption + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption $beVariantAttributeOption + * + * @return void + */ + public function removeBeVariantAttributeOption( + \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption $beVariantAttributeOption + ) { + $this->beVariantAttributeOptions->detach($beVariantAttributeOption); + } + + /** + * Returns BeVariantAttributeOptions + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption> + */ + public function getBeVariantAttributeOptions() + { + return $this->beVariantAttributeOptions; + } + + /** + * Sets BeVariantAttributeOptions + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $beVariantAttributeOptions + * + * @return void + */ + public function setBeVariantAttributeOptions( + \TYPO3\CMS\Extbase\Persistence\ObjectStorage $beVariantAttributeOptions + ) { + $this->beVariantAttributeOptions = $beVariantAttributeOptions; + } +} diff --git a/Classes/Domain/Model/Product/BeVariantAttributeOption.php b/Classes/Domain/Model/Product/BeVariantAttributeOption.php new file mode 100644 index 00000000..0053492f --- /dev/null +++ b/Classes/Domain/Model/Product/BeVariantAttributeOption.php @@ -0,0 +1,27 @@ + + */ +class BeVariantAttributeOption extends \Extcode\Cart\Domain\Model\Product\AbstractProduct +{ + +} diff --git a/Classes/Domain/Model/Product/Coupon.php b/Classes/Domain/Model/Product/Coupon.php new file mode 100644 index 00000000..e7f7452b --- /dev/null +++ b/Classes/Domain/Model/Product/Coupon.php @@ -0,0 +1,269 @@ + + */ +class Coupon extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + /** + * Title + * + * @var string + */ + protected $title = ''; + + /** + * Code + * + * @var string + */ + protected $code = ''; + + /** + * Discount + * + * @var float + */ + protected $discount = 0.0; + + /** + * Tax Class Id + * + * @var int + */ + protected $taxClassId; + + /** + * Cart Min Price + * + * @var float + */ + protected $cartMinPrice = 0.0; + + /** + * Is Combinable + * + * @var bool + */ + protected $isCombinable = false; + + /** + * Is Relative Discount + * + * @var bool + */ + protected $isRelativeDiscount = false; + + /** + * Number Available + * + * @var integer + */ + protected $numberAvailable = 0; + + /** + * Number Used + * + * @var integer + */ + protected $numberUsed = 0; + + /** + * __construct + * + * @param string $title + * @param string $code + * @param float $discount + * @param int $taxClassId + * + * @throws \InvalidArgumentException + */ + public function __construct( + $title, + $code, + $discount, + $taxClassId + ) { + if (!$title) { + throw new \InvalidArgumentException( + 'You have to specify a valid $title for constructor.', + 1456840910 + ); + } + if (!$code) { + throw new \InvalidArgumentException( + 'You have to specify a valid $code for constructor.', + 1456840920 + ); + } + if (!$discount) { + throw new \InvalidArgumentException( + 'You have to specify a valid $discount for constructor.', + 1456840930 + ); + } + if (!$taxClassId) { + throw new \InvalidArgumentException( + 'You have to specify a valid $taxClassId for constructor.', + 1456840940 + ); + } + + $this->title = $title; + $this->code = $code; + $this->discount = $discount; + $this->taxClassId = $taxClassId; + } + + /** + * Gets Title + * + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * Gets Code + * + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * Is Relative Discount + * + * @return bool + */ + public function isRelativeDiscount() + { + return $this->isRelativeDiscount; + } + + /** + * Gets Discount + * + * @return float + */ + public function getDiscount() + { + return $this->discount; + } + + /** + * Gets Tax Class Id + * + * @return int + */ + public function getTaxClassId() + { + return $this->taxClassId; + } + + /** + * Returns Cart Min Price + * + * @return float + */ + public function getCartMinPrice() + { + return $this->cartMinPrice; + } + + /** + * Sets Cart Min Price + * + * @param float $cartminPrice + * @return void + */ + public function setCartMinPrice($cartMinPrice) + { + $this->cartMinPrice = $cartMinPrice; + } + + /** + * @return int + */ + public function getNumberAvailable() + { + return $this->numberAvailable; + } + + /** + * @param int $numberAvailable + * @return void + */ + public function setNumberAvailable($numberAvailable) + { + $this->numberAvailable = $numberAvailable; + } + + /** + * @return int + */ + public function getNumberUsed() + { + return $this->numberUsed; + } + + /** + * @param int $numberUsed + * @return void + */ + public function setNumberUsed($numberUsed) + { + $this->numberUsed = $numberUsed; + } + + /** + * @return boolean + */ + public function getIsCombinable() + { + return $this->isCombinable; + } + + /** + * @param boolean $isCombinable + * @return void + */ + public function setIsCombinable($isCombinable) + { + $this->isCombinable = $isCombinable; + } + + /** + * Gets Is Available + * + * @return bool + */ + public function getIsAvailable() + { + $available = $this->numberAvailable - $this->numberUsed; + + return ($available > 0); + } +} diff --git a/Classes/Domain/Model/Product/FeVariant.php b/Classes/Domain/Model/Product/FeVariant.php new file mode 100644 index 00000000..cc780f0f --- /dev/null +++ b/Classes/Domain/Model/Product/FeVariant.php @@ -0,0 +1,27 @@ + + */ +class FeVariant extends \Extcode\Cart\Domain\Model\Product\AbstractProduct +{ + +} diff --git a/Classes/Domain/Model/Product/Product.php b/Classes/Domain/Model/Product/Product.php new file mode 100644 index 00000000..a550f2ef --- /dev/null +++ b/Classes/Domain/Model/Product/Product.php @@ -0,0 +1,1001 @@ + + */ +class Product extends \Extcode\Cart\Domain\Model\Product\AbstractProduct +{ + + /** + * Measurement Units + * + * @var array + */ + protected $measureUnits = [ + 'weight' => [ + 'mg' => 1000, + 'g' => 1, + 'kg' => 0.001, + ], + 'volume' => [ + 'ml' => 1000, + 'cl' => 100, + 'l' => 1, + 'cbm' => 0.001, + ], + 'length' => [ + 'mm' => 1000, + 'cm' => 100, + 'm' => 1, + 'km' => 0.001, + ], + 'area' => [ + 'm2' => 1, + ] + ]; + + /** + * Images + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> + */ + protected $images; + + /** + * Files + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> + */ + protected $files; + + /** + * Teaser + * + * @var string + */ + protected $teaser = ''; + + /** + * Product Content + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\TtContent> + * @lazy + */ + protected $productContent; + + /** + * Min Number In Order + * + * @var integer + */ + protected $minNumberInOrder = 0; + + /** + * Max Number in Order + * + * @var integer + */ + protected $maxNumberInOrder = 0; + + /** + * Price + * + * @var float + */ + protected $price = 0.0; + + /** + * Product Special Price + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\SpecialPrice> + * @cascade remove + */ + protected $specialPrices; + + /** + * Price Measure + * + * @var float + */ + protected $priceMeasure = 0.0; + + /** + * Price Measure Unit + * + * @var string + */ + protected $priceMeasureUnit = ''; + + /** + * Base Price Measure Unit + * + * @var string + */ + protected $basePriceMeasureUnit = ''; + + /** + * Tax Class Id + * + * @var integer + */ + protected $taxClassId = 1; + + /** + * beVariantAttribute1 + * + * @var \Extcode\Cart\Domain\Model\Product\BeVariantAttribute + */ + protected $beVariantAttribute1 = null; + + /** + * beVariantAttribute2 + * + * @var \Extcode\Cart\Domain\Model\Product\BeVariantAttribute + */ + protected $beVariantAttribute2 = null; + + /** + * beVariantAttribute3 + * + * @var \Extcode\Cart\Domain\Model\Product\BeVariantAttribute + */ + protected $beVariantAttribute3 = null; + + /** + * variants + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\BeVariant> + * @cascade remove + */ + protected $beVariants = null; + + /** + * Frontend Variants + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\FeVariant> + * @cascade remove + */ + protected $feVariants = null; + + /** + * Related Products + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\Product> + * @lazy + */ + protected $relatedProducts = null; + + /** + * Related Products (from) + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\Product> + * @lazy + */ + protected $relatedProductsFrom; + + /** + * stock + * + * @var int + */ + protected $stock = 0; + + /** + * Handle Stock + * + * @var bool + */ + protected $handleStock = false; + + /** + * Categories + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category> + */ + protected $categories = null; + + /** + * Product constructor. + * + */ + public function __construct() + { + $this->specialPrices = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $this->beVariants = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + } + + /** + * Returns the Images + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $images + */ + public function getImages() + { + return $this->images; + } + + /** + * Returns the first Image + * + * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $image + */ + public function getFirstImage() + { + return array_shift($this->getImages()->toArray()); + } + + /** + * Sets the Images + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $images + * @return void + */ + public function setImages($images) + { + $this->images = $images; + } + + /** + * Returns the Files + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $files + */ + public function getFiles() + { + return $this->files; + } + + /** + * Sets the Files + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $files + * @return void + */ + public function setFiles($files) + { + $this->files = $files; + } + + /** + * Returns the teaser + * + * @return string $teaser + */ + public function getTeaser() + { + return $this->teaser; + } + + /** + * Sets the teaser + * + * @param string $teaser + * @return void + */ + public function setTeaser($teaser) + { + $this->teaser = $teaser; + } + + /** + * Returns the Product Content + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage + */ + public function getProductContent() + { + return $this->productContent; + } + + /** + * Sets the Product Content + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $productContent + * @return void + */ + public function setProductContent($productContent) + { + $this->productContent = $productContent; + } + + /** + * @return int + */ + public function getMinNumberInOrder() + { + return $this->minNumberInOrder; + } + + /** + * @param int $minNumberInOrder + * + * @return void + */ + public function setMinNumberInOrder($minNumberInOrder) + { + if ($minNumberInOrder < 0 || $minNumberInOrder > $this->maxNumberInOrder) { + throw new \InvalidArgumentException; + } + + $this->minNumberInOrder = $minNumberInOrder; + } + + /** + * @return int + */ + public function getMaxNumberInOrder() + { + return $this->maxNumberInOrder; + } + + /** + * @param int $maxNumberInOrder + * + * @return void + */ + public function setMaxNumberInOrder($maxNumberInOrder) + { + if ($maxNumberInOrder < 0 || (($maxNumberInOrder != 0) && ($maxNumberInOrder < $this->minNumberInOrder))) { + throw new \InvalidArgumentException; + } + + $this->maxNumberInOrder = $maxNumberInOrder; + } + + /** + * Returns the price + * + * @return float $price + */ + public function getPrice() + { + return $this->price; + } + + /** + * Sets the price + * + * @param float $price + * @return void + */ + public function setPrice($price) + { + $this->price = $price; + } + + /** + * Adds a Special Price + * + * @param \Extcode\Cart\Domain\Model\Product\SpecialPrice $specialPrice + * @return void + */ + public function addSpecialPrice(\Extcode\Cart\Domain\Model\Product\SpecialPrice $specialPrice) + { + $this->specialPrices->attach($specialPrice); + } + + /** + * Removes a Special Price + * + * @param \Extcode\Cart\Domain\Model\Product\SpecialPrice $specialPriceToRemove + * @return void + */ + public function removeSpecialPrice(\Extcode\Cart\Domain\Model\Product\SpecialPrice $specialPriceToRemove) + { + $this->specialPrices->detach($specialPriceToRemove); + } + + /** + * Returns the Special Prices + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\specialPrice> + */ + public function getSpecialPrices() + { + return $this->specialPrices; + } + + /** + * Sets the Special Prices + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $specialPrices + */ + public function setSpecialPrices(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $specialPrices) + { + $this->specialPrices = $specialPrices; + } + + /** + * Returns best Special Price + * + * @return float + */ + public function getBestSpecialPrice() + { + $bestSpecialPrice = $this->price; + + if ($this->specialPrices) { + foreach ($this->specialPrices as $specialPrice) { + if ($specialPrice->getPrice() < $bestSpecialPrice) { + $bestSpecialPrice = $specialPrice->getPrice(); + } + } + } + + return $bestSpecialPrice; + } + + /** + * Returns best Special Price Discount + * + * @return float + */ + public function getBestSpecialPriceDiscount() + { + $bestSpecialPrice = $this->getBestSpecialPrice(); + $bestSpecialPriceDiscount = $this->price - $bestSpecialPrice; + + return $bestSpecialPriceDiscount; + } + + /** + * Returns best Special Price Percentage Discount + * + * @return float + */ + public function getBestSpecialPricePercentageDiscount() + { + $estSpecialPricePercentageDiscount = (($this->getBestSpecialPriceDiscount()) / $this->price) * 100; + + return $estSpecialPricePercentageDiscount; + } + + /** + * Returns the Price Measure + * + * @return float $priceMeasure + */ + public function getPriceMeasure() + { + return $this->priceMeasure; + } + + /** + * Sets the Price Measure + * + * @param float $priceMeasure + * @return void + */ + public function setPriceMeasure($priceMeasure) + { + $this->priceMeasure = $priceMeasure; + } + + /** + * Returns the Price Measure Unit + * + * @return string $priceMeasureUnit + */ + public function getPriceMeasureUnit() + { + return $this->priceMeasureUnit; + } + + /** + * Sets the Price Measure Unit + * + * @param string $priceMeasureUnit + * @return void + */ + public function setPriceMeasureUnit($priceMeasureUnit) + { + $this->priceMeasureUnit = $priceMeasureUnit; + } + + /** + * Returns the Base Price Measure Unit + * + * @return string $basePriceMeasureUnit + */ + public function getBasePriceMeasureUnit() + { + return $this->basePriceMeasureUnit; + } + + /** + * Sets the Basse Price Measure Unit + * + * @param string $basePriceMeasureUnit + * + * @return void + */ + public function setBasePriceMeasureUnit($basePriceMeasureUnit) + { + $this->basePriceMeasureUnit = $basePriceMeasureUnit; + } + + /** + * Check Measure Unit Compatibility + * + * @return bool + */ + public function getIsMeasureUnitCompatibility() + { + foreach ($this->measureUnits as $measureUnit) { + if (array_key_exists($this->basePriceMeasureUnit, $measureUnit) + && array_key_exists($this->priceMeasureUnit, $measureUnit) + ) { + return true; + } + } + + return false; + } + + /** + * Get Measure Unit Faktor + * + * @return float + */ + public function getMeasureUnitFactor() + { + $factor = 1.0; + + foreach ($this->measureUnits as $measureUnit) { + if ($measureUnit[$this->priceMeasureUnit]) { + $factor = $factor / ($this->priceMeasure / $measureUnit[$this->priceMeasureUnit]); + } + if ($measureUnit[$this->basePriceMeasureUnit]) { + $factor = $factor * (1.0 / $measureUnit[$this->basePriceMeasureUnit]); + } + } + + return $factor; + } + + /** + * Returns Calculated Base Price + * + * @return float|bool + */ + public function getCalculatedBasePrice() + { + if ($this->getIsMeasureUnitCompatibility()) { + return $this->getMinPrice() * $this->getMeasureUnitFactor(); + } + + return false; + } + + /** + * Returns Tax Class Id + * + * @return integer + */ + public function getTaxClassId() + { + return $this->taxClassId; + } + + /** + * Sets Tax Class Id + * + * @param integer $taxClassId + * @return void + */ + public function setTaxClassId($taxClassId) + { + $this->taxClassId = $taxClassId; + } + + /** + * Returns the Variant Set 1 + * + * @return \Extcode\Cart\Domain\Model\Product\BeVariantAttribute + */ + public function getBeVariantAttribute1() + { + return $this->beVariantAttribute1; + } + + /** + * Sets the Variant Set 1 + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariantAttribute $beVariantAttribute1 + * @return void + */ + public function setBeVariantAttribute1(\Extcode\Cart\Domain\Model\Product\BeVariantAttribute $beVariantAttribute1) + { + $this->beVariantAttribute1 = $beVariantAttribute1; + } + + /** + * Returns the Variant Set 2 + * + * @return \Extcode\Cart\Domain\Model\Product\BeVariantAttribute + */ + public function getBeVariantAttribute2() + { + return $this->beVariantAttribute2; + } + + /** + * Sets the Variant Set 2 + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariantAttribute $beVariantAttribute2 + * @return void + */ + public function setBeVariantAttribute2(\Extcode\Cart\Domain\Model\Product\BeVariantAttribute $beVariantAttribute2) + { + $this->beVariantAttribute2 = $beVariantAttribute2; + } + + /** + * Returns the Variant Set 3 + * + * @return \Extcode\Cart\Domain\Model\Product\BeVariantAttribute + */ + public function getBeVariantAttribute3() + { + return $this->beVariantAttribute3; + } + + /** + * Sets the Variant Set 3 + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariantAttribute $beVariantAttribute3 + * @return void + */ + public function setBeVariantAttribute3(\Extcode\Cart\Domain\Model\Product\BeVariantAttribute $beVariantAttribute3) + { + $this->beVariantAttribute3 = $beVariantAttribute3; + } + + /** + * Adds a Variant + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariant $variant + * @return void + */ + public function addBeVariant(\Extcode\Cart\Domain\Model\Product\BeVariant $variant) + { + $this->beVariants->attach($variant); + } + + /** + * Removes a Variant + * + * @param \Extcode\Cart\Domain\Model\Product\BeVariant $variantToRemove + * @return void + */ + public function removeBeVariant(\Extcode\Cart\Domain\Model\Product\BeVariant $variantToRemove) + { + $this->beVariants->detach($variantToRemove); + } + + /** + * Returns the Variants + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\BeVariant> $variant + */ + public function getBeVariants() + { + return $this->beVariants; + } + + /** + * Sets the Variants + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $variants + */ + public function setBeVariants(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $variants) + { + $this->beVariants = $variants; + } + + /** + * Adds a Frontend Variant + * + * @param \Extcode\Cart\Domain\Model\Product\FeVariant $feVariant + * @return void + */ + public function addFeVariant(\Extcode\Cart\Domain\Model\Product\FeVariant $feVariant) + { + $this->feVariants->attach($feVariant); + } + + /** + * Removes a Frontend Variant + * + * @param \Extcode\Cart\Domain\Model\Product\FeVariant $feVariantToRemove + * @return void + */ + public function removeFeVariant(\Extcode\Cart\Domain\Model\Product\FeVariant $feVariantToRemove) + { + $this->feVariants->detach($feVariantToRemove); + } + + /** + * Returns the Frontend Variants + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\FeVariant> $variant + */ + public function getFeVariants() + { + return $this->feVariants; + } + + /** + * Sets the Frontend Variants + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $feVariants + */ + public function setFeVariants(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $feVariants) + { + $this->feVariants = $feVariants; + } + + /** + * Adds a Related Product + * + * @param \Extcode\Cart\Domain\Model\Product\Product $relatedProduct + * @return void + */ + public function addRelatedProduct(\Extcode\Cart\Domain\Model\Product\Product $relatedProduct) + { + $this->relatedProducts->attach($relatedProduct); + } + + /** + * Removes a Related Product + * + * @param \Extcode\Cart\Domain\Model\Product\Product $relatedProductToRemove + * @return void + */ + public function removeRelatedProduct(\Extcode\Cart\Domain\Model\Product\Product $relatedProductToRemove) + { + $this->relatedProducts->detach($relatedProductToRemove); + } + + /** + * Returns the Related Products + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\Product> $relatedProduct + */ + public function getRelatedProducts() + { + return $this->relatedProducts; + } + + /** + * Sets the Related Products + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\Product> $relatedProducts + */ + public function setRelatedProducts(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $relatedProducts) + { + $this->relatedProducts = $relatedProducts; + } + + /** + * Adds a Related Product (from) + * + * @param \Extcode\Cart\Domain\Model\Product\Product $relatedProductFrom + * @return void + */ + public function addRelatedProductFrom(\Extcode\Cart\Domain\Model\Product\Product $relatedProductFrom) + { + $this->relatedProductsFrom->attach($relatedProductFrom); + } + + /** + * Removes a Related Product (from) + * + * @param \Extcode\Cart\Domain\Model\Product\Product $relatedProductFromToRemove + * @return void + */ + public function removeRelatedProductFrom(\Extcode\Cart\Domain\Model\Product\Product $relatedProductFromToRemove) + { + $this->relatedProductsFrom->detach($relatedProductFromToRemove); + } + + /** + * Returns the Related Products (from) + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\Product> $relatedProductFrom + */ + public function getRelatedProductsFrom() + { + return $this->relatedProductsFrom; + } + + /** + * Sets the Related Products (from) + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Extcode\Cart\Domain\Model\Product\Product> $relatedProductsFrom + */ + public function setRelatedProductsFrom(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $relatedProductsFrom) + { + $this->relatedProductsFrom = $relatedProductsFrom; + } + + /** + * Returns the Stock + * + * @return int + */ + public function getStock() + { + if (count($this->beVariants)) { + $count = 0; + + foreach ($this->beVariants as $variant) { + $count += $variant->getStock(); + } + + return $count; + } + return $this->stock; + } + + /** + * Set the Stock + * + * @param int $stock + */ + public function setStock($stock) + { + $this->stock = $stock; + } + + /** + * Add To Stock + * + * @param int $numberOfProducts + */ + public function addToStock($numberOfProducts) + { + if ($this->handleStock()) { + $this->stock += $numberOfProducts; + } + } + + /** + * Remove From Stock + * + * @param int $numberOfProducts + */ + public function removeFromStock($numberOfProducts) + { + if ($this->handleStock()) { + $this->stock -= $numberOfProducts; + } + } + + /** + * @return bool + */ + public function handleStock() + { + return $this->handleStock; + } + + /** + * Sets Handle Stock + * + * @param bool $handleStock + * @return void + */ + public function setHandleStock($handleStock) + { + $this->handleStock = $handleStock; + } + + /** + * Adds a Product Category + * + * @param \TYPO3\CMS\Extbase\Domain\Model\Category $productCategory + * @return void + */ + public function addProductCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category) + { + $this->categories->attach($category); + } + + /** + * Removes a Category + * + * @param \TYPO3\CMS\Extbase\Domain\Model\Category $categoryToRemove + * @return void + */ + public function removeProductCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $categoryToRemove) + { + $this->categories->detach($categoryToRemove); + } + + /** + * Returns the categories + * + * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category> $categories + */ + public function getProductCategories() + { + return $this->categories; + } + + /** + * Sets the categories + * + * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category> $categories + */ + public function setProductCategories(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $categories) + { + $this->categories = $categories; + } + + /** + * get the minimal Price from Variants + * + * @return float + */ + public function getMinPrice() + { + $minPrice = null; + if (count($this->getBeVariants())) { + foreach ($this->getBeVariants() as $variant) { + if (!isset($minPrice)) { + $minPrice = $variant->getPriceCalculated(); + } else { + if ($variant->getPriceCalculated() < $minPrice) { + $minPrice = $variant->getPriceCalculated(); + } + } + } + } else { + $minPrice = $this->getPrice(); + } + + return $minPrice; + } + + /** + * Returns MeasureUnits + * + * @return array + */ + public function getMeasureUnits() + { + return $this->measureUnits; + } + + /** + * Sets MeasureUnits + * + * @param array $measureUnits + * + * @return void + */ + public function setMeasureUnits($measureUnits) + { + $this->measureUnits = $measureUnits; + } + +} diff --git a/Classes/Domain/Model/Product/SpecialPrice.php b/Classes/Domain/Model/Product/SpecialPrice.php new file mode 100644 index 00000000..545555b0 --- /dev/null +++ b/Classes/Domain/Model/Product/SpecialPrice.php @@ -0,0 +1,54 @@ + + */ +class SpecialPrice extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + /** + * Price + * + * @var float + * @validate NotEmpty + */ + protected $price = 0.0; + + /** + * Returns the Price + * + * @return float $price + */ + public function getPrice() + { + return $this->price; + } + + /** + * Sets the Price + * + * @param float $price + * @return void + */ + public function setPrice($price) + { + $this->price = $price; + } +} diff --git a/Classes/Domain/Model/TtContent.php b/Classes/Domain/Model/TtContent.php new file mode 100644 index 00000000..64fa1810 --- /dev/null +++ b/Classes/Domain/Model/TtContent.php @@ -0,0 +1,1503 @@ + + */ +class TtContent extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity +{ + + /** + * @var \DateTime + */ + protected $crdate; + + /** + * @var \DateTime + */ + protected $tstamp; + + /** + * @var string + */ + protected $contentType; + + /** + * @var string + */ + protected $header; + + /** + * @var string + */ + protected $headerPosition; + + /** + * @var string + */ + protected $bodytext; + + /** + * @var integer + */ + protected $colPos; + + /** + * @var string + */ + protected $image; + + /** + * @var integer + */ + protected $imagewidth; + + /** + * @var integer + */ + protected $imageheight; + + /** + * @var integer + */ + protected $imageorient; + + /** + * @var string + */ + protected $imagecaption; + + /** + * @var integer + */ + protected $imagecols; + + /** + * @var integer + */ + protected $imageborder; + + /** + * @var string + */ + protected $media; + + /** + * @var string + */ + protected $layout; + + /** + * @var integer + */ + protected $cols; + + /** + * @var string + */ + protected $subheader; + + /** + * @var string + */ + protected $headerLink; + + /** + * @var string + */ + protected $imageLink; + + /** + * @var string + */ + protected $imageZoom; + + /** + * @var string + */ + protected $altText; + + /** + * @var string + */ + protected $titleText; + + /** + * @var string + */ + protected $headerLayout; + + /** + * @var string + */ + protected $listType; + + /** + * @var string + */ + protected $records; + + /** + * @var string + */ + protected $pages; + + /** + * @var string + */ + protected $feGroup; + + /** + * @var string + */ + protected $imagecaptionPosition; + + /** + * @var string + */ + protected $longdescUrl; + + /** + * @var string + */ + protected $menuType; + + /** + * @var string + */ + protected $selectKey; + + /** + * @var string + */ + protected $fileCollections; + + /** + * @var string + */ + protected $filelinkSorting; + + /** + * @var string + */ + protected $target; + + /** + * @var string + */ + protected $multimedia; + + /** + * @var string + */ + protected $piFlexform; + + /** + * @var string + */ + protected $accessibilityTitle; + + /** + * @var string + */ + protected $accessibilityBypassText; + + /** + * @var string + */ + protected $selectedCategories; + + /** + * @var string + */ + protected $categoryField; + + /** + * @var integer + */ + protected $spaceBefore; + + /** + * @var integer + */ + protected $spaceAfter; + + /** + * @var integer + */ + protected $imageNoRows; + + /** + * @var integer + */ + protected $imageEffects; + + /** + * @var integer + */ + protected $imageCompression; + + /** + * @var integer + */ + protected $tableBorder; + + /** + * @var integer + */ + protected $tableCellspacing; + + /** + * @var integer + */ + protected $tableCellpadding; + + /** + * @var integer + */ + protected $tableBgColor; + + /** + * @var integer + */ + protected $sectionIndex; + + /** + * @var integer + */ + protected $linkToTop; + + /** + * @var integer + */ + protected $filelinkSize; + + /** + * @var integer + */ + protected $sectionFrame; + + /** + * @var integer + */ + protected $date; + + /** + * @var integer + */ + protected $imageFrames; + + /** + * @var integer + */ + protected $recursive; + + /** + * @var integer + */ + protected $rteEnabled; + + /** + * @var integer + */ + protected $txImpexpOriguid; + + /** + * @var integer + */ + protected $accessibilityBypass; + + /** + * @var integer + */ + protected $sysLanguageUid; + + /** + * @var integer + */ + protected $starttime; + + /** + * @var integer + */ + protected $endtime; + + /** + * @var string + */ + protected $txGridelementsBackendLayout; + + /** + * @var integer + */ + protected $txGridelementsChildren; + + /** + * @var integer + */ + protected $txGridelementsContainer; + + /** + * @var integer + */ + protected $txGridelementsColumns; + + /** + * @return DateTime + */ + public function getCrdate() + { + return $this->crdate; + } + + /** + * @param $crdate + * @return void + */ + public function setCrdate($crdate) + { + $this->crdate = $crdate; + } + + /** + * @return DateTime + */ + public function getTstamp() + { + return $this->tstamp; + } + + /** + * @param $tstamp + * @return void + */ + public function setTstamp($tstamp) + { + $this->tstamp = $tstamp; + } + + /** + * @return string + */ + public function getContentType() + { + return $this->contentType; + } + + /** + * @param $contentType + * @return void + */ + public function setContentType($contentType) + { + $this->contentType = $contentType; + } + + /** + * @return string + */ + public function getHeader() + { + return $this->header; + } + + /** + * @param $header + * @return void + */ + public function setHeader($header) + { + $this->header = $header; + } + + /** + * @return string + */ + public function getHeaderPosition() + { + return $this->headerPosition; + } + + /** + * @param $headerPosition + * @return void + */ + public function setHeaderPosition($headerPosition) + { + $this->headerPosition = $headerPosition; + } + + /** + * @return string + */ + public function getBodytext() + { + return $this->bodytext; + } + + /** + * @param $bodytext + * @return void + */ + public function setBodytext($bodytext) + { + $this->bodytext = $bodytext; + } + + /** + * Get the colpos + * + * @return integer + */ + public function getColPos() + { + return (int)$this->colPos; + } + + /** + * Set colpos + * + * @param integer $colPos + * @return void + */ + public function setColPos($colPos) + { + $this->colPos = $colPos; + } + + /** + * @return string + */ + public function getImage() + { + return $this->image; + } + + /** + * @param $image + * @return void + */ + public function setImage($image) + { + $this->image = $image; + } + + /** + * @return int + */ + public function getImagewidth() + { + return $this->imagewidth; + } + + /** + * @param $imagewidth + * @return void + */ + public function setImagewidth($imagewidth) + { + $this->imagewidth = $imagewidth; + } + + /** + * @return int + */ + public function getImageheight() + { + return $this->imageheight; + } + + /** + * @param $imageheight + * @return void + */ + public function setImageheight($imageheight) + { + $this->imageheight = $imageheight; + } + + /** + * @return int + */ + public function getImageorient() + { + return $this->imageorient; + } + + /** + * @param $imageorient + * @return void + */ + public function setImageorient($imageorient) + { + $this->imageorient = $imageorient; + } + + /** + * @return string + */ + public function getImagecaption() + { + return $this->imagecaption; + } + + /** + * @param $imagecaption + * @return void + */ + public function setImagecaption($imagecaption) + { + $this->imagecaption = $imagecaption; + } + + /** + * @return int + */ + public function getImagecols() + { + return $this->imagecols; + } + + /** + * @param $imagecols + * @return void + */ + public function setImagecols($imagecols) + { + $this->imagecols = $imagecols; + } + + /** + * @return int + */ + public function getImageborder() + { + return $this->imageborder; + } + + /** + * @param $imageborder + * @return void + */ + public function setImageborder($imageborder) + { + $this->imageborder = $imageborder; + } + + /** + * @return string + */ + public function getMedia() + { + return $this->media; + } + + /** + * @param $media + * @return void + */ + public function setMedia($media) + { + $this->media = $media; + } + + /** + * @return string + */ + public function getLayout() + { + return $this->layout; + } + + /** + * @param $layout + * @return void + */ + public function setLayout($layout) + { + $this->layout = $layout; + } + + /** + * @return int + */ + public function getCols() + { + return $this->cols; + } + + /** + * @param $cols + * @return void + */ + public function setCols($cols) + { + $this->cols = $cols; + } + + /** + * @return string + */ + public function getSubheader() + { + return $this->subheader; + } + + /** + * @param $subheader + * @return void + */ + public function setSubheader($subheader) + { + $this->subheader = $subheader; + } + + /** + * @return string + */ + public function getHeaderLink() + { + return $this->headerLink; + } + + /** + * @param $headerLink + * @return void + */ + public function setHeaderLink($headerLink) + { + $this->headerLink = $headerLink; + } + + /** + * @return string + */ + public function getImageLink() + { + return $this->imageLink; + } + + /** + * @param $imageLink + * @return void + */ + public function setImageLink($imageLink) + { + $this->imageLink = $imageLink; + } + + /** + * @return string + */ + public function getImageZoom() + { + return $this->imageZoom; + } + + /** + * @param $imageZoom + * @return void + */ + public function setImageZoom($imageZoom) + { + $this->imageZoom = $imageZoom; + } + + /** + * @return string + */ + public function getAltText() + { + return $this->altText; + } + + /** + * @param $altText + * @return void + */ + public function setAltText($altText) + { + $this->altText = $altText; + } + + /** + * @return string + */ + public function getTitleText() + { + return $this->titleText; + } + + /** + * @param $titleText + * @return void + */ + public function setTitleText($titleText) + { + $this->titleText = $titleText; + } + + /** + * @return string + */ + public function getHeaderLayout() + { + return $this->headerLayout; + } + + /** + * @param $headerLayout + * @return void + */ + public function setHeaderLayout($headerLayout) + { + $this->headerLayout = $headerLayout; + } + + /** + * @return string + */ + public function getListType() + { + return $this->listType; + } + + /** + * @param string $listType + * @return void + */ + public function setListType($listType) + { + $this->listType = $listType; + } + + /** + * @return string + */ + public function getRecords() + { + return $this->records; + } + + /** + * @param $records + * @return void + */ + public function setRecords($records) + { + $this->records = $records; + } + + /** + * @return string + */ + public function getPages() + { + return $this->pages; + } + + /** + * @param $pages + * @return void + */ + public function setPages($pages) + { + $this->pages = $pages; + } + + /** + * @return string + */ + public function getFeGroup() + { + return $this->feGroup; + } + + /** + * @param $feGroup + * @return void + */ + public function setFeGroup($feGroup) + { + $this->feGroup = $feGroup; + } + + /** + * @return string + */ + public function getImagecaptionPosition() + { + return $this->imagecaptionPosition; + } + + /** + * @param $imagecaptionPosition + * @return void + */ + public function setImagecaptionPosition($imagecaptionPosition) + { + $this->imagecaptionPosition = $imagecaptionPosition; + } + + /** + * @return string + */ + public function getLongdescUrl() + { + return $this->longdescUrl; + } + + /** + * @param $longdescUrl + * @return void + */ + public function setLongdescUrl($longdescUrl) + { + $this->longdescUrl = $longdescUrl; + } + + /** + * @return string + */ + public function getMenuType() + { + return $this->menuType; + } + + /** + * @param $menuType + * @return void + */ + public function setMenuType($menuType) + { + $this->menuType = $menuType; + } + + /** + * @return string + */ + public function getSelectKey() + { + return $this->selectKey; + } + + /** + * @param $selectKey + * @return void + */ + public function setSelectKey($selectKey) + { + $this->selectKey = $selectKey; + } + + /** + * @return string + */ + public function getFileCollections() + { + return $this->fileCollections; + } + + /** + * @param $fileCollections + * @return void + */ + public function setFileCollections($fileCollections) + { + $this->fileCollections = $fileCollections; + } + + /** + * @return string + */ + public function getFilelinkSorting() + { + return $this->filelinkSorting; + } + + /** + * @param $filelinkSorting + * @return void + */ + public function setFilelinkSorting($filelinkSorting) + { + $this->filelinkSorting = $filelinkSorting; + } + + /** + * @return string + */ + public function getTarget() + { + return $this->target; + } + + /** + * @param $target + * @return void + */ + public function setTarget($target) + { + $this->target = $target; + } + + /** + * @return string + */ + public function getMultimedia() + { + return $this->multimedia; + } + + /** + * @param $multimedia + * @return void + */ + public function setMultimedia($multimedia) + { + $this->multimedia = $multimedia; + } + + /** + * @return string + */ + public function getPiFlexform() + { + return $this->piFlexform; + } + + /** + * @param $piFlexform + * @return void + */ + public function setPiFlexform($piFlexform) + { + $this->piFlexform = $piFlexform; + } + + /** + * @return string + */ + public function getAccessibilityTitle() + { + return $this->accessibilityTitle; + } + + /** + * @param $accessibilityTitle + * @return void + */ + public function setAccessibilityTitle($accessibilityTitle) + { + $this->accessibilityTitle = $accessibilityTitle; + } + + /** + * @return string + */ + public function getAccessibilityBypassText() + { + return $this->accessibilityBypassText; + } + + /** + * @param $accessibilityBypassText + * @return void + */ + public function setAccessibilityBypassText($accessibilityBypassText) + { + $this->accessibilityBypassText = $accessibilityBypassText; + } + + /**string + * @return string + */ + public function getSelectedCategories() + { + return $this->selectedCategories; + } + + /** + * @param $selectedCategories + * @return void + */ + public function setSelectedCategories($selectedCategories) + { + $this->selectedCategories = $selectedCategories; + } + + /** + * @return string + */ + public function getCategoryField() + { + return $this->categoryField; + } + + /** + * @param $categoryField + * @return void + */ + public function setCategoryField($categoryField) + { + $this->categoryField = $categoryField; + } + + /** + * @return integer + */ + public function getSpaceBefore() + { + return $this->spaceBefore; + } + + /** + * @param $spaceBefore + * @return void + */ + public function setSpaceBefore($spaceBefore) + { + $this->spaceBefore = $spaceBefore; + } + + /** + * @return integer + */ + public function getSpaceAfter() + { + return $this->spaceAfter; + } + + /** + * @param $spaceAfter + * @return void + */ + public function setSpaceAfter($spaceAfter) + { + $this->spaceAfter = $spaceAfter; + } + + /** + * @return integer + */ + public function getImageNoRows() + { + return $this->imageNoRows; + } + + /** + * @param $imageNoRows + * @return void + */ + public function setImageNoRows($imageNoRows) + { + $this->imageNoRows = $imageNoRows; + } + + /** + * @return integer + */ + public function getImageEffects() + { + return $this->imageEffects; + } + + /** + * @param $imageEffects + * @return void + */ + public function setImageEffects($imageEffects) + { + $this->imageEffects = $imageEffects; + } + + /** + * @return integer + */ + public function getImageCompression() + { + return $this->imageCompression; + } + + /** + * @param $imageCompression + * @return void + */ + public function setImageCompression($imageCompression) + { + $this->imageCompression = $imageCompression; + } + + /** + * @return integer + */ + public function getTableBorder() + { + return $this->tableBorder; + } + + /** + * @param $tableBorder + * @return void + */ + public function setTableBorder($tableBorder) + { + $this->tableBorder = $tableBorder; + } + + /** + * @return integer + */ + public function getTableCellspacing() + { + return $this->tableCellspacing; + } + + /** + * @param $tableCellspacing + * @return void + */ + public function setTableCellspacing($tableCellspacing) + { + $this->tableCellspacing = $tableCellspacing; + } + + /** + * @return integer + */ + public function getTableCellpadding() + { + return $this->tableCellpadding; + } + + /** + * @param $tableCellpadding + * @return void + */ + public function setTableCellpadding($tableCellpadding) + { + $this->tableCellpadding = $tableCellpadding; + } + + /** + * @return integer + */ + public function getTableBgColor() + { + return $this->tableBgColor; + } + + /** + * @param $tableBgColor + * @return void + */ + public function setTableBgColor($tableBgColor) + { + $this->tableBgColor = $tableBgColor; + } + + /** + * @return integer + */ + public function getSectionIndex() + { + return $this->sectionIndex; + } + + /** + * @param $sectionIndex + * @return void + */ + public function setSectionIndex($sectionIndex) + { + $this->sectionIndex = $sectionIndex; + } + + /** + * @return integer + */ + public function getLinkToTop() + { + return $this->linkToTop; + } + + /** + * @param $linkToTop + * @return void + */ + public function setLinkToTop($linkToTop) + { + $this->linkToTop = $linkToTop; + } + + /** + * @return integer + */ + public function getFilelinkSize() + { + return $this->filelinkSize; + } + + /** + * @param $filelinkSize + * @return void + */ + public function setFilelinkSize($filelinkSize) + { + $this->filelinkSize = $filelinkSize; + } + + /** + * @return integer + */ + public function getSectionFrame() + { + return $this->sectionFrame; + } + + /** + * @param $sectionFrame + * @return void + */ + public function setSectionFrame($sectionFrame) + { + $this->sectionFrame = $sectionFrame; + } + + /** + * @return integer + */ + public function getDate() + { + return $this->date; + } + + /** + * @param $date + * @return void + */ + public function setDate($date) + { + $this->date = $date; + } + + /** + * @return integer + */ + public function getImageFrames() + { + return $this->imageFrames; + } + + /** + * @param $imageFrames + * @return void + */ + public function setImageFrames($imageFrames) + { + $this->imageFrames = $imageFrames; + } + + /** + * @return integer + */ + public function getRecursive() + { + return $this->recursive; + } + + /** + * @param $recursive + * @return void + */ + public function setRecursive($recursive) + { + $this->recursive = $recursive; + } + + /** + * @return integer + */ + public function getRteEnabled() + { + return $this->rteEnabled; + } + + /** + * @param $rteEnabled + * @return void + */ + public function setRteEnabled($rteEnabled) + { + $this->rteEnabled = $rteEnabled; + } + + /** + * @return integer + */ + public function getTxImpexpOriguid() + { + return $this->txImpexpOriguid; + } + + /** + * @param $txImpexpOriguid + * @return void + */ + public function setTxImpexpOriguid($txImpexpOriguid) + { + $this->txImpexpOriguid = $txImpexpOriguid; + } + + /** + * @return integer + */ + public function getAccessibilityBypass() + { + return $this->accessibilityBypass; + } + + /** + * @param $accessibilityBypass + * @return void + */ + public function setAccessibilityBypass($accessibilityBypass) + { + $this->accessibilityBypass = $accessibilityBypass; + } + + /** + * @return integer + */ + public function getSysLanguageUid() + { + return $this->sysLanguageUid; + } + + /** + * @param $sysLanguageUid + * @return void + */ + public function setSysLanguageUid($sysLanguageUid) + { + $this->sysLanguageUid = $sysLanguageUid; + } + + /** + * @return integer + */ + public function getStarttime() + { + return $this->starttime; + } + + /** + * @param $starttime + * @return void + */ + public function setStarttime($starttime) + { + $this->starttime = $starttime; + } + + /** + * @return integer + */ + public function getEndtime() + { + return $this->endtime; + } + + /** + * @param $endtime + * @return void + */ + public function setEndtime($endtime) + { + $this->endtime = $endtime; + } + + /** + * @return string + */ + public function getTxGridelementsBackendLayout() + { + return $this->txGridelementsBackendLayout; + } + + /** + * @param $txGridelementsBackendLayout + * @return void + */ + public function setTxGridelementsBackendLayout($txGridelementsBackendLayout) + { + $this->txGridelementsBackendLayout = $txGridelementsBackendLayout; + } + + /** + * @return integer + */ + public function getTxGridelementsChildren() + { + return $this->txGridelementsChildren; + } + + /** + * @param $txGridelementsChildren + * @return void + */ + public function setTxGridelementsChildren($txGridelementsChildren) + { + $this->txGridelementsChildren = $txGridelementsChildren; + } + + /** + * @return integer + */ + public function getTxGridelementsContainer() + { + return $this->txGridelementsContainer; + } + + /** + * @param $txGridelementsContainer + * @return void + */ + public function setTxGridelementsContainer($txGridelementsContainer) + { + $this->txGridelementsContainer = $txGridelementsContainer; + } + + /** + * @return integer + */ + public function getTxGridelementsColumns() + { + return $this->txGridelementsColumns; + } + + /** + * @param $txGridelementsColumns + * @return void + */ + public function setTxGridelementsColumns($txGridelementsColumns) + { + $this->txGridelementsColumns = $txGridelementsColumns; + } +} diff --git a/Classes/Domain/Repository/CartRepository.php b/Classes/Domain/Repository/CartRepository.php new file mode 100644 index 00000000..0d98fbeb --- /dev/null +++ b/Classes/Domain/Repository/CartRepository.php @@ -0,0 +1,27 @@ + + */ +class CartRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + +} diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php new file mode 100644 index 00000000..65422916 --- /dev/null +++ b/Classes/Domain/Repository/CategoryRepository.php @@ -0,0 +1,129 @@ + + */ +class CategoryRepository extends \TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository +{ + + /** + * findAllAsRecursiveTreeArray + * + * @param \Extcode\Cart\Domain\Model\Category $selectedCategory + * @return array $categories + */ + public function findAllAsRecursiveTreeArray($selectedCategory = null) + { + $categoriesArray = $this->findAllAsArray($selectedCategory); + $categoriesTree = $this->buildSubcategories($categoriesArray, null); + return $categoriesTree; + } + + /** + * findAllAsArray + * + * @param \Extcode\Cart\Domain\Model\Category $selectedCategory + * @return array $categories + */ + public function findAllAsArray($selectedCategory = null) + { + $localCategories = $this->findAll(); + $categories = array(); + // Transform categories to array + foreach ($localCategories as $localCategory) { + $newCategory = array( + 'uid' => $localCategory->getUid(), + 'title' => $localCategory->getTitle(), + 'parent' => + ($localCategory->getParent() ? $localCategory->getParent()->getUid() : null), + 'subcategories' => null, + 'isSelected' => ($selectedCategory == $localCategory ? true : false) + ); + $categories[] = $newCategory; + } + return $categories; + } + + /** + * findSubcategoriesRecursiveAsArray + * + * @param Extcode\Cart\Domain\Model\Category $parentCategory + * @return array $categories + */ + public function findSubcategoriesRecursiveAsArray($parentCategory) + { + $categories = array(); + $localCategories = $this->findAllAsArray(); + foreach ($localCategories as $category) { + if (($parentCategory && $category['uid'] == $parentCategory->getUid()) + || !$parentCategory + ) { + $this->getSubcategoriesIds($localCategories, $category, + $categories); + } + } + return $categories; + } + + /** + * getSubcategoriesIds + * + * @param array $categoriesArray + * @param array $parentCategory + * @param array $subcategoriesArray + * @return void + */ + private function getSubcategoriesIds( + $categoriesArray, + $parentCategory, + &$subcategoriesArray + ) { + $subcategoriesArray[] = $parentCategory['uid']; + foreach ($categoriesArray as $category) { + if ($category['parent'] == $parentCategory['uid']) { + $this->getSubcategoriesIds($categoriesArray, $category, + $subcategoriesArray); + } + } + } + + /** + * buildSubcategories + * + * @param array $categoriesArray + * @param array $parentCategory + * @return array $categories + */ + private function buildSubcategories($categoriesArray, $parentCategory) + { + $categories = null; + foreach ($categoriesArray as $category) { + if ($category['parent'] == $parentCategory['uid']) { + $newCategory = $category; + $newCategory['subcategories'] = + $this->buildSubcategories($categoriesArray, $category); + $categories[] = $newCategory; + } + } + return $categories; + } + +} \ No newline at end of file diff --git a/Classes/Domain/Repository/Order/AddressRepository.php b/Classes/Domain/Repository/Order/AddressRepository.php new file mode 100644 index 00000000..9c83b8db --- /dev/null +++ b/Classes/Domain/Repository/Order/AddressRepository.php @@ -0,0 +1,27 @@ + + */ +class AddressRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + +} diff --git a/Classes/Domain/Repository/Order/CouponRepository.php b/Classes/Domain/Repository/Order/CouponRepository.php new file mode 100644 index 00000000..aaeff0bb --- /dev/null +++ b/Classes/Domain/Repository/Order/CouponRepository.php @@ -0,0 +1,27 @@ + + */ +class CouponRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + +} diff --git a/Classes/Domain/Repository/Order/ItemRepository.php b/Classes/Domain/Repository/Order/ItemRepository.php new file mode 100644 index 00000000..e8591dd1 --- /dev/null +++ b/Classes/Domain/Repository/Order/ItemRepository.php @@ -0,0 +1,124 @@ + + */ +class ItemRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + + protected $defaultOrderings = array( + 'uid' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING + ); + + /** + * Find a order by a given orderNumber + * + * @param string $orderNumber Order Number + * + * @return object + */ + public function findOneByOrderNumber($orderNumber) + { + $query = $this->createQuery(); + + $query->getQuerySettings()->setRespectStoragePage(false); + $query->getQuerySettings()->setIgnoreEnableFields(true); + $query->getQuerySettings()->setIncludeDeleted(true); + $query->getQuerySettings()->setRespectSysLanguage(false); + + $query->matching($query->equals('order_number', $orderNumber)); + $orderItem = $query->execute()->getFirst(); + + return $orderItem; + } + + /** + * Find all orders + * + * @param array $piVars Plugin Variables + * + * @return object + */ + public function findAll(array $piVars = array()) + { + // settings + $query = $this->createQuery(); + + $and = array( + $query->equals('deleted', 0) + ); + + // filter + if (isset($piVars['filter'])) { + foreach ((array)$piVars['filter'] as $field => $value) { + if (empty($value)) { + continue; + } + switch ($field) { + case 'customer': + $or = [ + $query->like('billingAddress.firstName', '%' . $value . '%'), + $query->like('billingAddress.lastName', '%' . $value . '%'), + $query->like('billingAddress.company', '%' . $value . '%') + ]; + + $and[] = $query->logicalOr($or); + break; + case 'orderNumber': + $and[] = $query->like('orderNumber', $value); + break; + case 'orderDateStart': + $and[] = $query->greaterThan('orderDate', strtotime($value)); + break; + case 'orderDateEnd': + $and[] = $query->lessThan('orderDate', strtotime($value)); + break; + case 'invoiceNumber': + $and[] = $query->like('invoiceNumber', $value); + break; + case 'invoiceDateStart': + $and[] = $query->greaterThan('invoiceDate', strtotime($value)); + break; + case 'invoiceDateEnd': + $and[] = $query->lessThan('invoiceDate', strtotime($value)); + break; + case 'paymentStatus': + if ($value != 'all') { + $and[] = $query->equals('payment.status', $value); + } + break; + case 'shippingStatus': + if ($value != 'all') { + $and[] = $query->equals('shipping.status', $value); + } + break; + } + } + } + + // create constraint + $constraint = $query->logicalAnd($and); + $query->matching($constraint); + + $orderItems = $query->execute(); + return $orderItems; + } +} diff --git a/Classes/Domain/Repository/Order/PaymentRepository.php b/Classes/Domain/Repository/Order/PaymentRepository.php new file mode 100644 index 00000000..e35910fe --- /dev/null +++ b/Classes/Domain/Repository/Order/PaymentRepository.php @@ -0,0 +1,27 @@ + + */ +class PaymentRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + +} diff --git a/Classes/Domain/Repository/Order/ProductAdditionalRepository.php b/Classes/Domain/Repository/Order/ProductAdditionalRepository.php new file mode 100644 index 00000000..a414ace8 --- /dev/null +++ b/Classes/Domain/Repository/Order/ProductAdditionalRepository.php @@ -0,0 +1,63 @@ + + */ +class ProductAdditionalRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + + /** + * Count all by Category + * + * @param array $piVars Plugin Variables + * @param string $additionalType + * + * @return object + */ + public function findAllByAdditionalType(array $piVars = array(), $additionalType) + { + // settings + $query = $this->createQuery(); + + $and = array( + $query->equals('deleted', 0), + $query->equals('additionalType', $additionalType) + ); + + // filter + if (isset($piVars['filter'])) { + foreach ((array)$piVars['filter'] as $field => $value) { + if ($field == 'start' && !empty($value)) { + $and[] = $query->greaterThan('crdate', strtotime($value)); + } elseif ($field == 'stop' && !empty($value)) { + $and[] = $query->lessThan('crdate', strtotime($value)); + } + } + } + + // create constraint + $constraint = $query->logicalAnd($and); + $query->matching($constraint); + + $orderProductAdditionals = $query->execute(); + return $orderProductAdditionals; + } +} diff --git a/Classes/Domain/Repository/Order/ProductRepository.php b/Classes/Domain/Repository/Order/ProductRepository.php new file mode 100644 index 00000000..480d7a91 --- /dev/null +++ b/Classes/Domain/Repository/Order/ProductRepository.php @@ -0,0 +1,61 @@ + + */ +class ProductRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + + /** + * Find all products + * + * @param array $piVars Plugin Variables + * + * @return object + */ + public function findAll(array $piVars = array()) + { + // settings + $query = $this->createQuery(); + + $and = array( + $query->equals('deleted', 0) + ); + + // filter + if (isset($piVars['filter'])) { + foreach ((array)$piVars['filter'] as $field => $value) { + if ($field == 'start' && !empty($value)) { + $and[] = $query->greaterThan('crdate', strtotime($value)); + } elseif ($field == 'stop' && !empty($value)) { + $and[] = $query->lessThan('crdate', strtotime($value)); + } + } + } + + // create constraint + $constraint = $query->logicalAnd($and); + $query->matching($constraint); + + $orderItems = $query->execute(); + return $orderItems; + } +} diff --git a/Classes/Domain/Repository/Order/ShippingRepository.php b/Classes/Domain/Repository/Order/ShippingRepository.php new file mode 100644 index 00000000..2219edb8 --- /dev/null +++ b/Classes/Domain/Repository/Order/ShippingRepository.php @@ -0,0 +1,27 @@ + + */ +class ShippingRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + +} diff --git a/Classes/Domain/Repository/Order/TaxClassRepository.php b/Classes/Domain/Repository/Order/TaxClassRepository.php new file mode 100644 index 00000000..4cba447b --- /dev/null +++ b/Classes/Domain/Repository/Order/TaxClassRepository.php @@ -0,0 +1,27 @@ + + */ +class TaxClassRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + +} diff --git a/Classes/Domain/Repository/Order/TaxRepository.php b/Classes/Domain/Repository/Order/TaxRepository.php new file mode 100644 index 00000000..9213f632 --- /dev/null +++ b/Classes/Domain/Repository/Order/TaxRepository.php @@ -0,0 +1,27 @@ + + */ +class TaxRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + +} diff --git a/Classes/Domain/Repository/Order/TransactionRepository.php b/Classes/Domain/Repository/Order/TransactionRepository.php new file mode 100644 index 00000000..9e5b81fb --- /dev/null +++ b/Classes/Domain/Repository/Order/TransactionRepository.php @@ -0,0 +1,27 @@ + + */ +class TransactionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + +} diff --git a/Classes/Domain/Repository/Product/BeVariantAttributeOptionRepository.php b/Classes/Domain/Repository/Product/BeVariantAttributeOptionRepository.php new file mode 100644 index 00000000..c5e040e5 --- /dev/null +++ b/Classes/Domain/Repository/Product/BeVariantAttributeOptionRepository.php @@ -0,0 +1,68 @@ + + */ +class BeVariantAttributeOptionRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + + /** + * Finds objects filtered by $piVars['filter'] + * + * @param array $piVars + * @return Query Object + */ + public function findAll($piVars = array()) + { + // settings + $query = $this->createQuery(); + + $constraints = array(); + + // filter + if (isset($piVars['filter'])) { + foreach ((array)$piVars['filter'] as $field => $value) { + if (empty($value)) { + continue; + } + + switch ($field) { + case 'sku': + $constraints[] = $query->like('sku', '%' . $value . '%'); + break; + case 'title': + $constraints[] = $query->like('title', '%' . $value . '%'); + } + } + } + + // create constraint + if (!empty($constraints)) { + $query->matching( + $query->logicalAnd($constraints) + ); + } + + $beVariantAttributes = $query->execute(); + + return $beVariantAttributes; + } +} diff --git a/Classes/Domain/Repository/Product/BeVariantAttributeRepository.php b/Classes/Domain/Repository/Product/BeVariantAttributeRepository.php new file mode 100644 index 00000000..9a5c6815 --- /dev/null +++ b/Classes/Domain/Repository/Product/BeVariantAttributeRepository.php @@ -0,0 +1,68 @@ + + */ +class BeVariantAttributeRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + + /** + * Finds objects filtered by $piVars['filter'] + * + * @param array $piVars + * @return Query Object + */ + public function findAll($piVars = array()) + { + // settings + $query = $this->createQuery(); + + $constraints = array(); + + // filter + if (isset($piVars['filter'])) { + foreach ((array)$piVars['filter'] as $field => $value) { + if (empty($value)) { + continue; + } + + switch ($field) { + case 'sku': + $constraints[] = $query->like('sku', '%' . $value . '%'); + break; + case 'title': + $constraints[] = $query->like('title', '%' . $value . '%'); + } + } + } + + // create constraint + if (!empty($constraints)) { + $query->matching( + $query->logicalAnd($constraints) + ); + } + + $beVariantAttributes = $query->execute(); + + return $beVariantAttributes; + } +} diff --git a/Classes/Domain/Repository/Product/BeVariantRepository.php b/Classes/Domain/Repository/Product/BeVariantRepository.php new file mode 100644 index 00000000..f19d8624 --- /dev/null +++ b/Classes/Domain/Repository/Product/BeVariantRepository.php @@ -0,0 +1,27 @@ + + */ +class BeVariantRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + +} diff --git a/Classes/Domain/Repository/Product/CouponRepository.php b/Classes/Domain/Repository/Product/CouponRepository.php new file mode 100644 index 00000000..522ad56f --- /dev/null +++ b/Classes/Domain/Repository/Product/CouponRepository.php @@ -0,0 +1,27 @@ + + */ +class CouponRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + +} diff --git a/Classes/Domain/Repository/Product/ProductRepository.php b/Classes/Domain/Repository/Product/ProductRepository.php new file mode 100644 index 00000000..c56896ec --- /dev/null +++ b/Classes/Domain/Repository/Product/ProductRepository.php @@ -0,0 +1,120 @@ + + */ +class ProductRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + + /** + * Finds objects filtered by $piVars['filter'] + * + * @param array $piVars + * @return Query Object + */ + public function findAll($piVars = array()) + { + // settings + $query = $this->createQuery(); + + $constraints = array(); + + // filter + if (isset($piVars['filter'])) { + foreach ((array)$piVars['filter'] as $field => $value) { + if (empty($value)) { + continue; + } + + switch ($field) { + case 'sku': + $constraints[] = $query->equals('sku', $value); + break; + case 'title': + $constraints[] = $query->like('title', '%' . $value . '%'); + } + } + } + + // create constraint + if (!empty($constraints)) { + $query->matching( + $query->logicalAnd($constraints) + ); + } + + $products = $query->execute(); + + return $products; + } + + /** + * Finds objects based on selected categories + * + * @param array $categories + * + * @return object + */ + public function findByCategories($categories) + { + $query = $this->createQuery(); + //$query->getQuerySettings()->setRespectStoragePage(false); + + $constraints = array(); + + if ((!empty($categories))) { + $categoryConstraints = array(); + foreach ($categories as $category) { + $categoryConstraints[] = $query->contains('productCategories', $category); + } + $constraints = $query->logicalOr($categoryConstraints); + } + + if (!empty($constraints)) { + $query->matching( + $query->logicalAnd($constraints) + ); + } + + $result = $query->execute(); + + return $result; + } + + /** + * Finds objects based on selected uids + * + * @param string $uids + * + * @return object + */ + public function findByUids($uids) + { + $uids = explode(',', $uids); + + $query = $this->createQuery(); + $query->matching( + $query->in('uid', $uids) + ); + + return $query->execute(); + } +} diff --git a/Classes/Domain/Repository/Product/SpecialPriceRepository.php b/Classes/Domain/Repository/Product/SpecialPriceRepository.php new file mode 100644 index 00000000..eecb7597 --- /dev/null +++ b/Classes/Domain/Repository/Product/SpecialPriceRepository.php @@ -0,0 +1,27 @@ + + */ +class SpecialPriceRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + +} diff --git a/Classes/Domain/Repository/Product/TaxClassRepository.php b/Classes/Domain/Repository/Product/TaxClassRepository.php new file mode 100644 index 00000000..9f08fb54 --- /dev/null +++ b/Classes/Domain/Repository/Product/TaxClassRepository.php @@ -0,0 +1,33 @@ + + */ +class TaxClassRepository extends \TYPO3\CMS\Extbase\Persistence\Repository +{ + public function initializeObject() + { + /** @var $querySettings \TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings */ + $querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings'); + $querySettings->setRespectStoragePage(false); + $this->setDefaultQuerySettings($querySettings); + } +} diff --git a/Classes/Exception/ResetPropertyException.php b/Classes/Exception/ResetPropertyException.php new file mode 100644 index 00000000..ec8952b3 --- /dev/null +++ b/Classes/Exception/ResetPropertyException.php @@ -0,0 +1,27 @@ + + */ +class ResetPropertyException extends \TYPO3\CMS\Extbase\Property\Exception +{ + +} diff --git a/Classes/Service/MailHandler.php b/Classes/Service/MailHandler.php new file mode 100644 index 00000000..ea259d7e --- /dev/null +++ b/Classes/Service/MailHandler.php @@ -0,0 +1,326 @@ + + */ +class MailHandler implements SingletonInterface +{ + /** + * Extension Name + * + * @var string + */ + protected $extensionName = 'Cart'; + + /** + * Plugin Name + * + * @var string + */ + protected $pluginName = 'Cart'; + + /** + * Extbase Object Manager + * + * @var \TYPO3\CMS\Extbase\Object\ObjectManager + * @inject + */ + protected $objectManager; + + /** + * Configuration Manager + * + * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManager + * @inject + */ + protected $configurationManager; + + /** + * Plugin Settings + * + * @var array + */ + protected $pluginSettings; + + /** + * Cart + * + * @var \Extcode\Cart\Domain\Model\Cart\Cart + */ + protected $cart; + + /** + * Buyer Email From Address + * + * @var string + */ + protected $buyerEmailFrom; + + /** + * Seller Email From Address + * + * @var string + */ + protected $sellerEmailFrom; + + /** + * Seller Email To Address + * + * @var string + */ + protected $sellerEmailTo; + + /** + * MailHandler constructor + */ + public function __construct() + { + $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( + 'TYPO3\CMS\Extbase\Object\ObjectManager' + ); + + $this->configurationManager = + $this->objectManager->get( + 'TYPO3\CMS\Extbase\Configuration\ConfigurationManager' + ); + + $this->setPluginSettings(); + + if (!empty($this->pluginSettings['settings'])) { + if (!empty($this->pluginSettings['settings']['buyer']) && + !empty($this->pluginSettings['settings']['buyer']['emailFromAddress']) + ) { + $this->setBuyerEmailFrom($this->pluginSettings['settings']['buyer']['emailFromAddress']); + } + + if (!empty($this->pluginSettings['settings']['seller']) && + !empty($this->pluginSettings['settings']['seller']['emailFromAddress']) + ) { + $this->setSellerEmailFrom($this->pluginSettings['settings']['seller']['emailFromAddress']); + } + + if (!empty($this->pluginSettings['settings']['seller']) && + !empty($this->pluginSettings['settings']['seller']['emailToAddress']) + ) { + $this->setSellerEmailTo($this->pluginSettings['settings']['seller']['emailToAddress']); + } + } + } + + /** + * Sets Plugin Settings + * + * @return void + */ + public function setPluginSettings() + { + $this->pluginSettings = + $this->configurationManager->getConfiguration( + \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, + $this->extensionName, + $this->pluginName + ); + } + + /** + * Sets Cart + * + * @param \Extcode\Cart\Domain\Model\Cart\Cart $cart + * + * @return void + */ + public function setCart($cart) + { + $this->cart = $cart; + } + + /** + * @param string $email + * + * @return void + */ + public function setBuyerEmailFrom($email) + { + $this->buyerEmailFrom = $email; + } + + /** + * @param string $email + * + * @return void + */ + public function setSellerEmailFrom($email) + { + $this->sellerEmailFrom = $email; + } + + /** + * @param string $email + * + * @return void + */ + public function setSellerEmailTo($email) + { + $this->sellerEmailTo = $email; + } + + /** + * Send a Mail to Buyer + * + * @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 + */ + public function sendBuyerMail( + \Extcode\Cart\Domain\Model\Order\Item $orderItem, + \Extcode\Cart\Domain\Model\Order\Address $billingAddress, + \Extcode\Cart\Domain\Model\Order\Address $shippingAddress = null + ) { + if (empty($this->buyerEmailFrom)) { + return; + } + + $renderer = $this->getEmailRenderer('OrderBuyer'); + + $renderer->assign('settings', $this->pluginSettings['settings']); + + $renderer->assign('cart', $this->cart); + $renderer->assign('orderItem', $orderItem); + $renderer->assign('billingAddress', $billingAddress); + $renderer->assign('shippingAddress', $shippingAddress); + + $mailBody = $renderer->render(); + + $mail = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage'); + $mail->setFrom($this->buyerEmailFrom); + $mail->setTo($billingAddress->getEmail()); + $mail->setSubject( + \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_cart.mail.buyer.subject', 'Cart') + ); + $mail->setBody($mailBody, 'text/html', 'utf-8'); + //$mail->addPart(strip_tags($mailBody), 'text/plain', 'utf-8'); + $mail->send(); + } + + /** + * Send a Mail to Seller + * + * @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 + */ + public function sendSellerMail( + \Extcode\Cart\Domain\Model\Order\Item $orderItem, + \Extcode\Cart\Domain\Model\Order\Address $billingAddress, + \Extcode\Cart\Domain\Model\Order\Address $shippingAddress = null + ) { + if (empty($this->sellerEmailFrom) && + empty($this->sellerEmailTo) + ) { + return; + } + + $renderer = $this->getEmailRenderer('OrderSeller'); + + $renderer->assign('settings', $this->pluginSettings['settings']); + + $renderer->assign('cart', $this->cart); + $renderer->assign('orderItem', $orderItem); + $renderer->assign('billingAddress', $billingAddress); + $renderer->assign('shippingAddress', $shippingAddress); + + $mailBody = $renderer->render(); + + $mail = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage'); + $mail->setFrom($this->sellerEmailFrom); + $mail->setTo($this->sellerEmailTo); + $mail->setSubject( + \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_cart.mail.seller.subject', 'Cart') + ); + $mail->setBody($mailBody, 'text/html', 'utf-8'); + //$mail->addPart(strip_tags($mailBody), 'text/plain', 'utf-8'); + $mail->send(); + } + + /** + * This creates another stand-alone instance of the Fluid StandaloneView + * to render an e-mail template + * + * @param string $templateFileName Template file name + * @param string $format Template file format + * + * @return \TYPO3\CMS\Fluid\View\StandaloneView Fluid instance + */ + protected function getEmailRenderer($templateFileName = 'Default', $format = 'html') + { + $view = $this->objectManager->get('TYPO3\\CMS\\Fluid\\View\\StandaloneView'); + $view->setFormat($format); + + $layoutRootPaths = array(); + $partialRootPaths = array(); + $templateRootPaths = array(); + + if ($this->pluginSettings['view']) { + if ($this->pluginSettings['view']['layoutRootPaths']) { + foreach ($this->pluginSettings['view']['layoutRootPaths'] as $pathNameKey => $pathNameValue) { + $layoutRootPaths[$pathNameKey] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName( + $pathNameValue + ); + } + } + $view->setLayoutRootPaths($layoutRootPaths); + + if ($this->pluginSettings['view']['layoutRootPaths']) { + foreach ($this->pluginSettings['view']['partialRootPaths'] as $pathNameKey => $pathNameValue) { + $partialRootPaths[$pathNameKey] = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName( + $pathNameValue + ); + } + } + $view->setPartialRootPaths($partialRootPaths); + + if ($this->pluginSettings['view']['templateRootPaths']) { + $templateRootPaths = $this->pluginSettings['view']['templateRootPaths']; + } + } + + foreach ($templateRootPaths as $templateRootPath) { + $templateRootPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($templateRootPath); + + if (file_exists($templateRootPath)) { + $templatePathAndFilename = $templateRootPath; + $templatePathAndFilename .= '/Cart/Mail/'; + $templatePathAndFilename .= $templateFileName . '.' . $format; + + $view->setTemplatePathAndFilename($templatePathAndFilename); + break; + } + } + + return $view; + } +} diff --git a/Classes/Service/SessionHandler.php b/Classes/Service/SessionHandler.php new file mode 100644 index 00000000..55a59304 --- /dev/null +++ b/Classes/Service/SessionHandler.php @@ -0,0 +1,85 @@ + + */ +class SessionHandler implements SingletonInterface +{ + + private $prefixKey = 'cart_'; + + /** + * Returns the object stored in the user´s PHP session + * + * @param string $key + * + * @return \Extcode\Cart\Domain\Model\Cart\Cart + */ + public function restoreFromSession($key) + { + $sessionData = $GLOBALS['TSFE']->fe_user->getKey('ses', $this->prefixKey . $key); + return unserialize($sessionData); + } + + /** + * Writes an object into the PHP session + * + * @param \Extcode\Cart\Domain\Model\Cart\Cart $cart Cart + * @param string $key Session Key + * + * @return SessionHandler $this + */ + public function writeToSession(\Extcode\Cart\Domain\Model\Cart\Cart $cart, $key) + { + $sessionData = serialize($cart); + $GLOBALS['TSFE']->fe_user->setKey('ses', $this->prefixKey . $key, $sessionData); + $GLOBALS['TSFE']->fe_user->storeSessionData(); + return $this; + } + + /** + * Cleans up the session: removes the stored object from the PHP session + * + * @param string $key + * + * @return SessionHandler $this + */ + public function cleanUpSession($key) + { + $GLOBALS['TSFE']->fe_user->setKey('ses', $this->prefixKey . $key, null); + $GLOBALS['TSFE']->fe_user->storeSessionData(); + return $this; + } + + /** + * Sets own prefix key for session + * + * @param string $prefixKey + * + * @return void + */ + public function setPrefixKey($prefixKey) + { + $this->prefixKey = $prefixKey; + } +} diff --git a/Classes/Utility/CartUtility.php b/Classes/Utility/CartUtility.php new file mode 100644 index 00000000..42011f23 --- /dev/null +++ b/Classes/Utility/CartUtility.php @@ -0,0 +1,928 @@ + + */ +class CartUtility +{ + + /** + * Session Handler + * + * @var \Extcode\Cart\Service\SessionHandler + * @inject + */ + protected $sessionHandler; + + /** + * Parser Utility + * + * @var \Extcode\Cart\Utility\ParserUtility + * @inject + */ + protected $parserUtility; + + /** + * Plugin Settings + * + * @var array + */ + protected $pluginSettings; + + /** + * Tax Classes + * + * @var array + */ + protected $taxClasses; + + /** + * Restore cart from session or creates a new one + * + * @param array $cartSettings TypoScript Cart Settings + * @param array $pluginSettings TypoScript Plugin Settings + * + * @return \Extcode\Cart\Domain\Model\Cart\Cart + */ + public function getCartFromSession(array $cartSettings, array $pluginSettings) + { + $cart = $this->sessionHandler->restoreFromSession($cartSettings['pid']); + + if (!$cart) { + $cart = $this->getNewCart($cartSettings, $pluginSettings); + } + + return $cart; + } + + /** + * Creates a new cart + * + * @param array $cartSettings TypoScript Cart Settings + * @param array $pluginSettings TypoScript Plugin Settings + * + * @return \Extcode\Cart\Domain\Model\Cart\Cart + */ + public function getNewCart(array $cartSettings, array $pluginSettings) + { + $isNetCart = intval($cartSettings['isNetCart']) == 0 ? false : true; + + $taxClasses = $this->parserUtility->parseTaxClasses($pluginSettings); + + $cart = new \Extcode\Cart\Domain\Model\Cart\Cart($taxClasses, $isNetCart); + + $shippings = $this->parserUtility->parseServices('Shipping', $pluginSettings, $cart); + + foreach ($shippings as $shipping) { + /** + * Shipping + * @var \Extcode\Cart\Domain\Model\Shipping $shipping + */ + if ($shipping->getIsPreset()) { + $cart->setShipping($shipping); + break; + } + } + + $payments = $this->parserUtility->parseServices('Payment', $pluginSettings, $cart); + + foreach ($payments as $payment) { + /** + * Payment + * @var \Extcode\Cart\Domain\Model\Payment $payment + */ + if ($payment->getIsPreset()) { + $cart->setPayment($payment); + break; + } + } + + return $cart; + } + + /** + * Get Order Number + * + * @param array $pluginSettings TypoScript Plugin Settings + * + * @return string + */ + protected function getOrderNumber(array $pluginSettings) + { + $cObjRenderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); + + $typoScriptService = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService'); + $pluginTypoScriptSettings = $typoScriptService->convertPlainArrayToTypoScriptArray($pluginSettings); + + $registry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry'); + + $registryName = 'lastInvoice_' . $pluginSettings['settings']['cart']['pid']; + $orderNumber = $registry->get('tx_cart', $registryName); + + $orderNumber = $orderNumber ? $orderNumber + 1 : 1; + + $registry->set('tx_cart', $registryName, $orderNumber); + + $cObjRenderer->start(array('orderNumber' => $orderNumber)); + $orderNumber = $cObjRenderer-> + cObjGetSingle($pluginTypoScriptSettings['orderNumber'], $pluginTypoScriptSettings['orderNumber.']); + + return $orderNumber; + } + + /** + * Get Cart/Product From Request + * + * @param array $pluginSettings TypoScript Plugin Settings + * @param Request $request Request + * @param \Extcode\Cart\Domain\Model\Cart\TaxClass[] $taxClasses Tax Class Array + * + * @return \Extcode\Cart\Domain\Model\Cart\Product[] + */ + public function getProductsFromRequest(array $pluginSettings, Request $request, array $taxClasses) + { + if (!$this->pluginSettings) { + $this->pluginSettings = $pluginSettings; + } + if (!$this->taxClasses) { + $this->taxClasses = $taxClasses; + } + + $multiple = 1; + if ($this->pluginSettings['multiple']) { + $argumentName = $this->pluginSettings['multiple']; + if ($request->hasArgument($argumentName)) { + $multiple = intval($request->getArgument($argumentName)); + } + } + + $products = array(); + $preCartProductSets = array(); + + if ($multiple == 1) { + $preCartProductSets[1] = $this->parserUtility->getPreCartProductSet($pluginSettings, $request); + } else { + // TODO: iterate over request + } + + foreach ($preCartProductSets as $preCartProductSetKey => $preCartProductSetValue) { + if ($preCartProductSetValue['contentId']) { + $products[$preCartProductSetKey] = $this->getCartProductFromCE($preCartProductSetValue); + } elseif ($preCartProductSetValue['productId']) { + $products[$preCartProductSetKey] = $this->getCartProductFromDatabase($preCartProductSetValue); + } + } + + return $products; + } + + + + /** + * Create a CartProduct from array + * + * @param array $preCartProductSetValue + * + * @return \Extcode\Cart\Domain\Model\Cart\Product + */ + public function createproduct(array $preCartProductSetValue) + { + $newFeVariant = null; + if ($preCartProductSetValue['feVariants']) { + $newFeVariant = new \Extcode\Cart\Domain\Model\Cart\FeVariant( + $preCartProductSetValue['feVariants'] + ); + } + + $newCartProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + $preCartProductSetValue['productId'], + $preCartProductSetValue['tableId'], + $preCartProductSetValue['contentId'], + $preCartProductSetValue['sku'], + $preCartProductSetValue['title'], + $preCartProductSetValue['price'], + $this->taxClasses[$preCartProductSetValue['taxClassId']], + $preCartProductSetValue['quantity'], + $preCartProductSetValue['isNetPrice'], + $newFeVariant + ); + + if ($preCartProductSetValue['maxNumber'] !== null) { + $newCartProduct->setMaxNumberInCart($preCartProductSetValue['maxNumber']); + } + if ($preCartProductSetValue['minNumber'] !== null) { + $newCartProduct->setMinNumberInCart($preCartProductSetValue['minNumber']); + } + if ($preCartProductSetValue['specialPrice'] !== null) { + $newCartProduct->setSpecialPrice($preCartProductSetValue['specialPrice']); + } + + $newVariantArr = array(); + + // ToDo: refactor Variant + + if ($preCartProductSetValue['beVariants']) { + $variantConf = array(); + if (isset($this->pluginSettings['repository']) && is_array($this->pluginSettings['repository'])) { + $variantConf = $this->pluginSettings; + } elseif (isset($this->pluginSettings['db']) && is_array($this->pluginSettings['db'])) { + $variantConf = $this->pluginSettings; + } + + $priceCalcMethod = $preCartProductSetValue['priceCalcMethod']; + $price = $newCartProduct->getBestPrice(); + if ($this->pluginSettings['gpValues']['beVariants']) { + foreach ($this->pluginSettings['gpValues']['beVariants'] as $variantsKey => $variantsValue) { + if ($variantsKey == 1) { + if ($preCartProductSetValue['hasFeVariants']) { + $newVariant = $this->getFeVariant( + $newCartProduct, + null, + $preCartProductSetValue, + $variantsValue, + $priceCalcMethod, + $price, + $preCartProductSetValue['hasFeVariants'] - 1 + ); + } else { + if (isset($this->pluginSettings['repository'])) { + $variantConf = $variantConf['repository']['beVariants']; + } elseif (isset($this->pluginSettings['db'])) { + $variantConf = $variantConf['db']['beVariants']; + } + + $newVariant = $this->getDatabaseVariant( + $newCartProduct, + null, + $variantConf, + $preCartProductSetValue, + $variantsValue, + $priceCalcMethod, + $price + ); + } + + if ($newVariant) { + $newVariantArr[$variantsKey] = $newVariant; + $newCartProduct->addBeVariant($newVariant); + $price = $newVariant->getPrice(); + } else { + break; + } + } elseif ($variantsKey > 1) { + // check if variant key-1 has fe_variants defined then use input as fe variant + if ($newVariantArr[$variantsKey - 1]->getHasFeVariants()) { + $newVariant = $this->getFeVariant( + null, + $newVariantArr[$variantsKey - 1], + $preCartProductSetValue, + $variantsValue, + $priceCalcMethod, + $price, + $newVariantArr[$variantsKey - 1]->getHasFeVariants() - 1 + ); + } else { + if (isset($variantConf['repository'])) { + $variantConf = $variantConf['repository']['beVariants']; + } elseif (isset($variantConf['db'])) { + $variantConf = $variantConf['db']['beVariants']; + } + + $newVariant = $this->getDatabaseVariant(null, $newVariantArr[$variantsKey - 1], + $variantConf, $preCartProductSetValue, $variantsValue, $priceCalcMethod, $price); + } + + if ($newVariant) { + $newVariantArr[$variantsKey] = $newVariant; + $newVariantArr[$variantsKey - 1]->addBeVariant($newVariant); + $price = $newVariant->getPrice(); + } else { + break; + } + } + } + } + } + return $newCartProduct; + } + + /** + * Get Variant Data From Database + * + * @param \Extcode\Cart\Domain\Model\Cart\Product $product + * @param \Extcode\Cart\Domain\Model\Cart\BeVariant $variant + * @param $variantConf + * @param $preCartProductSetValue + * @param $variantsValue + * @param $priceCalcMethod + * @param $price + * + * @return \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + protected function getDatabaseVariant( + $product, + $variant, + $variantConf, + $preCartProductSetValue, + $variantsValue, + $priceCalcMethod, + $price + ) { + + list($pluginSettingsVariantsName, $pluginSettingsVariantsKey, $remainder) = explode('|', $variantsValue, 3); + $variantsValue = $preCartProductSetValue[$pluginSettingsVariantsName][$pluginSettingsVariantsKey]; + // if value is a integer, get details from database + if (!is_int($variantsValue) ? (ctype_digit($variantsValue)) : true) { + // creating a new Variant and using Price and Taxclass form CartProduct + + // get further data of variant + $variantData = $this->getVariantDetails($variantsValue, $variantConf); + + if ($variantData['priceCalcMethod']) { + $priceCalcMethod = intval($variantData['priceCalcMethod']); + } + + $newVariant = new \Extcode\Cart\Domain\Model\Cart\BeVariant ( + $variantsValue, + $product, + $variant, + $variantData['title'], + $variantData['sku'], + $priceCalcMethod, + $price, + $preCartProductSetValue['quantity'] + ); + + unset($variantData['title']); + unset($variantData['sku']); + + foreach ($variantData as $variantDataKey => $variantDataValue) { + if (!is_array($variantDataValue)) { + $setter = 'set' . ucfirst($variantDataKey); + $newVariant->$setter($variantDataValue); + } + } + + } + + return $newVariant; + } + + /** + * Get Frontend Variant + * + * @param \Extcode\Cart\Domain\Model\Cart\Product $product + * @param \Extcode\Cart\Domain\Model\Cart\BeVariant $variant + * @param array $preCartProductSetValue + * @param string $variantsValue + * @param integer $priceCalcMethod + * @param float $price + * @param integer $hasCountFeVariants + * + * @return \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + protected function getFeVariant( + $product, + $variant, + array $preCartProductSetValue, + $variantsValue, + $priceCalcMethod, + $price, + $hasCountFeVariants + ) { + $newVariant = new \Extcode\Cart\Domain\Model\Cart\BeVariant( + sha1($variantsValue), + $product, + $variant, + $variantsValue, + str_replace(' ', '', $variantsValue), + $priceCalcMethod, + $price, + $preCartProductSetValue['quantity'], + $preCartProductSetValue['isNetPrice'] + ); + + $newVariant->setHasFeVariants($hasCountFeVariants); + + return $newVariant; + } + + /** + * Get CartProduct from Content Element + * + * @param array $preCartProductSetValue + * + * @return \Extcode\Cart\Domain\Model\Cart\Product + */ + public function getCartProductFromCE(array $preCartProductSetValue) + { + $abstractPlugin = new \TYPO3\CMS\Frontend\Plugin\AbstractPlugin(); + + $row = $abstractPlugin->pi_getRecord('tt_content', $preCartProductSetValue['contentId']); + + $flexformData = GeneralUtility::xml2array($row['pi_flexform']); + + $gpvarArr = array('productId', 'sku', 'title', 'price', 'isNetPrice'); + foreach ($gpvarArr as $gpvarVal) { + $preCartProductSetValue[$gpvarVal] = $abstractPlugin->pi_getFFvalue( + $flexformData, + 'settings.' . $gpvarVal, + 'sDEF' + ); + } + + $preCartProductSetValue['taxClassId'] = $abstractPlugin->pi_getFFvalue( + $flexformData, + 'settings.taxClassId', + 'sDEF' + ); + + $attributes = explode("\n", $abstractPlugin->pi_getFFvalue($flexformData, 'settings.attributes', 'sDEF')); + + foreach ($attributes as $line) { + list($key, $value) = explode('==', $line, 2); + switch ($key) { + case 'serviceAttribute1': + $preCartProductSetValue['serviceAttribute1'] = floatval($value); + break; + case 'serviceAttribute2': + $preCartProductSetValue['serviceAttribute2'] = floatval($value); + break; + case 'serviceAttribute3': + $preCartProductSetValue['serviceAttribute3'] = floatval($value); + break; + case 'minNumber': + $preCartProductSetValue['minNumber'] = intval($value); + break; + case 'maxNumber': + $preCartProductSetValue['maxNumber'] = intval($value); + break; + default: + } + } + + return $this->createproduct($preCartProductSetValue); + } + + /** + * Get CartProduct from Database + * + * @param array $preCartProductSetValue + * + * @return \Extcode\Cart\Domain\Model\Cart\Product + */ + public function getCartProductFromDatabase(array $preCartProductSetValue) + { + + if (isset($this->pluginSettings['repository']) && is_array($this->pluginSettings['repository'])) { + return $this->getCartProductDetailsFromRepository($preCartProductSetValue, $this->pluginSettings['repository']); + } elseif (isset($this->pluginSettings['db']) && is_array($this->pluginSettings['db'])) { + return $this->getCartProductDetailsFromTable($preCartProductSetValue, $this->pluginSettings['db']); + } + + return false; + } + + /** + * Get CartProduct from Database Table + * + * @param array $preCartProductSetValue + * @param array $databaseSettings + * + * @return \Extcode\Cart\Domain\Model\Cart\Product + */ + public function getCartProductDetailsFromTable($preCartProductSetValue, $databaseSettings) + { + $productId = intval($preCartProductSetValue['productId']); + + $tableId = intval($preCartProductSetValue['tableId']); + if (($tableId != 0) && ($databaseSettings[$tableId])) { + $databaseSettings = $databaseSettings[$tableId]; + } + + $table = $databaseSettings['table']; + + $l10nParent = $databaseSettings['l10n_parent']; + + $select = $this->getCartProductDataSelect($table, $databaseSettings['fields']); + + $where = ' ( ' . $table . '.uid = ' . $productId . ' OR ' . $table . '.' . $l10nParent . ' = ' . $productId . ' )' . + ' AND sys_language_uid = ' . $GLOBALS['TSFE']->sys_language_uid; + //$where .= $this->contentObject->enableFields($table); + $groupBy = ''; + $orderBy = ''; + $limit = 1; + + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, $groupBy, $orderBy, $limit); + + if ($res) { + $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); + + $preCartProductSetValue['title'] = $row[$databaseSettings['title']]; + $preCartProductSetValue['price'] = $row[$databaseSettings['price']]; + $preCartProductSetValue['taxClassId'] = $row[$databaseSettings['taxClassId']]; + + if ($row[$databaseSettings['sku']]) { + $preCartProductSetValue['sku'] = $row[$databaseSettings['sku']]; + } + if ($row[$databaseSettings['serviceAttribute1']]) { + $preCartProductSetValue['serviceAttribute1'] = $row[$databaseSettings['serviceAttribute1']]; + } + if ($row[$databaseSettings['serviceAttribute2']]) { + $preCartProductSetValue['serviceAttribute2'] = $row[$databaseSettings['serviceAttribute2']]; + } + if ($row[$databaseSettings['serviceAttribute3']]) { + $preCartProductSetValue['serviceAttribute3'] = $row[$databaseSettings['serviceAttribute3']]; + } + if ($row[$databaseSettings['serviceAttribute3']]) { + $preCartProductSetValue['serviceAttribute3'] = $row[$databaseSettings['serviceAttribute3']]; + } + if ($row[$databaseSettings['hasFeVariants']]) { + $preCartProductSetValue['hasFeVariants'] = $row[$databaseSettings['hasFeVariants']]; + } + if ($row[$databaseSettings['minNumber']]) { + $preCartProductSetValue['minNumber'] = $row[$databaseSettings['minNumber']]; + } + if ($row[$databaseSettings['maxNumber']]) { + $preCartProductSetValue['maxNumber'] = $row[$databaseSettings['maxNumber']]; + } + if ($row[$databaseSettings['specialPrice']]) { + $preCartProductSetValue['specialPrice'] = $row[$databaseSettings['specialPrice']]; + } + + if ($databaseSettings['additional']) { + $preCartProductSetValue['additional'] = array(); + foreach ($databaseSettings['additional'] as $additionalKey => $additionalValue) { + if ($additionalValue['field']) { + $preCartProductSetValue['additional'][$additionalKey] = $row[$additionalValue['field']]; + } elseif ($additionalValue['value']) { + $preCartProductSetValue['additional'][$additionalKey] = $additionalValue['value']; + } + } + } + } + + return $this->createproduct($preCartProductSetValue); + } + + /** + * Get CartProduct from Database Repository + * + * @param array $preCartProductSetValue + * @param array $repositorySettings + * + * @return \Extcode\Cart\Domain\Model\Cart\Product + */ + public function getCartProductDetailsFromRepository($preCartProductSetValue, $repositorySettings) + { + $productId = intval($preCartProductSetValue['productId']); + + $repositoryId = intval($preCartProductSetValue['repositoryId']); + if (($repositoryId != 0) && ($repositorySettings[$repositoryId])) { + $repositorySettings = $repositorySettings[$repositoryId]; + } + + $objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager'); + $productRepository = $objectManager->get($repositorySettings['class']); + $productObject = $productRepository->findByUid($productId); + + $repositoryFields = $repositorySettings['fields']; + + if ($productObject) { + if (isset($repositoryFields['getTitle'])) { + $preCartProductSetValue['title'] = $productObject->$repositoryFields['getTitle']; + } else { + $preCartProductSetValue['title'] = $productObject->getTitle(); + } + if (isset($repositoryFields['getSku'])) { + $preCartProductSetValue['sku'] = $productObject->$repositoryFields['getSku']; + } else { + $preCartProductSetValue['sku'] = $productObject->getSku(); + } + if (isset($repositoryFields['getPrice'])) { + $preCartProductSetValue['price'] = $productObject->$repositoryFields['getPrice']; + } else { + $preCartProductSetValue['price'] = $productObject->getPrice(); + } + + if (isset($repositoryFields['getProductTaxClassId'])) { + $preCartProductSetValue['taxClassId'] = $productObject->$repositoryFields['getProductTaxClassId'](); + } elseif (isset($repositoryFields['getProductTaxClass'])) { + $preCartProductSetValue['taxClassId'] = $productObject->$repositoryFields['getProductTaxClass']()->getUid(); + } else { + $preCartProductSetValue['taxClassId'] = $productObject->getTaxClassId(); + } + + if (isset($repositoryFields['getServiceAttribute1'])) { + $preCartProductSetValue['serviceAttribute1'] = $productObject->$repositoryFields['getServiceAttribute1'](); + } + if (isset($repositoryFields['getServiceAttribute2'])) { + $preCartProductSetValue['serviceAttribute2'] = $productObject->$repositoryFields['getServiceAttribute2'](); + } + if (isset($repositoryFields['getServiceAttribute3'])) { + $preCartProductSetValue['serviceAttribute3'] = $productObject->$repositoryFields['getServiceAttribute3'](); + } + + if (isset($repositoryFields['hasFeVariants'])) { + $preCartProductSetValue['hasFeVariants'] = $productObject->$repositoryFields['hasFeVariants'](); + } + + if (isset($repositoryFields['getSpecialPrice'])) { + $preCartProductSetValue['specialPrice'] = $productObject->$repositoryFields['getSpecialPrice'](); + } + + if (isset($repositoryFields['getMinNumber'])) { + $preCartProductSetValue['minNumber'] = $productObject->$repositoryFields['getMinNumber'](); + } + if (isset($repositoryFields['getMaxNumber'])) { + $preCartProductSetValue['maxNumber'] = $productObject->$repositoryFields['getMaxNumber'](); + } + + if (isset($repositoryFields['getFeVariants'])) { + $feVariantValues = $preCartProductSetValue['feVariants']; + + $feVariants = $productObject->$repositoryFields['getFeVariants'](); + + if ($feVariants) { + $preCartProductSetValue['feVariants'] = array(); + foreach ($feVariants as $feVariant) { + if ($feVariantValues[$feVariant->getSku()]) { + $preCartProductSetValue['feVariants'][] = array( + 'sku' => $feVariant->getSku(), + 'title' => $feVariant->getTitle(), + 'value' => $feVariantValues[$feVariant->getSku()] + ); + } + } + } + } + + if ($repositoryFields['additional.']) { + $preCartProductSetValue['additional'] = array(); + foreach ($repositoryFields['additional.'] as $additionalKey => $additionalValue) { + if ($additionalValue['field']) { + $preCartProductSetValue['additional'][$additionalKey] = $productObject->$additionalValue['field'](); + } elseif ($additionalValue['value']) { + $preCartProductSetValue['additional'][$additionalKey] = $additionalValue['value'](); + } + } + } + + } + + return $this->createproduct($preCartProductSetValue); + } + + /** + * @param string $table + * @param $databaseFields + * + * @return string + */ + protected function getCartProductDataSelect($table, $databaseFields) + { + $select = ""; + + foreach ($databaseFields as $databaseFieldKey => $databaseFieldValue) { + if ($databaseFieldValue != '' && is_string($databaseFieldValue)) { + if ($databaseFieldValue != '{$plugin.tx_cart.db.' . $databaseFieldKey . '}') { + $select .= ', ' . $table . '.' . $databaseFieldValue; + } + } + } + + if ($databaseFields['variants'] != '' && $databaseFields['variants'] != '{$plugin.tx_cart.db.variants}') { + $select .= ', ' . $table . '.' . $databaseFields['variants']; + } + + if ($databaseFields['additional.']) { + foreach ($databaseFields['additional.'] as $additional) { + if ($additional['field']) { + $select .= ', ' . $table . '.' . $additional['field']; + } + } + } + + return $select; + } + + /** + * @param int $variantId + * @param array $conf + * @return array + * @throws Exception + */ + public function getVariantDetails($variantId, &$conf) + { + + if (isset($conf['repository'])) { + return $this->getVariantDetailsFromRepository($variantId, $conf['repository']); + } elseif (isset($conf['db'])) { + return $this->getVariantDetailsFromTable($variantId, $conf['db']); + } + + throw new Exception; + } + + /** + * @param int $variantId + * @param array $databaseSettings + * + * @return array $variantData + */ + public function getVariantDetailsFromTable($variantId, $databaseSettings) + { + $table = $databaseSettings['table']; + $l10nParent = $databaseSettings['l10n_parent'] ? $databaseSettings['l10n_parent'] : 'l10n_parent'; + + $select = $table . '.' . $databaseSettings['title']; + + if ($databaseSettings['priceCalcMethod'] != '' && + $databaseSettings['priceCalcMethod'] != '{$plugin.cart.db.variants.db.priceCalcMethod}' + ) { + $select .= ', ' . $table . '.' . $databaseSettings['priceCalcMethod']; + } + if ($databaseSettings['price'] != '' && + $databaseSettings['price'] != '{$plugin.cart.db.variants.db.price}' + ) { + $select .= ', ' . $table . '.' . $databaseSettings['price']; + } + if ($databaseSettings['inheritPrice'] != '' && + $databaseSettings['variants.']['db.']['price'] != '{$plugin.cart.db.variants.db.inheritPrice}' + ) { + $select .= ', ' . $table . '.' . $databaseSettings['inheritPrice']; + } + if ($databaseSettings['sku'] != '' && + $databaseSettings['sku'] != '{$plugin.cart.db.variants.db.sku}' + ) { + $select .= ', ' . $table . '.' . $databaseSettings['sku']; + } + if ($databaseSettings['hasFeVariants'] != '' && + $databaseSettings['hasFeVariants'] != '{$plugin.cart.db.variants.db.hasFeVariants}' + ) { + $select .= ', ' . $table . '.' . $databaseSettings['hasFeVariants']; + } + + if ($databaseSettings['additional']) { + foreach ($databaseSettings['additional'] as $additional) { + if ($additional['field']) { + $select .= ', ' . $table . '.' . $additional['field']; + } + } + } + + $where = ' ( ' . $table . '.uid = ' . $variantId . ' OR ' . $l10nParent . ' = ' . $variantId . ' )' . + ' AND sys_language_uid = ' . $GLOBALS['TSFE']->sys_language_uid; + $where .= tslib_cObj::enableFields($table); + $groupBy = ''; + $orderBy = ''; + $limit = 1; + + if (TYPO3_DLOG) { + $GLOBALS['TYPO3_DB']->store_lastBuiltQuery = true; + } + + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, $groupBy, $orderBy, $limit); + + $variantData = array(); + + if ($res) { + $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); + + $variantData['title'] = $row[$databaseSettings['title']]; + if ($row[$databaseSettings['sku']]) { + $variantData['sku'] = $row[$databaseSettings['sku']]; + } + + if ($row[$databaseSettings['priceCalcMethod']]) { + $varianData['priceCalcMethod'] = $row[$databaseSettings['priceCalcMethod']]; + } + + // if inherit_price is defined then check the inherit_price and replace the with variant price + // if inherit_price is not defined then replace the with variant price + if ($databaseSettings['inheritPrice'] != '' && $databaseSettings['price'] != '{$plugin.cart.db.variants.db.inheritPrice}') { + if ($row[$databaseSettings['inheritPrice']]) { + if ($row[$databaseSettings['price']]) { + $variantData['price'] = $row[$databaseSettings['price']]; + } + } + } else { + if ($row[$databaseSettings['price']]) { + $variantData['price'] = $row[$databaseSettings['price']]; + } + } + + if ($row[$databaseSettings['hasFeVariants']]) { + $variantData['hasFeVariants'] = $row[$databaseSettings['hasFeVariants']]; + } + + if ($databaseSettings['additional']) { + foreach ($databaseSettings['additional'] as $additionalKey => $additionalValue) { + if ($additionalValue['field']) { + $variantData['additional'][$additionalKey] = $row[$additionalValue['field']]; + } elseif ($additionalValue['value']) { + $variantData['additional'][$additionalKey] = $additionalValue['value']; + } + } + } + } + + return $variantData; + } + + /** + * @param int $variantId + * @param array $repositorySettings + * + * @return array $variantData + */ + public function getVariantDetailsFromRepository($variantId, $repositorySettings) + { + $objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager'); + $variantRepository = $objectManager->get($repositorySettings['class']); + $variantObject = $variantRepository->findByUid($variantId); + + $variantData = array(); + if ($variantObject) { + + if (isset($variantObject->$repositorySettings['getTitle'])) { + $variantData['title'] = $variantObject->$repositorySettings['getTitle']; + } else { + $variantData['title'] = $variantObject->getTitle(); + } + + if (isset($variantObject->$repositorySettings['getSku'])) { + $variantData['sku'] = $variantObject->$repositorySettings['getSku']; + } else { + $variantData['sku'] = $variantObject->getSku(); + } + + if (isset($variantObject->$repositorySettings['getPriceCalcMethod'])) { + $variantData['priceCalcMethod'] = $variantObject->$repositorySettings['getPriceCalcMethod']; + } else { + $variantData['priceCalcMethod'] = $variantObject->getPriceCalcMethod(); + } + + if (isset($variantObject->$repositorySettings['getPrice'])) { + $variantData['price'] = $variantObject->$repositorySettings['getPrice']; + } else { + $variantData['price'] = $variantObject->getPrice(); + } + + if (isset($repositorySettings['hasFeVariants'])) { + $variantData['hasFeVariants'] = $repositorySettings['hasFeVariants']; + } + + if (isset($repositorySettings['additional']) && is_array($repositorySettings['additional'])) { + foreach ($repositorySettings['additional'] as $additionalKey => $additionalValue) { + if ($additionalValue['field']) { + $variantData['additional']['$additionalKey'] = $variantObject->$additionalValue['field']; + } elseif ($additionalValue['value']) { + $variantData['additional']['$additionalKey'] = $additionalValue['value']; + } + } + } + + /* + // if inherit_price is defined then check the inherit_price and replace the with variant price + // if inherit_price is not defined then replace the with variant price + if ($conf['db.']['inherit_price'] != '' && $conf['db.']['price'] != '{$plugin.wtcart.db.variants.db.inherit_price}') { + if ($row[$conf['db.']['inherit_price']]) { + if ($row[$conf['db.']['price']]) { + $variant->setPrice($row[$conf['db.']['price']]); + } + } + } else { + if ($row[$conf['db.']['price']]) { + $variant->setPrice($row[$conf['db.']['price']]); + } + } + */ + } + + return $variantData; + + } +} diff --git a/Classes/Utility/EvalPrice.php b/Classes/Utility/EvalPrice.php new file mode 100644 index 00000000..4a188f90 --- /dev/null +++ b/Classes/Utility/EvalPrice.php @@ -0,0 +1,67 @@ + + */ +class EvalPrice +{ + + /** + * Returns Field JS + * + * @return string + */ + public function returnFieldJs() + { + $js = ' + var re = new RegExp("^[0-9]{1,}[.,]{0,1}[0-9]{0,2}$"); + + if(value == "" || !value.match(re)) { + alert("please enter a price"); + return ""; + } + + return value;'; + + return $js; + } + + /** + * Evaluate Field Value + * + * @param $value + * @param $is_in + * @param $set + * + * @return string + */ + public function evaluateFieldValue($value, $is_in, &$set) + { + if ($value == '' + || $value == 'please enter a price' + || !preg_match("/^[0-9]{1,}[.,]{0,1}[0-9]{0,2}$/", $value) + ) { + return "please enter a price"; + } + + return $value; + } +} diff --git a/Classes/Utility/OrderUtility.php b/Classes/Utility/OrderUtility.php new file mode 100644 index 00000000..c7eeaf9c --- /dev/null +++ b/Classes/Utility/OrderUtility.php @@ -0,0 +1,853 @@ + + */ +class OrderUtility +{ + /** + * Persistence Manager + * + * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager + * @inject + */ + protected $persistenceManager; + + /** + * Object Manager + * + * @var \TYPO3\CMS\Extbase\Object\ObjectManager + * @inject + */ + protected $objectManager; + + /** + * Item Repository + * + * @var \Extcode\Cart\Domain\Repository\Order\ItemRepository + * @inject + */ + protected $orderItemRepository; + + /** + * Coupon Repository + * + * @var \Extcode\Cart\Domain\Repository\Order\CouponRepository + * @inject + */ + protected $couponRepository; + + /** + * Product Repository + * + * @var \Extcode\Cart\Domain\Repository\Order\ProductRepository + * @inject + */ + protected $productRepository; + + /** + * Product Additional Repository + * + * @var \Extcode\Cart\Domain\Repository\Order\ProductAdditionalRepository + * @inject + */ + protected $productAdditionalRepository; + + /** + * Address Repository + * + * @var \Extcode\Cart\Domain\Repository\Order\AddressRepository + * @inject + */ + protected $addressRepository; + + /** + * Payment Repository + * + * @var \Extcode\Cart\Domain\Repository\Order\PaymentRepository + * @inject + */ + protected $paymentRepository; + + /** + * Shipping Repository + * + * @var \Extcode\Cart\Domain\Repository\Order\ShippingRepository + * @inject + */ + protected $shippingRepository; + + /** + * Tax Class Repository + * + * @var \Extcode\Cart\Domain\Repository\Order\TaxClassRepository + * @inject + */ + protected $taxClassRepository; + + /** + * Order Tax Repository + * + * @var \Extcode\Cart\Domain\Repository\Order\TaxRepository + * @inject + */ + protected $taxRepository; + + /** + * Product Product Repository + * + * @var \Extcode\Cart\Domain\Repository\Product\ProductRepository + * @inject + */ + protected $productProductRepository; + + /** + * Cart + * + * @var \Extcode\Cart\Domain\Model\Cart\Cart + */ + protected $cart; + + /** + * Tax Classes + * + * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage + */ + private $taxClasses; + + /** + * Order Item + * + * @var \Extcode\Cart\Domain\Model\Order\Item + */ + protected $orderItem; + + /** + * Storage Pid + * + * @var int + */ + protected $storagePid = null; + + /** + * 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()); + } + + /** + * Check Stock + * + * @param \Extcode\Cart\Domain\Model\Cart\Cart $cart + */ + public function checkStock(\Extcode\Cart\Domain\Model\Cart\Cart $cart) + { + // TODO internal stock check + + $data = array( + 'cart' => $cart, + ); + + $signalSlotDispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); + $signalSlotDispatcher->dispatch( + __CLASS__, + 'afterInternalCheckStock', + array($data) + ); + } + + /** + * Handle Stock + * + * @param \Extcode\Cart\Domain\Model\Cart\Cart $cart + */ + public function handleStock(\Extcode\Cart\Domain\Model\Cart\Cart $cart) + { + $data = array( + 'cart' => $cart, + ); + + $signalSlotDispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); + $signalSlotDispatcher->dispatch( + __CLASS__, + 'beforeHandleStock', + array($data) + ); + + foreach ($cart->getProducts() as $cartProduct) { + /** @var $cartProduct \Extcode\Cart\Domain\Model\Cart\Product */ + if (!$cartProduct->getContentId()) { + $productProduct = $this->productProductRepository->findByUid($cartProduct->getProductId()); + if ($productProduct) { + $productProduct->removeFromStock($cartProduct->getQuantity()); + } + $this->productProductRepository->update($productProduct); + } + } + + $this->persistenceManager->persistAll(); + + $data = array( + 'cart' => $cart, + ); + + $signalSlotDispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); + $signalSlotDispatcher->dispatch( + __CLASS__, + 'afterHandleStock', + array($data) + ); + } + + /** + * Handle Payment + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem + * @param \Extcode\Cart\Domain\Model\Cart\Cart $cart + */ + public function handlePayment( + \Extcode\Cart\Domain\Model\Order\Item $orderItem, + \Extcode\Cart\Domain\Model\Cart\Cart $cart + ) { + $payment = $cart->getPayment(); + $provider = $payment->getAdditional('payment_service'); + + $data = array( + 'orderItem' => $orderItem, + 'cart' => $cart, + 'provider' => $provider + ); + + $signalSlotDispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); + $signalSlotDispatcher->dispatch( + __CLASS__, + __FUNCTION__ . + 'AfterOrder', + array($data) + ); + } + + /** + * Adds a Taxes To Order + * + * @param string $type Type of the Tax + * + * @return void + */ + protected function addTaxes($type = 'Tax') + { + $cartTaxes = call_user_func(array($this->cart, 'get' . $type . 'es')); + foreach ($cartTaxes as $cartTaxKey => $cartTax) { + /** + * Order Tax + * @var $orderTax \Extcode\Cart\Domain\Model\Order\Tax + */ + $orderTax = new \Extcode\Cart\Domain\Model\Order\Tax( + $cartTax, + $this->taxClasses[$cartTaxKey] + ); + $orderTax->setPid($this->storagePid); + + $this->taxRepository->add($orderTax); + + call_user_func(array($this->orderItem, 'add' . $type), $orderTax); + } + } + + /** + * Add TaxClasses to Order Item + * + * @return void + */ + protected function addTaxClasses() + { + foreach ($this->cart->getTaxClasses() as $taxClass) { + /** + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass + */ + /** + * @var \Extcode\Cart\Domain\Model\Order\TaxClass $orderTaxClass + */ + $orderTaxClass = new \Extcode\Cart\Domain\Model\Order\TaxClass( + $taxClass->getTitle(), + $taxClass->getValue(), + $taxClass->getCalc() + ); + $orderTaxClass->setPid($this->storagePid); + + $this->taxClassRepository->add($orderTaxClass); + + $this->orderItem->addTaxClass($orderTaxClass); + + $this->taxClasses[$taxClass->getId()] = $orderTaxClass; + } + } + + /** + * Add Coupons to Order Item + */ + protected function addCoupons() + { + /** + * @var $cartCoupon \Extcode\Cart\Domain\Model\Cart\Coupon + */ + foreach ($this->cart->getCoupons() as $cartCoupon) { + if ($cartCoupon->getIsUseable()) { + $orderCoupon = new \Extcode\Cart\Domain\Model\Order\Coupon( + $cartCoupon->getTitle(), + $cartCoupon->getCode(), + $cartCoupon->getDiscount(), + $cartCoupon->getTaxClass(), + $cartCoupon->getTax() + ); + $orderCoupon->setPid($this->storagePid); + + $this->couponRepository->add($orderCoupon); + + $this->orderItem->addCoupon($orderCoupon); + } + } + } + + /** + * Add Products to Order Item + * + * @return void + */ + protected function addProducts() + { + /** + * @var $cartProduct \Extcode\Cart\Domain\Model\Cart\Product + */ + foreach ($this->cart->getProducts() as $cartProduct) { + if ($cartProduct->getBeVariants()) { + $this->addProductVariants($cartProduct); + } else { + $this->addProduct($cartProduct); + } + } + } + + /** + * Add CartProduct to Order Item + * + * @param \Extcode\Cart\Domain\Model\Cart\Product $cartProduct + * + * @return void + */ + protected function addProduct(\Extcode\Cart\Domain\Model\Cart\Product $cartProduct) + { + /** + * @var \Extcode\Cart\Domain\Model\Order\Product $orderProduct + */ + $orderProduct = new \Extcode\Cart\Domain\Model\Order\Product( + $cartProduct->getSku(), + $cartProduct->getTitle(), + $cartProduct->getQuantity() + ); + $orderProduct->setPid($this->storagePid); + + $orderProduct->setPrice($cartProduct->getPrice()); + $orderProduct->setGross($cartProduct->getGross()); + $orderProduct->setNet($cartProduct->getNet()); + $orderProduct->setTaxClass($this->taxClasses[$cartProduct->getTaxClass()->getId()]); + $orderProduct->setTax($cartProduct->getTax()); + + $additionalArray = $cartProduct->getAdditionalArray(); + + $data = array( + 'cartProduct' => $cartProduct, + 'orderProduct' => &$orderProduct, + 'additionalArray' => &$additionalArray, + 'storagePid' => $this->storagePid, + ); + + $signalSlotDispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); + $signalSlotDispatcher->dispatch( + __CLASS__, + __FUNCTION__ . + 'BeforeSetAdditionalData', + array($data) + ); + + $orderProduct->setAdditionalData(json_encode($data['additionalArray'])); + + $this->productRepository->add($orderProduct); + + $this->orderItem->addProduct($orderProduct); + + $this->addFeVariants($orderProduct, $cartProduct->getFeVariant()); + } + + /** + * @param \Extcode\Cart\Domain\Model\Order\Product $product + * @param \Extcode\Cart\Domain\Model\Cart\FeVariant $feVariant + */ + protected function addFeVariants( + \Extcode\Cart\Domain\Model\Order\Product $product, + \Extcode\Cart\Domain\Model\Cart\FeVariant $feVariant = null + ) { + if ($feVariant) { + $feVariantsData = $feVariant->getVariantData(); + if ($feVariantsData) { + foreach ($feVariantsData as $feVariant) { + $this->addProductAdditional('FeVariant', $product, $feVariant); + } + } + } + } + + /** + * @param string $type + * @param \Extcode\Cart\Domain\Model\Order\Product $product + * @param array $feVariant + */ + protected function addProductAdditional( + $productAdditionalType, + \Extcode\Cart\Domain\Model\Order\Product $product, + $feVariant + ) { + /** + * @var \Extcode\Cart\Domain\Model\Order\ProductAdditional $productAdditional + */ + $productAdditional = new \Extcode\Cart\Domain\Model\Order\ProductAdditional( + $productAdditionalType, + $feVariant['sku'], + $feVariant['value'], + $feVariant['title'] + ); + $productAdditional->setPid($this->storagePid); + + $this->productAdditionalRepository->add($productAdditional); + + $product->addProductAdditional($productAdditional); + } + + + /** + * Adds Variants of a CartProduct to Order Item + * + * @param \Extcode\Cart\Domain\Model\Cart\Product $product CartProduct + * + * @return void + */ + protected function addProductVariants(\Extcode\Cart\Domain\Model\Cart\Product $product) + { + foreach ($product->getBeVariants() as $variant) { + /** + * Cart Variant + * @var \Extcode\Cart\Domain\Model\Cart\BeVariant $variant + */ + if ($variant->getBeVariants()) { + $this->addVariantsOfVariant($variant, 1); + } else { + $this->addBeVariant($variant, 1); + } + } + } + + /** + * Adds Variants of a Variant to Order Item + * + * @param \Extcode\Cart\Domain\Model\Cart\BeVariant $variant + * @param int $level Level + * + * @return void + */ + protected function addVariantsOfVariant(\Extcode\Cart\Domain\Model\Cart\BeVariant $variant, $level) + { + $level += 1; + + foreach ($variant->getBeVariants() as $variantInner) { + /** + * Cart Variant Inner + * @var \Extcode\Cart\Domain\Model\Cart\BeVariant $variantInner + */ + if ($variantInner->getBeVariants()) { + $this->addVariantsOfVariant($variantInner, $level); + } else { + $this->addBeVariant($variantInner, $level); + } + } + } + + /** + * Adds a Variant to Order Item + * + * @param \Extcode\Cart\Domain\Model\Cart\BeVariant $variant + * @param int $level Level + * + * @return void + */ + protected function addBeVariant(\Extcode\Cart\Domain\Model\Cart\BeVariant $variant, $level) + { + /** @var \Extcode\Cart\Domain\Model\Order\Tax $orderTax */ + $orderTax = new \Extcode\Cart\Domain\Model\Order\Tax( + $variant->getTax(), + $this->taxClasses[$variant->getTaxClass()->getId()] + ); + $orderTax->setPid($this->storagePid); + + $this->taxRepository->add($orderTax); + + /** + * Order Product + * @var \Extcode\Cart\Domain\Model\Order\Product $orderProduct + */ + $orderProduct = new \Extcode\Cart\Domain\Model\Order\Product( + $variant->getSku(), + $variant->getTitle(), + $variant->getQuantity() + ); + $orderProduct->setPid($this->storagePid); + + $skuWithVariants = array(); + $titleWithVariants = array(); + + $variantInner = $variant; + for ($count = $level; $count > 0; $count--) { + $skuWithVariants['variantsku' . $count] = $variantInner->getSku(); + $titleWithVariants['varianttitle' . $count] = $variantInner->getTitle(); + + if ($count > 1) { + $variantInner = $variantInner->getParentBeVariant(); + } else { + $cartProduct = $variantInner->getProduct(); + } + } + unset($variantInner); + + $skuWithVariants['sku'] = $cartProduct->getSku(); + $titleWithVariants['title'] = $cartProduct->getTitle(); + + $orderProduct->setPrice($variant->getPrice()); + $orderProduct->setDiscount($variant->getDiscount()); + $orderProduct->setGross($variant->getGross()); + $orderProduct->setNet($variant->getNet()); + $orderProduct->setTaxClass($this->taxClasses[$variant->getTaxClass()->getId()]); + $orderProduct->setTax($variant->getTax()); + + if (!$orderProduct->_isDirty()) { + $this->productRepository->add($orderProduct); + } + + $this->addFeVariants($orderProduct, $cartProduct->getFeVariant()); + + $variantInner = $variant; + for ($count = $level; $count > 0; $count--) { + /** + * @var \Extcode\Cart\Domain\Model\Order\ProductAdditional $productAdditional + */ + $orderProductAdditional = new \Extcode\Cart\Domain\Model\Order\ProductAdditional( + 'variant_' . $count, + $variantInner->getSku(), + $variantInner->getTitle() + ); + $orderProductAdditional->setPid($this->storagePid); + + $this->productAdditionalRepository->add($orderProductAdditional); + + $orderProduct->addProductAdditional($orderProductAdditional); + + if ($count > 1) { + $variantInner = $variantInner->getParentBeVariant(); + } else { + $cartProduct = $variantInner->getProduct(); + } + } + unset($variantInner); + + $additionalArray = $cartProduct->getAdditionalArray(); + + $data = array( + 'cartProduct' => $cartProduct, + 'orderProduct' => &$orderProduct, + 'additionalArray' => &$additionalArray, + 'storagePid' => $this->storagePid, + ); + + $signalSlotDispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); + $signalSlotDispatcher->dispatch( + __CLASS__, + __FUNCTION__ . + 'BeforeSetAdditionalData', + array($data) + ); + + $orderProduct->setAdditionalData(json_encode($data['additionalArray'])); + + $this->productRepository->add($orderProduct); + + $this->orderItem->addProduct($orderProduct); + } + + /** + * Add Billing Address + * + * @param array $billingAddress Data for Billing Address + * + * @return void + */ + protected function addBillingAddress(array $billingAddress) + { + /** + * Order Address + * @var \Extcode\Cart\Domain\Model\Order\Address $orderAddress + */ + $orderAddress = $this->objectManager->get('Extcode\\Cart\\Domain\\Model\\Order\\Address'); + $orderAddress->setPid($this->storagePid); + + if ($billingAddress['title']) { + $orderAddress->setTitle($billingAddress['title']); + } + $orderAddress->setSalutation($billingAddress['salutation']); + $orderAddress->setFirstName($billingAddress['firstName']); + $orderAddress->setLastName($billingAddress['lastName']); + + $this->addressRepository->add($orderAddress); + + $this->orderItem->setBillingAddress($orderAddress); + } + + /** + * Add Shipping Address + * + * @param array $shippingAddress Data for Shipping Address + * + * @return void + */ + protected function addShippingAddress(array $shippingAddress) + { + /** + * Order Address + * @var \Extcode\Cart\Domain\Model\Order\Address $orderAddress + */ + $orderAddress = $this->objectManager->get('Extcode\\Cart\\Domain\\Model\\Order\\Address'); + $orderAddress->setPid($this->storagePid); + + if ($shippingAddress['title']) { + $orderAddress->setTitle($shippingAddress['title']); + } + $orderAddress->setSalutation($shippingAddress['salutation']); + $orderAddress->setFirstName($shippingAddress['firstName']); + $orderAddress->setLastName($shippingAddress['lastName']); + + $this->addressRepository->add($orderAddress); + + $this->orderItem->setBillingAddress($orderAddress); + } + + /** + * Add Payment + * + * @return void + */ + protected function addPayment() + { + $payment = $this->cart->getPayment(); + + /** + * Order Payment + * @var $orderPayment \Extcode\Cart\Domain\Model\Order\Payment + */ + $orderPayment = $this->objectManager->get('Extcode\\Cart\\Domain\\Model\\Order\\Payment'); + $orderPayment->setPid($this->storagePid); + + $orderPayment->setName($payment->getName()); + $orderPayment->setProvider($payment->getProvider()); + $orderPayment->setStatus($payment->getStatus()); + $orderPayment->setGross($payment->getGross()); + $orderPayment->setNet($payment->getNet()); + $orderPayment->setTaxClass($this->taxClasses[$payment->getTaxClass()->getId()]); + $orderPayment->setTax($payment->getTax()); + + $this->paymentRepository->add($orderPayment); + + $this->orderItem->setPayment($orderPayment); + } + + /** + * 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->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()); + + $this->shippingRepository->add($orderShipping); + + $this->orderItem->setShipping($orderShipping); + } + + /** + * Get Order Number + * + * @param array $pluginSettings TypoScript Plugin Settings + * + * @return int + */ + protected function getOrderNumber(array $pluginSettings) + { + /** + * @var \TYPO3\CMS\Extbase\Service\TypoScriptService $typoScriptService + */ + $typoScriptService = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService'); + $pluginTypoScriptSettings = $typoScriptService->convertPlainArrayToTypoScriptArray($pluginSettings); + + $registry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry'); + + $registryName = 'lastOrder_' . $pluginSettings['settings']['cart']['pid']; + + $orderNumber = $registry->get('tx_cart', $registryName); + $orderNumber = $orderNumber ? $orderNumber + 1 : 1; + $registry->set('tx_cart', $registryName, $orderNumber); + + $cObjRenderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); + $cObjRenderer->start(array('orderNumber' => $orderNumber)); + $orderNumber = $cObjRenderer->cObjGetSingle( + $pluginTypoScriptSettings['orderNumber'], + $pluginTypoScriptSettings['orderNumber.'] + ); + + return $orderNumber; + } + + /** + * Get Invoice Number + * + * @param array $pluginSettings TypoScript Plugin Settings + * + * @return int + */ + public function getInvoiceNumber(array $pluginSettings) + { + /** + * @var \TYPO3\CMS\Extbase\Service\TypoScriptService $typoScriptService + */ + $typoScriptService = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService'); + $pluginTypoScriptSettings = $typoScriptService->convertPlainArrayToTypoScriptArray($pluginSettings); + + + $registry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry'); + + $registryName = 'lastInvoice_' . $pluginSettings['settings']['cart']['pid']; + + $invoiceNumber = $registry->get('tx_cart', $registryName); + $invoiceNumber = $invoiceNumber ? $invoiceNumber + 1 : 1; + $registry->set('tx_cart', $registryName, $invoiceNumber); + + $cObjRenderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); + $cObjRenderer->start(array('invoiceNumber' => $invoiceNumber)); + $invoiceNumber = $cObjRenderer->cObjGetSingle( + $pluginTypoScriptSettings['invoiceNumber'], + $pluginTypoScriptSettings['invoiceNumber.'] + ); + + return $invoiceNumber; + } +} diff --git a/Classes/Utility/ParserUtility.php b/Classes/Utility/ParserUtility.php new file mode 100644 index 00000000..b36b0c01 --- /dev/null +++ b/Classes/Utility/ParserUtility.php @@ -0,0 +1,261 @@ + + */ +class ParserUtility +{ + + /** + * Plugin Settings + * + * @var array + */ + protected $pluginSettings; + + /** + * Parse Tax Classes + * + * @param array $pluginSettings Plugin Settings + * + * @return array $taxes + */ + public function parseTaxClasses(array $pluginSettings) + { + $taxClasses = array(); + + if (isset($pluginSettings['taxClassRepository']) && is_array($pluginSettings['taxClassRepository'])) { + $taxClasses = $this->parseTaxClassesFromRepository($pluginSettings['taxClassRepository']); + } elseif (isset($pluginSettings['taxClasses']) && is_array($pluginSettings['taxClasses'])) { + $taxClasses = $this->parseTaxClassesFromTypoScript($pluginSettings['taxClasses']); + } + + return $taxClasses; + } + + /** + * Parse Tax Classes From TypoScript + * + * @param array $taxClassSettings TypoScript Tax Class Settings + * + * @return array $taxes + */ + protected function parseTaxClassesFromTypoScript(array $taxClassSettings) + { + $taxClasses = array(); + + foreach ($taxClassSettings as $taxClassKey => $taxClassValue) { + $taxClasses[$taxClassKey] = new \Extcode\Cart\Domain\Model\Cart\TaxClass( + $taxClassKey, + $taxClassValue['value'], + $taxClassValue['calc'], + $taxClassValue['name'] + ); + } + + return $taxClasses; + } + + /** + * Parse Tax Classes From Repository + * + * @param array $taxClassRepositorySettings TypoScript Tax Class Settings + * + * @return array $taxes + */ + protected function parseTaxClassesFromRepository(array $taxClassRepositorySettings) + { + $taxes = array(); + + $objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager'); + $taxClassRepository = $objectManager->get($taxClassRepositorySettings['class']); + $taxClassObjects = $taxClassRepository->findAll(); + + foreach ($taxClassObjects as $taxClassObject) { + $taxClassId = $taxClassObject->$taxClassRepositorySettings['fields']['getId'](); + $taxClassValue = $taxClassObject->$taxClassRepositorySettings['fields']['getValue'](); + $taxClassCalc = $taxClassObject->$taxClassRepositorySettings['fields']['getCalc'](); + $taxClassName = $taxClassObject->$taxClassRepositorySettings['fields']['getTitle'](); + + $taxes[$taxClassId] = new \Extcode\Cart\Domain\Model\Cart\TaxClass( + $taxClassId, + $taxClassValue, + $taxClassCalc, + $taxClassName + ); + } + + return $taxes; + } + + /** + * 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 = array(); + $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']); + 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); + } + + $service->setFreeFrom($value['free']['from']); + $service->setFreeUntil($value['free']['until']); + $service->setAvailableFrom($value['available']['from']); + $service->setAvailableUntil($value['available']['until']); + + if ($pluginSettings[$type]['preset'] == $key) { + $service->setIsPreset(true); + } + + $additional = array(); + 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; + } + + /** + * @param array $pluginSettings + * @param Request $request Request + * + * @return array + */ + public function getPreCartProductSet(array $pluginSettings, Request $request) + { + if (!$this->pluginSettings) { + $this->pluginSettings = $pluginSettings; + } + + $productValueSet = array(); + + if ($request->hasArgument('productId')) { + $productValueSet['productId'] = intval($request->getArgument('productId')); + } + if ($request->hasArgument('tableId')) { + $productValueSet['tableId'] = intval($request->getArgument('tableId')); + } + if ($request->hasArgument('repositoryId')) { + $productValueSet['repositoryId'] = intval($request->getArgument('repositoryId')); + } + if ($request->hasArgument('contentId')) { + $productValueSet['contentId'] = intval($request->getArgument('contentId')); + } + if ($request->hasArgument('quantity')) { + $quantity = intval($request->getArgument('quantity')); + $productValueSet['quantity'] = $quantity ? $quantity : 1; + } + + if ($request->hasArgument('feVariants')) { + $requestFeVariants = $request->getArgument('feVariants'); + if (is_array($requestFeVariants)) { + foreach ($requestFeVariants as $requestFeVariantKey => $requestFeVariantValue) { + $productValueSet['feVariants'][$requestFeVariantKey] = $requestFeVariantValue; + } + } + } + + if ($request->hasArgument('beVariants')) { + $requestVariants = $request->getArgument('beVariants'); + if (is_array($requestVariants)) { + foreach ($requestVariants as $requestVariantKey => $requestVariantValue) { + $productValueSet['beVariants'][$requestVariantKey] = intval($requestVariantValue); + } + } + } + + return $productValueSet; + } +} diff --git a/Classes/ViewHelpers/CsvHeaderViewHelper.php b/Classes/ViewHelpers/CsvHeaderViewHelper.php new file mode 100644 index 00000000..c6ff772e --- /dev/null +++ b/Classes/ViewHelpers/CsvHeaderViewHelper.php @@ -0,0 +1,47 @@ + + */ +class CsvHeaderViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper +{ + /** + * Format OrderItem to CSV format + * + * @param string $delim + * @param string $quote + * @return string + */ + public function render($delim = ',', $quote = '"') + { + + $orderItemArr = array(); + + $orderItemArr[] = 'FirstName'; + $orderItemArr[] = 'LastName'; + $orderItemArr[] = 'OrderNumber'; + $orderItemArr[] = 'InvoiceNumber'; + + return GeneralUtility::csvValues($orderItemArr, $delim, $quote); + } +} diff --git a/Classes/ViewHelpers/CsvValuesViewHelper.php b/Classes/ViewHelpers/CsvValuesViewHelper.php new file mode 100644 index 00000000..3c97f4e7 --- /dev/null +++ b/Classes/ViewHelpers/CsvValuesViewHelper.php @@ -0,0 +1,48 @@ + + */ +class CsvValuesViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper +{ + /** + * Format OrderItem to CSV format + * + * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem Order Item + * @param string $delim Delimiter + * @param string $quote Quote Style + * + * @return string + */ + public function render(\Extcode\Cart\Domain\Model\Order\Item $orderItem, $delim = ',', $quote = '"') + { + $orderItemArr = array(); + + $orderItemArr[] = $orderItem->getBillingAddress()->getSalutation(); + $orderItemArr[] = $orderItem->getBillingAddress()->getTitle(); + $orderItemArr[] = $orderItem->getBillingAddress()->getFirstName(); + $orderItemArr[] = $orderItem->getBillingAddress()->getLastName(); + $orderItemArr[] = $orderItem->getOrderNumber(); + $orderItemArr[] = $orderItem->getInvoiceNumber(); + + return \TYPO3\CMS\Core\Utility\GeneralUtility::csvValues($orderItemArr, $delim, $quote); + } +} diff --git a/Classes/ViewHelpers/FieldNameViewHelper.php b/Classes/ViewHelpers/FieldNameViewHelper.php new file mode 100644 index 00000000..bf688a49 --- /dev/null +++ b/Classes/ViewHelpers/FieldNameViewHelper.php @@ -0,0 +1,71 @@ + + */ +class FieldNameViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper +{ + + public function initializeArguments() + { + parent::initializeArguments(); + + $this->registerArgument('product', '\Extcode\Cart\Domain\Model\Cart\Product', 'product', false, 0); + $this->registerArgument('variant', '\Extcode\Cart\Domain\Model\Cart\BeVariant', 'variant', false, 0); + } + + public function render() + { + $fieldName = ''; + + if ($this->arguments['product']) { + $product = $this->arguments['product']; + $fieldName = '[' . $product->getId() . ']'; + } + if ($this->arguments['variant']) { + $variant = $this->arguments['variant']; + $fieldName = $this->getVariantFieldName($variant); + } + + return $fieldName; + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\BeVariant $variant + * + * @return string + */ + protected function getVariantFieldName($variant) + { + $fieldName = ''; + + if ($variant->getParentBeVariant()) { + $fieldName .= $this->getVariantFieldName($variant->getParentBeVariant()); + } + if ($variant->getProduct()) { + $fieldName .= '[' . $variant->getProduct()->getId() . ']'; + } + + $fieldName .= '[' . $variant->getId() . ']'; + + return $fieldName; + } +} diff --git a/Classes/ViewHelpers/Form/VariantSelectViewHelper.php b/Classes/ViewHelpers/Form/VariantSelectViewHelper.php new file mode 100644 index 00000000..fc35d980 --- /dev/null +++ b/Classes/ViewHelpers/Form/VariantSelectViewHelper.php @@ -0,0 +1,63 @@ + + */ +class VariantSelectViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper +{ + /** + * render + * + * @param string $name + * @param \Extcode\Cart\Domain\Model\Product\Product $product + * @return array + */ + public function render($name = '', \Extcode\Cart\Domain\Model\Product\Product $product) + { + $out = ''; + + $out .= ''; + + return $out; + } +} diff --git a/Classes/ViewHelpers/Form/VariantSetSelectViewHelper.php b/Classes/ViewHelpers/Form/VariantSetSelectViewHelper.php new file mode 100644 index 00000000..3bfdd0a1 --- /dev/null +++ b/Classes/ViewHelpers/Form/VariantSetSelectViewHelper.php @@ -0,0 +1,47 @@ + + */ +class BeVariantAttributeSelectViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper +{ + /** + * render + * + * @param string $name + * @param \Extcode\Cart\Domain\Model\Product\BeVariantAttribute $productBeVariantAttribute + * @return array + */ + public function render($name = '', \Extcode\Cart\Domain\Model\Product\BeVariantAttribute $productBeVariantAttribute) + { + $out = ''; + + $out .= ''; + + return $out; + } +} diff --git a/Classes/ViewHelpers/IncludeFileViewHelper.php b/Classes/ViewHelpers/IncludeFileViewHelper.php new file mode 100644 index 00000000..8da91511 --- /dev/null +++ b/Classes/ViewHelpers/IncludeFileViewHelper.php @@ -0,0 +1,50 @@ + + */ +class IncludeFileViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper +{ + + /** + * Include a CSS/JS file + * + * @param string $path Path to the CSS/JS file which should be included + * @param boolean $compress Define if file should be compressed + * @return void + */ + public function render($path, $compress = false) + { + $pageRenderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Page\\PageRenderer'); + if (TYPO3_MODE === 'FE') { + $path = $GLOBALS['TSFE']->tmpl->getFileName($path); + } + + if (strtolower(substr($path, -3)) === '.js') { + $pageRenderer->addJsFile($path, null, $compress); + } elseif (strtolower(substr($path, -4)) === '.css') { + $pageRenderer->addCssFile($path, 'stylesheet', 'all', '', $compress); + } + } + +} \ No newline at end of file diff --git a/Classes/ViewHelpers/Link/ActionViewHelper.php b/Classes/ViewHelpers/Link/ActionViewHelper.php new file mode 100644 index 00000000..a6a382f8 --- /dev/null +++ b/Classes/ViewHelpers/Link/ActionViewHelper.php @@ -0,0 +1,112 @@ + + */ +class ActionViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\ActionViewHelper +{ + + public function initializeArguments() + { + parent::initializeArguments(); + + $this->registerArgument('product', '\Extcode\Cart\Domain\Model\Cart\Product', 'product', false, 0); + $this->registerArgument('beVariant', '\Extcode\Cart\Domain\Model\Cart\BeVariant', 'beVariant', false, 0); + } + + /** + * @param string $action Target action + * @param array $arguments Arguments + * @param string $controller Target controller. If NULL current controllerName is used + * @param string $extensionName Target Extension Name (without "tx_" prefix and no underscores). If NULL the current extension name is used + * @param string $pluginName Target plugin. If empty, the current plugin name is used + * @param integer $pageUid target page. See TypoLink destination + * @param integer $pageType type of the target page. See typolink.parameter + * @param boolean $noCache set this to disable caching for the target page. You should not need this. + * @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this. + * @param string $section the anchor to be added to the URI + * @param string $format The requested format, e.g. ".html + * @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed. + * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments) + * @param boolean $absolute If set, the URI of the rendered link is absolute + * @param boolean $addQueryString If set, the current query parameters will be kept in the URI + * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = true + * @param string $addQueryStringMethod Set which parameters will be kept. Only active if $addQueryString = true + * @return string Rendered link + */ + public function render( + $action = null, + array $arguments = array(), + $controller = null, + $extensionName = null, + $pluginName = null, + $pageUid = null, + $pageType = 0, + $noCache = false, + $noCacheHash = false, + $section = '', + $format = '', + $linkAccessRestrictedPages = false, + array $additionalParams = array(), + $absolute = false, + $addQueryString = false, + array $argumentsToBeExcludedFromQueryString = array(), + $addQueryStringMethod = null + ) { + + $fieldName = ''; + if ($this->arguments['product']) { + $product = $this->arguments['product']; + $fieldName = '[' . $product->getId() . ']'; + } + if ($this->arguments['beVariant']) { + $variant = $this->arguments['beVariant']; + $fieldName = $this->getVariantFieldName($variant); + } + + $additionalParams['tx_cart_cart[product]' . $fieldName] = 1; + + return parent::render($action, $arguments, $controller, $extensionName, $pluginName, $pageUid, $pageType, + $noCache, $noCacheHash, $section, $format, $linkAccessRestrictedPages, $additionalParams, $absolute, + $addQueryString, $argumentsToBeExcludedFromQueryString, $addQueryStringMethod); + } + + /** + * @param \Extcode\Cart\Domain\Model\Cart\BeVariant $variant + * + * @return string + */ + protected function getVariantFieldName($variant) + { + $fieldName = ''; + + if ($variant->getParentBeVariant()) { + $fieldName .= $this->getVariantFieldName($variant->getParentBeVariant()); + } + if ($variant->getProduct()) { + $fieldName .= '[' . $variant->getProduct()->getId() . ']'; + } + + $fieldName .= '[' . $variant->getId() . ']'; + + return $fieldName; + } +} diff --git a/Classes/ViewHelpers/MapModelPropertiesToTableColumnsViewHelper.php b/Classes/ViewHelpers/MapModelPropertiesToTableColumnsViewHelper.php new file mode 100644 index 00000000..ce17c3d2 --- /dev/null +++ b/Classes/ViewHelpers/MapModelPropertiesToTableColumnsViewHelper.php @@ -0,0 +1,63 @@ + + */ +class MapModelPropertiesToTableColumnsViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper +{ + /** + * render + * + * @param string $class + * @param string $table + * @param object $data + * @return array + */ + public function render($class = '', $table = '', $data) + { + $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); + $conf = $configurationManager->getConfiguration( + \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK + ); + + if (isset($conf['persistence']['classes'][$class]['mapping']) && + $conf['persistence']['classes'][$class]['mapping']['tableName'] == $table + ) { + $mapping = array(); + foreach ($conf['persistence']['classes'][$class]['mapping']['columns'] as $tableColumn => $modelPropertyData) { + $modelProperty = $modelPropertyData['mapOnProperty']; + $mapping[$modelProperty] = $tableColumn; + } + + $data = \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getGettableProperties($data); + + foreach ($data as $key => $value) { + if (isset($mapping[$key])) { + unset($data[$key]); + $data[$mapping[$key]] = $value; + } + } + + return $data; + } else { + return $data; + } + } +} diff --git a/Configuration/.htaccess b/Configuration/.htaccess new file mode 100644 index 00000000..896fbc5a --- /dev/null +++ b/Configuration/.htaccess @@ -0,0 +1,2 @@ +Order deny,allow +Deny from all \ No newline at end of file diff --git a/Configuration/FlexForms/CartPlugin.xml b/Configuration/FlexForms/CartPlugin.xml new file mode 100644 index 00000000..efa4d9b7 --- /dev/null +++ b/Configuration/FlexForms/CartPlugin.xml @@ -0,0 +1,47 @@ + + + 1 + + + + + + LLL:EXT:cart/locallang_db.php:tt_content.list_type_pi2 + + array + + + + + + input + + + + + + + + input + + + + + + + + input + + + + + + + + \ No newline at end of file diff --git a/Configuration/FlexForms/ProductPlugin.xml b/Configuration/FlexForms/ProductPlugin.xml new file mode 100644 index 00000000..9f239fba --- /dev/null +++ b/Configuration/FlexForms/ProductPlugin.xml @@ -0,0 +1,196 @@ + + + + + + Optionen + + array + + + + + + select + + + LLL:EXT:cart/Resources/Private/Language/locallang_db.xlf:tx_cart.plugin.products.action.product.list_and_show + Product->list;Product->show + + + LLL:EXT:cart/Resources/Private/Language/locallang_db.xlf:tx_cart.plugin.products.action.product.teaser + Product->teaser + + + LLL:EXT:cart/Resources/Private/Language/locallang_db.xlf:tx_cart.plugin.products.action.product.flexform + Product->flexform + + + + + + + + + 1 + + FIELD:switchableControllerActions:=:Product->teaser + + select + tx_cart_domain_model_product_product + 3 + 1 + 3 + + + + + + + 1 + + FIELD:switchableControllerActions:=:Product->list;Product->show + + select + 50 + sys_category + AND sys_category.sys_language_uid IN (-1, 0) ORDER BY + sys_category.title ASC + + 99 + tree + 10 + + + 1 + 1 + + parent + + + + + + + + + FIELD:switchableControllerActions:=:Product->flexform + + input + int + + 1 + 9999999 + + + + + + + + FIELD:switchableControllerActions:=:Product->flexform + + input + int + + 1 + 9999999 + + + + + + + + FIELD:switchableControllerActions:=:Product->flexform + + input + required + + + + + + + FIELD:switchableControllerActions:=:Product->flexform + + input + + + + + + + FIELD:switchableControllerActions:=:Product->flexform + + check + + + + + + + FIELD:switchableControllerActions:=:Product->flexform + + input + \Extcode\Cart\Utility\EvalPrice + + + + + + + FIELD:switchableControllerActions:=:Product->flexform + + select + + + LLL:EXT:cart/Resources/Private/Language/locallang_db.xlf:tx_cart_flexform_model_product.tax_class_id.1 + 1 + + + LLL:EXT:cart/Resources/Private/Language/locallang_db.xlf:tx_cart_flexform_model_product.tax_class_id.2 + 2 + + + LLL:EXT:cart/Resources/Private/Language/locallang_db.xlf:tx_cart_flexform_model_product.tax_class_id.3 + 3 + + + + + + + + + FIELD:switchableControllerActions:=:Product->flexform + + text + + + + + + + + \ No newline at end of file diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php new file mode 100644 index 00000000..43fbcdcd --- /dev/null +++ b/Configuration/TCA/Overrides/tt_content.php @@ -0,0 +1,5 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_cart', + 'label' => 'uid', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => '', + ], + 'interface' => [ + 'showRecordFieldList' => 'pid, fe_user, was_ordered, order_item, cart', + ], + 'types' => [ + '1' => [ + 'showitem' => + 'pid, fe_user, was_ordered, order_item, cart' + ], + ], + 'palettes' => [ + '1' => ['showitem' => ''], + ], + 'columns' => [ + 'pid' => [ + 'exclude' => 1, + 'config' => [ + 'type' => 'passthrough' + ] + ], + 'fe_user' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_cart.fe_user', + 'config' => [ + 'type' => 'select', + 'readOnly' => 1, + 'foreign_table' => 'fe_users', + 'size' => 1, + 'autoMaxSize' => 1, + 'minitems' => 0, + 'maxitems' => 1, + 'multiple' => 0, + ] + ], + 'was_ordered' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_cart.was_ordered', + 'config' => [ + 'type' => 'check', + ], + ], + 'order_item' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_cart.order_item', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_item', + 'minitems' => 0, + 'maxitems' => 1, + ], + ], + 'cart' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_cart.cart', + 'config' => [ + 'type' => 'text', + 'cols' => 48, + 'rows' => 15, + 'eval' => 'required', + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_order_address.php b/Configuration/TCA/tx_cart_domain_model_order_address.php new file mode 100644 index 00000000..4547a83a --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_order_address.php @@ -0,0 +1,163 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_order_address', + 'label' => 'uid', + 'label_alt' => 'first_name, last_name, street, street_number, zip, city', + 'label_alt_force' => 1, + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => 'first_name, last_name, street, street_number, zip, city', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Order/Address.png' + ], + 'hideTable' => 1, + 'interface' => [ + 'showRecordFieldList' => 'title, salutation, first_name, last_name, email, company, street, zip, city, country, phone, fax', + ], + 'types' => [ + '1' => [ + 'showitem' => 'title, salutation, first_name, last_name, email, company, street, zip, city, country, phone, fax' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + ], + 'columns' => [ + 'title' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.title', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'salutation' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.salutation', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'first_name' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.first_name', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'last_name' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.last_name', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'email' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.email', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'company' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.company', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'street' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.street', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'zip' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.zip', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'city' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.city', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'country' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.country', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'phone' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.phone', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'fax' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_address.fax', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_order_coupon.php b/Configuration/TCA/tx_cart_domain_model_order_coupon.php new file mode 100644 index 00000000..3e1b0bd0 --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_order_coupon.php @@ -0,0 +1,97 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_order_coupon', + 'label' => 'code', + 'label_alt' => 'title', + 'label_alt_force' => 1, + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => 'title', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Order/Coupon.png' + ], + 'hideTable' => 1, + 'interface' => [ + 'showRecordFieldList' => 'title, code, discount, tax_class_id, tax', + ], + 'types' => [ + '1' => [ + 'showitem' => 'title, code, discount, tax_class_id, tax' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + ], + 'columns' => [ + 'title' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_coupon.title', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'code' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_coupon.code', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'discount' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_coupon.discount', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'tax_class_id' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_order_coupon.tax_class_id', + 'config' => [ + 'type' => 'select', + 'items' => [ + [$_LLL . ':tx_cart_domain_model_order_coupon.tax_class_id.1', 1], + ], + 'size' => 1, + 'minitems' => 1, + 'maxitems' => 1, + ], + ], + 'tax' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_coupon.tax', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'item' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_order_item.php b/Configuration/TCA/tx_cart_domain_model_order_item.php new file mode 100644 index 00000000..aa8cc3a0 --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_order_item.php @@ -0,0 +1,469 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_order_item', + 'label' => 'order_number', + 'label_alt' => 'invoice_number', + 'label_alt_force' => 1, + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => 'order_number, invoice_number', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Order/Item.png' + ], + 'interface' => [ + 'showRecordFieldList' => 'pid, fe_user, order_number, invoice_number, billing_address, shipping_address, gross, net, total_gross, total_net, additional_data, tax_class, products, coupons, tax, total_tax, payment, shipping, order_pdf, invoice_pdf', + ], + 'types' => [ + '1' => [ + 'showitem' => + 'pid, fe_user, + --palette--;' . $_LLL . ':tx_cart_domain_model_order_item.palettes.numbers;numbers, + --palette--;' . $_LLL . ':tx_cart_domain_model_order_item.palettes.addresses;addresses, + --palette--;' . $_LLL . ':tx_cart_domain_model_order_item.palettes.price;price, + --palette--;' . $_LLL . ':tx_cart_domain_model_order_item.palettes.total_price;total_price, + additional_data, + tax_class, + products, + coupons, + payment, + shipping, + order_pdf, + invoice_pdf' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + 'addresses' => [ + 'showitem' => 'billing_address, shipping_address', + 'canNotCollapse' => 0 + ], + 'numbers' => [ + 'showitem' => 'order_number, order_date, --linebreak--, invoice_number, invoice_date', + 'canNotCollapse' => 1 + ], + 'price' => [ + 'showitem' => 'currency, gross, net, --linebreak--, order_tax', + 'canNotCollapse' => 1 + ], + 'total_price' => [ + 'showitem' => 'total_gross, total_net, --linebreak--, order_total_tax', + 'canNotCollapse' => 1 + ], + ], + 'columns' => [ + 'pid' => [ + 'exclude' => 1, + 'config' => [ + 'type' => 'passthrough' + ] + ], + 'fe_user' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.fe_user', + 'config' => [ + 'type' => 'select', + 'readOnly' => 1, + 'foreign_table' => 'fe_users', + 'size' => 1, + 'items' => [ + [$_LLL . ':tx_cart_domain_model_order_item.fe_user.not_available', 0], + ], + 'minitems' => 0, + 'maxitems' => 1, + ] + ], + 'order_number' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.order_number', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'order_date' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.order_date', + 'config' => [ + 'type' => 'input', + 'size' => '8', + 'max' => '20', + 'eval' => 'date', + 'checkbox' => '0', + 'default' => '0' + ] + ], + 'invoice_number' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.invoice_number', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'invoice_date' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.invoice_date', + 'config' => [ + 'type' => 'input', + 'size' => '8', + 'max' => '20', + 'eval' => 'date', + 'checkbox' => '0', + 'default' => '0' + ] + ], + 'billing_address' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.billing_address', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_address', + 'minitems' => 1, + 'maxitems' => 1, + 'appearance' => [ + 'enabledControls' => [ + 'info' => false, + 'new' => false, + 'dragdrop' => false, + 'sort' => false, + 'hide' => false, + 'delete' => false, + 'localize' => false, + ], + ], + ], + ], + 'shipping_address' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.shipping_address', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_address', + 'minitems' => 0, + 'maxitems' => 1, + 'appearance' => [ + 'enabledControls' => [ + 'info' => false, + 'new' => false, + 'dragdrop' => false, + 'sort' => false, + 'hide' => false, + 'delete' => false, + 'localize' => false, + ], + ], + ], + ], + 'additional_data' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.additional_data', + 'config' => [ + 'type' => 'text', + 'readOnly' => 1, + 'cols' => 48, + 'rows' => 15, + 'appearance' => [ + 'enabledControls' => [ + 'info' => false, + 'new' => false, + 'dragdrop' => false, + 'sort' => false, + 'hide' => false, + 'delete' => false, + 'localize' => false, + ], + ], + ], + ], + 'description1' => [ + 'exclude' => 0, + 'defaultExtras' => 'richtext[*]', + 'label' => $_LLL . ':tx_cart_domain_model_order_item.description1', + 'config' => [ + 'type' => 'text', + 'cols' => 48, + 'rows' => 15, + 'eval' => 'required', + 'wizards' => [ + '_PADDING' => 4, + 'RTE' => [ + 'notNewRecords' => 1, + 'RTEonly' => 1, + 'type' => 'script', + 'title' => 'LLL:EXT:cms/locallang_ttc.php:bodytext.W.RTE', + 'icon' => 'wizard_rte2.gif', + 'script' => 'wizard_rte.php' + ] + ] + ], + ], + 'tax_class' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.tax_class', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_taxclass', + 'foreign_field' => 'item', + 'maxitems' => 9999, + 'appearance' => [ + 'collapseAll' => 1, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1, + 'enabledControls' => [ + 'info' => false, + 'new' => false, + 'dragdrop' => false, + 'sort' => false, + 'hide' => false, + 'delete' => false, + 'localize' => false, + ], + ], + ], + ], + 'currency' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.currency', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'required' + ], + ], + 'gross' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.gross', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2,required' + ], + ], + 'total_gross' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.total_gross', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2,required' + ], + ], + 'net' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.net', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2,required' + ], + ], + 'total_net' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.total_net', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2,required' + ], + ], + 'tax' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.tax', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_tax', + 'maxitems' => 9999, + ], + ], + 'total_tax' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.total_tax', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_tax', + 'maxitems' => 9999, + ], + ], + 'products' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.products', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_product', + 'foreign_field' => 'item', + 'maxitems' => 9999, + 'appearance' => [ + 'collapseAll' => 1, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1, + 'enabledControls' => [ + 'info' => false, + 'new' => false, + 'dragdrop' => false, + 'sort' => false, + 'hide' => false, + 'delete' => false, + 'localize' => false, + ], + ], + ], + ], + 'coupons' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.coupons', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_coupon', + 'foreign_field' => 'item', + 'maxitems' => 9999, + 'appearance' => [ + 'collapseAll' => 1, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1, + 'enabledControls' => [ + 'info' => false, + 'new' => false, + 'dragdrop' => false, + 'sort' => false, + 'hide' => false, + 'delete' => false, + 'localize' => false, + ], + ], + ], + ], + 'payment' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.payment', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_payment', + 'minitems' => 0, + 'maxitems' => 1, + 'appearance' => [ + 'collapseAll' => 1, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1, + 'enabledControls' => [ + 'info' => false, + 'new' => false, + 'dragdrop' => false, + 'sort' => false, + 'hide' => false, + 'delete' => false, + 'localize' => false, + ], + ], + ], + ], + 'shipping' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.shipping', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_shipping', + 'minitems' => 0, + 'maxitems' => 1, + 'appearance' => [ + 'collapseAll' => 1, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1, + 'enabledControls' => [ + 'info' => false, + 'new' => false, + 'dragdrop' => false, + 'sort' => false, + 'hide' => false, + 'delete' => false, + 'localize' => false, + ], + ], + ], + ], + 'order_pdf' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.order_pdf', + 'config' => [ + 'type' => 'group', + 'readOnly' => 1, + 'internal_type' => 'file_reference', + 'uploadfolder' => 'uploads/tx_cart/order_pdf/', + 'allowed' => 'pdf', + 'disallowed' => 'php', + 'size' => 1, + 'minitems' => 0, + 'maxitems' => 1, + ], + ], + 'invoice_pdf' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.invoice_pdf', + 'config' => [ + 'type' => 'group', + 'readOnly' => 1, + 'internal_type' => 'file_reference', + 'uploadfolder' => 'uploads/tx_cart/invoice_pdf/', + 'allowed' => 'pdf', + 'disallowed' => 'php', + 'size' => 1, + 'minItems' => 0, + 'maxItems' => 1, + ], + ], + 'crdate' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'config' => [ + 'type' => 'input', + 'size' => '8', + 'max' => '20', + 'eval' => 'date', + 'checkbox' => '0', + 'default' => '0' + ] + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_order_payment.php b/Configuration/TCA/tx_cart_domain_model_order_payment.php new file mode 100644 index 00000000..ff6620c0 --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_order_payment.php @@ -0,0 +1,157 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_order_payment', + 'label' => 'name', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => 'name,value,calc,sum,', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Order/Payment.png' + ], + 'hideTable' => 1, + 'interface' => [ + 'showRecordFieldList' => 'name, provider, status, gross, net, tax, tax_class, note, transactions', + ], + 'types' => [ + '1' => [ + 'showitem' => 'name, provider, status, gross, net, tax, tax_class, note, transactions' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + ], + 'columns' => [ + 'name' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_payment.name', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'provider' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_payment.provider', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'status' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_payment.status', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + [$_LLL . ':tx_cart_domain_model_order_payment.status.open', 'open'], + [$_LLL . ':tx_cart_domain_model_order_payment.status.pending', 'pending'], + [$_LLL . ':tx_cart_domain_model_order_payment.status.paid', 'paid'], + [$_LLL . ':tx_cart_domain_model_order_payment.status.canceled', 'canceled'] + ], + 'size' => 1, + 'maxitems' => 1, + 'eval' => 'required' + ], + ], + 'gross' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_payment.gross', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'net' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_payment.net', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'tax' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_payment.tax', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'tax_class' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_payment.tax_class', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_taxclass', + 'minitems' => 1, + 'maxitems' => 1, + ], + ], + 'note' => [ + 'label' => $_LLL . ':tx_cart_domain_model_order_payment.note', + 'config' => [ + 'type' => 'text', + 'readOnly' => 1, + 'cols' => '40', + 'rows' => '15' + ] + ], + + 'transactions' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_item.transactions', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_transaction', + 'foreign_field' => 'payment', + 'maxitems' => 9999, + 'appearance' => [ + 'collapseAll' => 1, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1, + 'enabledControls' => [ + 'info' => false, + 'new' => false, + 'dragdrop' => false, + 'sort' => false, + 'hide' => false, + 'delete' => false, + 'localize' => false, + ], + ], + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_order_product.php b/Configuration/TCA/tx_cart_domain_model_order_product.php new file mode 100644 index 00000000..70d749fa --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_order_product.php @@ -0,0 +1,192 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_order_product', + 'label' => 'sku', + 'label_alt' => 'title', + 'label_alt_force' => 1, + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => 'sku,title', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Order/Product.png' + ], + 'hideTable' => 1, + 'interface' => [ + 'showRecordFieldList' => 'sku, title, count, additional_data, product_additional, price, discount, gross, net, tax, tax_class', + ], + 'types' => [ + '1' => [ + 'showitem' => 'sku, title, count, --palette--;' . $_LLL . ':tx_cart_domain_model_order_product.price.group;price, product_additional, additional_data' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + 'price' => [ + 'showitem' => 'price, discount, --linebreak--, gross, net, --linebreak--, tax, tax_class', + 'canNotCollapse' => 1 + ], + ], + 'columns' => [ + 'sku' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_product.sku', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'title' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_product.title', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'count' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_product.count', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'int' + ], + ], + 'price' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_product.price', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'discount' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_product.discount', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'gross' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_product.gross', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'net' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_product.net', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'tax' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_product.tax', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'tax_class' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_product.tax_class', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_taxclass', + 'minitems' => 1, + 'maxitems' => 1, + 'appearance' => [ + 'enabledControls' => [ + 'info' => false, + 'new' => false, + 'dragdrop' => false, + 'sort' => false, + 'hide' => false, + 'delete' => false, + 'localize' => false, + ], + ], + ], + ], + 'additional_data' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_product.additional_data', + 'config' => [ + 'type' => 'text', + 'readOnly' => 1, + 'cols' => 48, + 'rows' => 5 + ], + ], + 'item' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + 'product_additional' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_product.product_additional', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_productadditional', + 'foreign_field' => 'product', + 'maxitems' => 9999, + 'appearance' => [ + 'collapseAll' => 1, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1, + 'enabledControls' => [ + 'info' => false, + 'new' => false, + 'dragdrop' => false, + 'sort' => false, + 'hide' => false, + 'delete' => false, + 'localize' => false, + ], + ], + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_order_productadditional.php b/Configuration/TCA/tx_cart_domain_model_order_productadditional.php new file mode 100644 index 00000000..f3bf61b8 --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_order_productadditional.php @@ -0,0 +1,88 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_order_productadditional', + 'label' => 'additional_type', + 'label_alt' => 'additional_key, additional_value', + 'label_alt_force' => 1, + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => 'additional_type,additional_key,additional_value', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Order/ProductAdditional.png' + ], + 'hideTable' => 1, + 'interface' => [ + 'showRecordFieldList' => 'additional_type, additional_key, additional_value, additional_data', + ], + 'types' => [ + '1' => [ + 'showitem' => 'additional_type, additional_key, additional_value, additional_data' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + ], + 'columns' => [ + 'additional_type' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_productadditional.additional_type', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'additional_key' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_productadditional.additional_key', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'additional_value' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_productadditional.additional_value', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'additional_data' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_productadditional.additional_data', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'product' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_order_shipping.php b/Configuration/TCA/tx_cart_domain_model_order_shipping.php new file mode 100644 index 00000000..24d2a6c4 --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_order_shipping.php @@ -0,0 +1,119 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_order_shipping', + 'label' => 'name', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => 'name,value,calc,sum,', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Order/Shipping.png' + ], + 'hideTable' => 1, + 'interface' => [ + 'showRecordFieldList' => 'name, status, gross, net, tax, tax_class, note', + ], + 'types' => [ + '1' => [ + 'showitem' => 'name, status, gross, net, tax, tax_class, note' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + ], + 'columns' => [ + 'name' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_shipping.name', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'status' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_shipping.status', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + [$_LLL . ':tx_cart_domain_model_order_shipping.status.open', 'open'], + [$_LLL . ':tx_cart_domain_model_order_shipping.status.on_hold', 'on_hold'], + [$_LLL . ':tx_cart_domain_model_order_shipping.status.in_process', 'in_process'], + [$_LLL . ':tx_cart_domain_model_order_shipping.status.shipped', 'shipped'] + ], + 'size' => 1, + 'maxitems' => 1, + 'eval' => 'required' + ], + ], + 'gross' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_shipping.gross', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'net' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_shipping.net', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'tax' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_shipping.tax', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'tax_class' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_shipping.tax_class', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_taxclass', + 'minitems' => 1, + 'maxitems' => 1, + ], + ], + 'note' => [ + 'label' => $_LLL . ':tx_cart_domain_model_order_shipping.note', + 'config' => [ + 'type' => 'text', + 'readOnly' => 1, + 'cols' => '40', + 'rows' => '15' + ] + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_order_tax.php b/Configuration/TCA/tx_cart_domain_model_order_tax.php new file mode 100644 index 00000000..7efe96cd --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_order_tax.php @@ -0,0 +1,63 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_order_tax', + 'label' => 'name', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => '', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Order/Tax.png' + ], + 'hideTable' => 1, + 'interface' => [ + 'showRecordFieldList' => 'tax, tax_class', + ], + 'types' => [ + '1' => [ + 'showitem' => 'tax, tax_class' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + ], + 'columns' => [ + 'tax' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_tax.tax', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'tax_class' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_tax.tax_class', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_order_taxclass', + 'minitems' => 1, + 'maxitems' => 1, + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_order_taxclass.php b/Configuration/TCA/tx_cart_domain_model_order_taxclass.php new file mode 100644 index 00000000..90a83cc5 --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_order_taxclass.php @@ -0,0 +1,76 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_order_taxclass', + 'label' => 'title', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => 'title,value,calc', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Order/TaxClass.png' + ], + 'hideTable' => 1, + 'interface' => [ + 'showRecordFieldList' => 'title, value, calc', + ], + 'types' => [ + '1' => [ + 'showitem' => 'title, value, calc' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + ], + 'columns' => [ + 'title' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_taxclass.title', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'value' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_taxclass.value', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'calc' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_taxclass.calc', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'item' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_order_transaction.php b/Configuration/TCA/tx_cart_domain_model_order_transaction.php new file mode 100644 index 00000000..1d547b7f --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_order_transaction.php @@ -0,0 +1,56 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_order_transaction', + 'label' => 'txn_id', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => 'txn_id', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Order/Transaction.png' + ], + 'hideTable' => 1, + 'interface' => [ + 'showRecordFieldList' => 'txn_id', + ], + 'types' => [ + '1' => [ + 'showitem' => 'txn_id' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + ], + 'columns' => [ + 'txn_id' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_order_transaction.txn_id', + 'config' => [ + 'type' => 'input', + 'readOnly' => 1, + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'payment' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_product_bevariant.php b/Configuration/TCA/tx_cart_domain_model_product_bevariant.php new file mode 100644 index 00000000..47818c62 --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_product_bevariant.php @@ -0,0 +1,287 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_product_bevariant', + 'label' => 'be_variant_attribute_option1', + 'label_alt' => 'be_variant_attribute_option2,be_variant_attribute_option3', + 'label_alt_force' => 1, + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + + 'languageField' => 'sys_language_uid', + 'transOrigPointerField' => 'l10n_parent', + 'transOrigDiffSourceField' => 'l10n_diffsource', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [ + 'disabled' => 'hidden', + 'starttime' => 'starttime', + 'endtime' => 'endtime', + ], + 'searchFields' => 'title', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Product/Variant.png' + ], + 'interface' => [ + 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, be_variant_attribute_option1, be_variant_attribute_option2, be_variant_attribute_option3, stock', + ], + 'types' => [ + '1' => [ + 'showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, + --palette--;' . $_LLL . ':tx_cart_domain_model_product_bevariant.palette.variants;variants, + --div--;' . $_LLL_product . '.div.prices, + --palette--;' . $_LLL_product . '.palette.prices;prices, + --palette--;' . $_LLL_product . '.palette.measure;measure, + stock, + --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access, starttime, endtime' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + 'variants' => [ + 'showitem' => 'be_variant_attribute_option1, be_variant_attribute_option2, be_variant_attribute_option3', + 'canNotCollapse' => 1 + ], + 'prices' => ['showitem' => 'price, price_calc_method', 'canNotCollapse' => 1], + 'measure' => ['showitem' => 'price_measure, price_measure_unit', 'canNotCollapse' => 1], + ], + 'columns' => [ + + 'sys_language_uid' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'foreign_table' => 'sys_language', + 'foreign_table_where' => 'ORDER BY sys_language.title', + 'items' => [ + ['LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1], + ['LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0] + ], + ], + ], + 'l10n_parent' => [ + 'displayCond' => 'FIELD:sys_language_uid:>:0', + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['', 0], + ], + 'foreign_table' => 'tx_cart_domain_model_product_bevariant', + 'foreign_table_where' => 'AND tx_cart_domain_model_product_bevariant.pid=###CURRENT_PID### AND tx_cart_domain_model_product_bevariant.sys_language_uid IN (-1,0)', + ], + ], + 'l10n_diffsource' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + 't3ver_label' => [ + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.versionLabel', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'max' => 255, + ] + ], + 'hidden' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden', + 'config' => [ + 'type' => 'check', + ], + ], + 'starttime' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.starttime', + 'config' => [ + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + ], + ], + 'endtime' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.endtime', + 'config' => [ + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + ], + ], + + 'be_variant_attribute_option1' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariant.be_variant_attribute_option1', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['', 0], + ], + 'foreign_table' => 'tx_cart_domain_model_product_bevariantattributeoption', + 'foreign_table_where' => + ' AND tx_cart_domain_model_product_bevariantattributeoption.pid=###CURRENT_PID###' . + ' AND tx_cart_domain_model_product_bevariantattributeoption.be_variant_attribute IN ((SELECT tx_cart_domain_model_product_product.be_variant_attribute1 FROM tx_cart_domain_model_product_product WHERE tx_cart_domain_model_product_product.uid=###REC_FIELD_product###)) ' . + ' ORDER BY tx_cart_domain_model_product_bevariantattributeoption.title ', + 'minitems' => 0, + 'maxitems' => 1, + ], + ], + + 'be_variant_attribute_option2' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariant.be_variant_attribute_option2', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['', 0], + ], + 'foreign_table' => 'tx_cart_domain_model_product_bevariantattributeoption', + 'foreign_table_where' => + ' AND tx_cart_domain_model_product_bevariantattributeoption.pid=###CURRENT_PID###' . + ' AND tx_cart_domain_model_product_bevariantattributeoption.be_variant_attribute IN ((SELECT tx_cart_domain_model_product_product.be_variant_attribute2 FROM tx_cart_domain_model_product_product WHERE tx_cart_domain_model_product_product.uid=###REC_FIELD_product###)) ' . + ' ORDER BY tx_cart_domain_model_product_bevariantattributeoption.title ', + 'minitems' => 0, + 'maxitems' => 1, + ], + ], + + 'be_variant_attribute_option3' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariant.be_variant_attribute_option3', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['', 0], + ], + 'foreign_table' => 'tx_cart_domain_model_product_bevariantattributeoption', + 'foreign_table_where' => + ' AND tx_cart_domain_model_product_bevariantattributeoption.pid=###CURRENT_PID###' . + ' AND tx_cart_domain_model_product_bevariantattributeoption.be_variant_attribute IN ((SELECT tx_cart_domain_model_product_product.be_variant_attribute3 FROM tx_cart_domain_model_product_product WHERE tx_cart_domain_model_product_product.uid=###REC_FIELD_product###)) ' . + ' ORDER BY tx_cart_domain_model_product_bevariantattributeoption.title ', + 'minitems' => 0, + 'maxitems' => 1, + ], + ], + + 'price' => [ + 'exclude' => 1, + 'label' => $_LLL_product . '.price', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,double2', + 'default' => '0.00', + ] + ], + + 'price_calc_method' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariant.price_calc_method', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + [$_LLL . ':tx_cart_domain_model_product_bevariant.price_calc_method.0', 0], + [$_LLL . ':tx_cart_domain_model_product_bevariant.price_calc_method.1', 1], + [$_LLL . ':tx_cart_domain_model_product_bevariant.price_calc_method.2', 2], + [$_LLL . ':tx_cart_domain_model_product_bevariant.price_calc_method.3', 3], + [$_LLL . ':tx_cart_domain_model_product_bevariant.price_calc_method.4', 4], + [$_LLL . ':tx_cart_domain_model_product_bevariant.price_calc_method.5', 5] + ], + 'size' => 1, + 'minitems' => 0, + 'maxitems' => 1, + ] + ], + + 'price_measure' => [ + 'exclude' => 1, + 'label' => $_LLL_product . '.price_measure', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'double2' + ] + ], + + 'price_measure_unit' => [ + 'exclude' => 1, + 'label' => $_LLL_product . '.price_measure_unit', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + [$_LLL_product . '.measure.no_measuring_unit', 0], + [$_LLL_product . '.measure.weight', '--div--'], + ['mg', 'mg'], + ['g', 'g'], + ['kg', 'kg'], + [$_LLL_product . '.measure.volume', '--div--'], + ['ml', 'ml'], + ['cl', 'cl'], + ['l', 'l'], + ['cbm', 'cbm'], + [$_LLL_product . '.measure.length', '--div--'], + ['cm', 'cm'], + ['m', 'm'], + [$_LLL_product . '.measure.area'], + ['m²', 'm2'], + ], + 'size' => 1, + 'minitems' => 0, + 'maxitems' => 1, + ] + ], + + 'stock' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariant.stock', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,int', + 'default' => 0, + ] + ], + + 'product' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_product_bevariantattribute.php b/Configuration/TCA/tx_cart_domain_model_product_bevariantattribute.php new file mode 100644 index 00000000..304f1a40 --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_product_bevariantattribute.php @@ -0,0 +1,180 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_product_bevariantattribute', + 'label' => 'title', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + + 'languageField' => 'sys_language_uid', + 'transOrigPointerField' => 'l10n_parent', + 'transOrigDiffSourceField' => 'l10n_diffsource', + 'delete' => 'deleted', + 'enablecolumns' => [ + 'disabled' => 'hidden', + 'starttime' => 'starttime', + 'endtime' => 'endtime', + ], + 'searchFields' => 'title,value,calc,', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Product/BeVariantAttribute.png' + ], + 'interface' => [ + 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, sku, title, description, be_variant_attribute_options', + ], + 'types' => [ + '1' => [ + 'showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, sku, title, description;;;richtext:rte_transform[mode=ts_links], be_variant_attribute_options' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + ], + 'columns' => [ + + 'sys_language_uid' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'foreign_table' => 'sys_language', + 'foreign_table_where' => 'ORDER BY sys_language.title', + 'items' => [ + ['LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1], + ['LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0] + ], + ], + ], + 'l10n_parent' => [ + 'displayCond' => 'FIELD:sys_language_uid:>:0', + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['', 0], + ], + 'foreign_table' => 'tx_cart_domain_model_product_bevariantattribute', + 'foreign_table_where' => 'AND tx_cart_domain_model_product_bevariantattribute.pid=###CURRENT_PID### AND tx_cart_domain_model_product_bevariantattribute.sys_language_uid IN (-1,0)', + ], + ], + 'l10n_diffsource' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + 't3ver_label' => [ + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.versionLabel', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'max' => 255, + ] + ], + 'hidden' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden', + 'config' => [ + 'type' => 'check', + ], + ], + 'starttime' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.starttime', + 'config' => [ + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + ], + ], + 'endtime' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.endtime', + 'config' => [ + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + ], + ], + + 'sku' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariantattribute.sku', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,trim' + ], + ], + + 'title' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariantattribute.title', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,trim' + ], + ], + + 'description' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariantattribute.description', + 'config' => [ + 'type' => 'text', + 'cols' => 40, + 'rows' => 15, + 'eval' => 'trim' + ], + 'defaultExtras' => 'richtext[]' + ], + + 'be_variant_attribute_options' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariantattribute.be_variant_attribute_options', + 'config' => [ + 'type' => 'inline', + 'readOnly' => 1, + 'foreign_table' => 'tx_cart_domain_model_product_bevariantattributeoption', + 'foreign_field' => 'be_variant_attribute', + 'foreign_table_where' => ' AND tx_cart_domain_model_product_bevariantattributeoption.pid=###CURRENT_PID### ORDER BY tx_cart_domain_model_product_bevariantattributeoption.title ', + 'maxitems' => 9999, + 'appearance' => [ + 'collapseAll' => 1, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1 + ], + ], + ], + + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_product_bevariantattributeoption.php b/Configuration/TCA/tx_cart_domain_model_product_bevariantattributeoption.php new file mode 100644 index 00000000..3d05a60a --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_product_bevariantattributeoption.php @@ -0,0 +1,167 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_product_bevariantattributeoption', + 'label' => 'title', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + + 'languageField' => 'sys_language_uid', + 'transOrigPointerField' => 'l10n_parent', + 'transOrigDiffSourceField' => 'l10n_diffsource', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [ + 'disabled' => 'hidden', + 'starttime' => 'starttime', + 'endtime' => 'endtime', + ], + 'searchFields' => 'title,', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Product/BeVariantAttributeOption.png' + ], + 'interface' => [ + 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, sku, title, description', + ], + 'types' => [ + '1' => [ + 'showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, sku, title, description;;;richtext:rte_transform[mode=ts_links]' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + ], + 'columns' => [ + + 'sys_language_uid' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'foreign_table' => 'sys_language', + 'foreign_table_where' => 'ORDER BY sys_language.title', + 'items' => [ + ['LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1], + ['LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0] + ], + ], + ], + 'l10n_parent' => [ + 'displayCond' => 'FIELD:sys_language_uid:>:0', + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['', 0], + ], + 'foreign_table' => 'tx_cart_domain_model_product_bevariantattributeoption', + 'foreign_table_where' => 'AND tx_cart_domain_model_product_bevariantattributeoption.pid=###CURRENT_PID### AND tx_cart_domain_model_product_bevariantattributeoption.sys_language_uid IN (-1,0)', + ], + ], + 'l10n_diffsource' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + 't3ver_label' => [ + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.versionLabel', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'max' => 255, + ] + ], + 'hidden' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden', + 'config' => [ + 'type' => 'check', + ], + ], + 'starttime' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.starttime', + 'config' => [ + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + ], + ], + 'endtime' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.endtime', + 'config' => [ + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + ], + ], + + 'sku' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariantattributeoption.sku', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,trim' + ], + ], + + 'title' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariantattributeoption.title', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,trim' + ], + ], + + 'description' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_bevariantattributeoption.description', + 'config' => [ + 'type' => 'text', + 'cols' => 40, + 'rows' => 15, + 'eval' => 'trim' + ], + 'defaultExtras' => 'richtext[]' + ], + + 'be_variant' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_product_coupon.php b/Configuration/TCA/tx_cart_domain_model_product_coupon.php new file mode 100644 index 00000000..150d0816 --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_product_coupon.php @@ -0,0 +1,123 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_product_coupon', + 'label' => 'code', + 'label_alt' => 'title', + 'label_alt_force' => 1, + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + 'origUid' => 't3_origuid', + 'delete' => 'deleted', + 'enablecolumns' => [], + 'searchFields' => 'title', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Product/Coupon.png' + ], + 'hideTable' => 1, + 'interface' => [ + 'showRecordFieldList' => 'title, code, discount, tax_class_id, cart_min_price, is_combinable, is_relative_discount, number_available, number_used', + ], + 'types' => [ + '1' => [ + 'showitem' => 'title, code, discount, tax_class_id, cart_min_price, is_combinable, number_available, number_used' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + ], + 'columns' => [ + 'title' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_product_coupon.title', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'code' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_product_coupon.code', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim,required' + ], + ], + 'discount' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_product_coupon.discount', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'tax_class_id' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_coupon.tax_class_id', + 'config' => [ + 'type' => 'select', + 'items' => [ + [$_LLL . ':tx_cart_domain_model_product_coupon.tax_class_id.1', 1], + ], + 'size' => 1, + 'minitems' => 1, + 'maxitems' => 1, + ], + ], + 'cart_min_price' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_product_coupon.cart_min_price', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'is_combinable' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_coupon.is_combinable', + 'config' => [ + 'type' => 'check', + ], + ], + 'is_relative_discount' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_coupon.is_relative_discount', + 'config' => [ + 'type' => 'check', + ], + ], + 'number_available' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_product_coupon.number_available', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'double2' + ], + ], + 'number_used' => [ + 'exclude' => 0, + 'label' => $_LLL . ':tx_cart_domain_model_product_coupon.number_used', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'double2' + ], + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_product_fevariant.php b/Configuration/TCA/tx_cart_domain_model_product_fevariant.php new file mode 100644 index 00000000..350aaf74 --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_product_fevariant.php @@ -0,0 +1,71 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_product_fevariant', + 'label' => 'title', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [ + 'disabled' => 'hidden', + 'starttime' => 'starttime', + 'endtime' => 'endtime', + ], + 'searchFields' => 'title', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Product/FeVariant.png' + ], + 'interface' => [ + 'showRecordFieldList' => 'hidden, sku, title', + ], + 'types' => [ + '1' => ['showitem' => 'hidden;;1, sku, title, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access'], + ], + 'palettes' => [ + '1' => ['showitem' => ''], + ], + 'columns' => [ + 'hidden' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden', + 'config' => [ + 'type' => 'check', + ], + ], + + 'sku' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_fevariant.sku', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,trim' + ], + ], + + 'title' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_fevariant.title', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,trim' + ], + ], + + 'product' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_product_product.php b/Configuration/TCA/tx_cart_domain_model_product_product.php new file mode 100644 index 00000000..f62999de --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_product_product.php @@ -0,0 +1,555 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_product_product', + 'label' => 'sku', + 'label_alt' => 'title', + 'label_alt_force' => 1, + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + + 'languageField' => 'sys_language_uid', + 'transOrigPointerField' => 'l10n_parent', + 'transOrigDiffSourceField' => 'l10n_diffsource', + 'delete' => 'deleted', + 'enablecolumns' => [ + 'disabled' => 'hidden', + 'starttime' => 'starttime', + 'endtime' => 'endtime', + ], + 'searchFields' => 'sku,title,teaser,description,price,', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Product/Product.png' + ], + 'interface' => [ + 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, sku, title, header_image, teaser, description, min_number_in_order, max_number_in_order, price, special_prices, price_measure, price_measure_unit, base_price_measure_unit, tax_class_id, be_variant_attribute1, be_variant_attribute2, be_variant_attribute3, fe_variants, be_variants, related_products, category', + ], + 'types' => [ + '1' => [ + 'showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, starttime, endtime, + sku, title, + --div--;' . $_LLL . ':tx_cart_domain_model_product_product.div.descriptions, + teaser;;;richtext:rte_transform[mode=ts_links], description;;;richtext:rte_transform[mode=ts_links], + product_content, + --div--;' . $_LLL . ':tx_cart_domain_model_product_product.div.images_and_files, + header_image, images, files, + --div--;' . $_LLL . ':tx_cart_domain_model_product_product.div.prices, + --palette--;' . $_LLL . ':tx_cart_domain_model_product_product.palette.minmax;minmax, + --palette--;' . $_LLL . ':tx_cart_domain_model_product_product.palette.prices;prices, + --palette--;' . $_LLL . ':tx_cart_domain_model_product_product.palette.measures;measures, + --palette--;' . $_LLL . ':tx_cart_domain_model_product_product.palette.stock;stock, + --div--;' . $_LLL . ':tx_cart_domain_model_product_product.div.variants, + fe_variants, + --palette--;' . $_LLL . ':tx_cart_domain_model_product_product.palette.be_variant_attributes;be_variant_attributes, + --div--;' . $_LLL . ':tx_cart_domain_model_product_product.div.related_products, + related_products, + --div--;' . $_LLL . ':tx_cart_domain_model_product_product.div.categories, + categories, ' + ], + ], + 'palettes' => [ + '1' => [ + 'showitem' => '' + ], + 'be_variant_attributes' => [ + 'showitem' => 'be_variant_attribute1, be_variant_attribute2, be_variant_attribute3, --linebreak--, be_variants', + 'canNotCollapse' => 1 + ], + 'minmax' => [ + 'showitem' => 'min_number_in_order, max_number_in_order', + 'canNotCollapse' => 1 + ], + 'prices' => [ + 'showitem' => 'price, tax_class_id, --linebreak--, special_prices', + 'canNotCollapse' => 1 + ], + 'measures' => [ + 'showitem' => 'price_measure, price_measure_unit, base_price_measure_unit', + 'canNotCollapse' => 1 + ], + 'stock' => ['showitem' => 'handle_stock, stock', 'canNotCollapse' => 1], + ], + 'columns' => [ + + 'sys_language_uid' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'foreign_table' => 'sys_language', + 'foreign_table_where' => 'ORDER BY sys_language.title', + 'items' => [ + ['LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1], + ['LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0] + ], + ], + ], + 'l10n_parent' => [ + 'displayCond' => 'FIELD:sys_language_uid:>:0', + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['', 0], + ], + 'foreign_table' => 'tx_cart_domain_model_product_product', + 'foreign_table_where' => 'AND tx_cart_domain_model_product_product.pid=###CURRENT_PID### AND tx_cart_domain_model_product_product.sys_language_uid IN (-1,0)', + ], + ], + 'l10n_diffsource' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + 't3ver_label' => [ + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.versionLabel', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'max' => 255, + ] + ], + 'hidden' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden', + 'config' => [ + 'type' => 'check', + ], + ], + 'starttime' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.starttime', + 'config' => [ + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + ], + ], + 'endtime' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.endtime', + 'config' => [ + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + ], + ], + + 'sku' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.sku', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,trim' + ], + ], + + 'title' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.title', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,trim' + ], + ], + + 'teaser' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.teaser', + 'config' => [ + 'type' => 'text', + 'cols' => 40, + 'rows' => 15, + 'eval' => 'trim' + ], + 'defaultExtras' => 'richtext[]' + ], + + 'description' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.description', + 'config' => [ + 'type' => 'text', + 'cols' => 40, + 'rows' => 15, + 'eval' => 'trim' + ], + 'defaultExtras' => 'richtext[]' + ], + + 'min_number_in_order' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.min_number_in_order', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'int' + ] + ], + + 'max_number_in_order' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.max_number_in_order', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'int' + ] + ], + + 'price' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.price', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,double2', + 'default' => '0.00', + ] + ], + + 'special_prices' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.special_prices', + 'config' => [ + 'type' => 'inline', + 'foreign_table' => 'tx_cart_domain_model_product_specialprice', + 'foreign_field' => 'product', + 'foreign_table_where' => ' AND tx_cart_domain_model_product_specialprice.pid=###CURRENT_PID### ORDER BY tx_cart_domain_model_product_specialprice.title ', + 'maxitems' => 99, + 'appearance' => [ + 'collapseAll' => 1, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1 + ], + ], + ], + + 'price_measure' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.price_measure', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'double2', + 'default' => '0.00', + ] + ], + + 'price_measure_unit' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.price_measure_unit', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + [$_LLL . ':tx_cart_domain_model_product_product.measure.no_measuring_unit', 0], + [$_LLL . ':tx_cart_domain_model_product_product.measure.weight', '--div--'], + ['mg', 'mg'], + ['g', 'g'], + ['kg', 'kg'], + [$_LLL . ':tx_cart_domain_model_product_product.measure.volume', '--div--'], + ['ml', 'ml'], + ['cl', 'cl'], + ['l', 'l'], + ['cbm', 'cbm'], + [$_LLL . ':tx_cart_domain_model_product_product.measure.length', '--div--'], + ['cm', 'cm'], + ['m', 'm'], + [$_LLL . ':tx_cart_domain_model_product_product.measure.area', '--div--'], + ['m²', 'm2'], + ], + 'size' => 1, + 'minitems' => 0, + 'maxitems' => 1, + ] + ], + + 'base_price_measure_unit' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.base_price_measure_unit', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + [$_LLL . ':tx_cart_domain_model_product_product.measure.no_measuring_unit', 0], + [$_LLL . ':tx_cart_domain_model_product_product.measure.weight', '--div--'], + ['mg', 'mg'], + ['g', 'g'], + ['kg', 'kg'], + [$_LLL . ':tx_cart_domain_model_product_product.measure.volume', '--div--'], + ['ml', 'ml'], + ['cl', 'cl'], + ['l', 'l'], + ['cbm', 'cbm'], + [$_LLL . ':tx_cart_domain_model_product_product.measure.length', '--div--'], + ['cm', 'cm'], + ['m', 'm'], + [$_LLL . ':tx_cart_domain_model_product_product.measure.area', '--div--'], + ['m²', 'm2'], + ], + 'size' => 1, + 'minitems' => 0, + 'maxitems' => 1, + ] + ], + + 'tax_class_id' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.tax_class_id', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + [$_LLL . ':tx_cart_domain_model_product_product.tax_class_id.1', 1], + [$_LLL . ':tx_cart_domain_model_product_product.tax_class_id.2', 2], + [$_LLL . ':tx_cart_domain_model_product_product.tax_class_id.3', 3], + ], + 'size' => 1, + 'minitems' => 1, + 'maxitems' => 1, + ], + ], + + 'be_variant_attribute1' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.be_variant_attribute1', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['', 0], + ], + 'foreign_table' => 'tx_cart_domain_model_product_bevariantattribute', + 'foreign_table_where' => ' AND tx_cart_domain_model_product_bevariantattribute.pid=###CURRENT_PID### ORDER BY tx_cart_domain_model_product_bevariantattribute.title ', + 'minitems' => 0, + 'maxitems' => 1, + ], + ], + + 'be_variant_attribute2' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.be_variant_attribute2', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['', 0], + ], + 'foreign_table' => 'tx_cart_domain_model_product_bevariantattribute', + 'foreign_table_where' => ' AND tx_cart_domain_model_product_bevariantattribute.pid=###CURRENT_PID### ORDER BY tx_cart_domain_model_product_bevariantattribute.title ', + 'minitems' => 0, + 'maxitems' => 1, + ], + ], + + 'be_variant_attribute3' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.be_variant_attribute3', + 'config' => [ + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['', 0], + ], + 'foreign_table' => 'tx_cart_domain_model_product_bevariantattribute', + 'foreign_table_where' => ' AND tx_cart_domain_model_product_bevariantattribute.pid=###CURRENT_PID### ORDER BY tx_cart_domain_model_product_bevariantattribute.title ', + 'minitems' => 0, + 'maxitems' => 1, + ], + ], + + 'fe_variants' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.fe_variants', + 'config' => [ + 'type' => 'inline', + 'foreign_table' => 'tx_cart_domain_model_product_fevariant', + 'foreign_field' => 'product', + 'foreign_table_where' => ' AND tx_cart_domain_model_product_fevariant.pid=###CURRENT_PID### ORDER BY tx_cart_domain_model_product_fevariant.title ', + 'maxitems' => 9999, + 'appearance' => [ + 'collapseAll' => 1, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1 + ], + ], + ], + + 'be_variants' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.be_variants', + 'config' => [ + 'type' => 'inline', + 'foreign_table' => 'tx_cart_domain_model_product_bevariant', + 'foreign_field' => 'product', + 'foreign_table_where' => ' AND tx_cart_domain_model_product_bevariant.pid=###CURRENT_PID### ORDER BY tx_cart_domain_model_product_bevariant.title ', + 'maxitems' => 9999, + 'appearance' => [ + 'collapseAll' => 1, + 'levelLinksPosition' => 'top', + 'showSynchronizationLink' => 1, + 'showPossibleLocalizationRecords' => 1, + 'showAllLocalizationLink' => 1 + ], + ], + ], + + 'related_products' => [ + 'exclude' => 1, + 'label' => $_LLL . 'tx_cart_domain_model_product_product.related_products', + 'config' => [ + 'type' => 'group', + 'internal_type' => 'db', + 'allowed' => 'tx_cart_domain_model_product_product', + 'foreign_table' => 'tx_cart_domain_model_product_product', + 'MM_opposite_field' => 'related_products_from', + 'size' => 5, + 'minitems' => 0, + 'maxitems' => 100, + 'MM' => 'tx_cart_domain_model_product_product_related_mm', + 'wizards' => [ + 'suggest' => [ + 'type' => 'suggest', + 'default' => [ + 'searchWholePhrase' => true + ] + ], + ], + ] + ], + + 'related_products_from' => [ + 'exclude' => 1, + 'label' => $_LLL . 'tx_cart_domain_model_product_product.related_products_from', + 'config' => [ + 'type' => 'group', + 'internal_type' => 'db', + 'foreign_table' => 'tx_cart_domain_model_product_product', + 'allowed' => 'tx_cart_domain_model_product_product', + 'size' => 5, + 'maxitems' => 100, + 'MM' => 'tx_cart_domain_model_product_product_related_mm', + 'readOnly' => 1, + ] + ], + + 'images' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.images', + 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( + 'image', + [ + 'appearance' => [ + 'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference', + ], + 'minitems' => 0, + 'maxitems' => 99, + ], + $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] + ), + ], + + 'files' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.files', + 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( + 'files', + [ + 'appearance' => [ + 'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference', + ], + 'minitems' => 0, + 'maxitems' => 99, + ], + $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] + ), + ], + + 'product_content' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.product_content', + 'config' => [ + 'type' => 'inline', + 'foreign_table' => 'tt_content', + 'foreign_field' => 'tx_cart_domain_model_product_product', + 'foreign_sortby' => 'sorting', + 'minitems' => 0, + 'maxitems' => 99, + 'appearance' => [ + 'levelLinksPosition' => 'top', + 'showPossibleLocalizationRecords' => true, + 'showRemovedLocalizationRecords' => true, + 'showAllLocalizationLink' => true, + 'showSynchronizationLink' => true, + 'enabledControls' => [ + 'info' => true, + 'new' => true, + 'dragdrop' => false, + 'sort' => true, + 'hide' => true, + 'delete' => true, + 'localize' => true, + ] + ], + 'inline' => [ + 'inlineNewButtonStyle' => 'display: inline-block;', + ], + 'behaviour' => [ + 'localizationMode' => 'select', + 'localizeChildrenAtParentLocalization' => true, + ], + ] + ], + + 'handle_stock' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.handle_stock', + 'config' => [ + 'type' => 'check', + ], + ], + 'stock' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_product.stock', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'int', + 'default' => 0, + ] + ], + ], +]; diff --git a/Configuration/TCA/tx_cart_domain_model_product_specialprice.php b/Configuration/TCA/tx_cart_domain_model_product_specialprice.php new file mode 100644 index 00000000..81d583f0 --- /dev/null +++ b/Configuration/TCA/tx_cart_domain_model_product_specialprice.php @@ -0,0 +1,141 @@ + [ + 'title' => $_LLL . ':tx_cart_domain_model_product_specialprice', + 'label' => 'price', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'dividers2tabs' => true, + + 'versioningWS' => 2, + 'versioning_followPages' => true, + + 'languageField' => 'sys_language_uid', + 'transOrigPointerField' => 'l10n_parent', + 'transOrigDiffSourceField' => 'l10n_diffsource', + 'hideTable' => true, + 'delete' => 'deleted', + 'enablecolumns' => [ + 'disabled' => 'hidden', + 'starttime' => 'starttime', + 'endtime' => 'endtime', + ], + 'searchFields' => 'price', + 'iconfile' => 'EXT:cart/Resources/Public/Icons/Product/SpecialPrice.png' + ], + 'interface' => [ + 'showRecordFieldList' => 'hidden, starttime, endtime, price', + ], + 'types' => [ + '1' => ['showitem' => 'hidden;;1, starttime, endtime, price'], + ], + 'palettes' => [ + '1' => ['showitem' => ''], + ], + 'columns' => [ + + 'sys_language_uid' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language', + 'config' => [ + 'type' => 'select', + 'foreign_table' => 'sys_language', + 'foreign_table_where' => 'ORDER BY sys_language.title', + 'items' => [ + ['LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1], + ['LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0] + ], + ], + ], + 'l10n_parent' => [ + 'displayCond' => 'FIELD:sys_language_uid:>:0', + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent', + 'config' => [ + 'type' => 'select', + 'items' => [ + ['', 0], + ], + 'foreign_table' => 'tx_cart_domain_model_product_specialprice', + 'foreign_table_where' => 'AND tx_cart_domain_model_product_specialprice.pid=###CURRENT_PID### AND tx_cart_domain_model_product_specialprice.sys_language_uid IN (-1,0)', + ], + ], + 'l10n_diffsource' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + + 't3ver_label' => [ + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.versionLabel', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'max' => 255, + ] + ], + + 'hidden' => [ + 'exclude' => 1, + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden', + 'config' => [ + 'type' => 'check', + ], + ], + 'starttime' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.starttime', + 'config' => [ + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + ], + ], + 'endtime' => [ + 'exclude' => 1, + 'l10n_mode' => 'mergeIfNotBlank', + 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.endtime', + 'config' => [ + 'type' => 'input', + 'size' => 13, + 'max' => 20, + 'eval' => 'datetime', + 'checkbox' => 0, + 'default' => 0, + 'range' => [ + 'lower' => mktime(0, 0, 0, date('m'), date('d'), date('Y')) + ], + ], + ], + + 'price' => [ + 'exclude' => 1, + 'label' => $_LLL . ':tx_cart_domain_model_product_specialprice.price', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'required,double2', + 'default' => '0.00', + ] + ], + + 'product' => [ + 'config' => [ + 'type' => 'passthrough', + ], + ], + ], +]; diff --git a/Configuration/TypoScript/Bootstrap/setup.txt b/Configuration/TypoScript/Bootstrap/setup.txt new file mode 100644 index 00000000..b220cb39 --- /dev/null +++ b/Configuration/TypoScript/Bootstrap/setup.txt @@ -0,0 +1,15 @@ +plugin.tx_cart { + view { + templateRootPaths { + 101 = {$plugin.tx_cart.view.bootstrap.templateRootPath} + } + partialRootPaths { + 101 = {$plugin.tx_cart.view.bootstrap.partialRootPath} + } + layoutRootPaths { + 101 = {$plugin.tx_cart.view.bootstrap.layoutRootPath} + } + } +} + +page.includeCSS.tx_cart > \ No newline at end of file diff --git a/Configuration/TypoScript/Foundation/setup.txt b/Configuration/TypoScript/Foundation/setup.txt new file mode 100644 index 00000000..4ebf20a5 --- /dev/null +++ b/Configuration/TypoScript/Foundation/setup.txt @@ -0,0 +1,15 @@ +plugin.tx_cart { + view { + templateRootPaths { + 101 = {$plugin.tx_cart.view.foundation.templateRootPath} + } + partialRootPaths { + 101 = {$plugin.tx_cart.view.foundation.partialRootPath} + } + layoutRootPaths { + 101 = {$plugin.tx_cart.view.foundation.layoutRootPath} + } + } +} + +page.includeCSS.tx_cart > \ No newline at end of file diff --git a/Configuration/TypoScript/constants.txt b/Configuration/TypoScript/constants.txt new file mode 100644 index 00000000..ddeb9b70 --- /dev/null +++ b/Configuration/TypoScript/constants.txt @@ -0,0 +1,179 @@ +plugin.tx_cart { + view { + default { + templateRootPath = EXT:cart/Resources/Private/Templates/Default/ + partialRootPath = EXT:cart/Resources/Private/Partials/Default/ + layoutRootPath = EXT:cart/Resources/Private/Layouts/Default/ + } + + bootstrap { + templateRootPath = EXT:cart/Resources/Private/Templates/Bootstrap/ + partialRootPath = EXT:cart/Resources/Private/Partials/Bootstrap/ + layoutRootPath = EXT:cart/Resources/Private/Layouts/Bootstrap/ + } + + foundation { + templateRootPath = EXT:cart/Resources/Private/Templates/Foundation/ + partialRootPath = EXT:cart/Resources/Private/Partials/Foundation/ + layoutRootPath = EXT:cart/Resources/Private/Layouts/Foundation/ + } + } + + persistence { + storagePid = + } + + # cat=plugin.cart//0070; type=text; label= Service Attribute 1 symbol (e.g. Weight: g, kg, lbs). + main.service_attribute_1_symbol = + + # cat=plugin.cart//0071; type=text; label= Service Attribute 2 symbol (e.g. Volume: l, gal). + main.service_attribute_2_symbol = + + # cat=plugin.cart//0072; type=text; label= Service Attribute 3 symbol (e.g. Length: m, cm, inch). + main.service_attribute_3_symbol = + + # cat=plugin.cart//0090; type=text; label= Enter the uid of the page where cart plugin resides (e.g. 10). + main.pid = + + gpValues { + # cat=plugin.cart//0100; type=text; label= Param productId: Enter the correct parameter name for a unique product number (integer) of your order form. cart uses this number for internal purposes. It can't be a string. The PUID will never be displayed (e.g. tx_myext_pi1|showUid). Default: productId. + productId = productId + + # cat=plugin.cart//0101; type=text; label= Param tableId: Enter the correct parameter name for a unique product table (integer) of your order form. cart uses this number for internal purposes. It can't be a string. The tableId will never be displayed. + tableId = + + # cat=plugin.cart//0102; type=text; label= Param repositoryId: Enter the correct parameter name for a unique product repository (integer) of your order form. cart uses this number for internal purposes. It can't be a string. The tableId will never be displayed. + repositoryId = + + # cat=plugin.cart//0105; type=text; label= Param contentId: Enter the correct parameter name for the uid of the current tt_content element. This value is only needed if you want to add tt_content elements to your cart. The provided parameter must be equal to the name in your HTML template. Default: contentId. + contentId = contentId + + # cat=plugin.cart//0110; type=text; label= Param Quantity: Enter the correct parameter name for the quantity/amount field of your order form. The provided parameter must be equal to the name in your HTML template. Default: quantity. + quantity = quantity + + beVariants { + # cat=plugin.cart//0150; type=text; label= Param Variants: Enter the correct parameter name for the variant 1. + 1 = + # cat=plugin.cart//0151; type=text; label= Param Variants: Enter the correct parameter name for the variant 2. + 2 = + # cat=plugin.cart//0152; type=text; label= Param Variants: Enter the correct parameter name for the variant 3. + 3 = + } + + # cat=plugin.cart//0153; type=text; label= Param Multiple: Enter the correct parameter name if adding multiple products to cart in one form. + multiple = multiple + } + + taxClasses { + 1 { + # cat=plugin.cart//0160; type=text; label= Tax rate: Enter the tax value for this tax class item (e.g. 19). Value will be displayed. + value = 19 + # cat=plugin.cart//0161; type=text; label= Tax rate: Enter the tax rate for this tax class item (e.g. 0.19). Used for calculation. + calc = 0.19 + # cat=plugin.cart//0162; type=text; label= Tax rate: Enter the name for this tax class item (e.g. normal). Value can be displayed. + name = normal + } + + 2 { + # cat=plugin.cart//0170; type=text; label= Tax rate: Enter the tax value for this tax class item (e.g. 7). Value will be displayed. + value = 7 + # cat=plugin.cart//0171; type=text; label= Tax rate: Enter the tax rate for this tax class item (e.g. 0.07). Used for calculation. + calc = 0.07 + # cat=plugin.cart//0172; type=text; label= Tax rate: Enter the name for this tax class item (e.g. reduced). Value can be displayed. + name = reduced + } + + 3 { + # cat=plugin.cart//0180; type=text; label= Tax rate: Enter the tax value for this tax class item (e.g. 0). Value will be displayed. + value = 0 + # cat=plugin.cart//0181; type=text; label= Tax rate: Enter the tax rate for this tax class item (e.g. 0.19). Used for calculation. + calc = 0.00 + # cat=plugin.cart//0182; type=text; label= Tax rate: Enter the name for this tax class item (e.g. free). Value can be displayed. + name = free + } + } + + db { + # cat=plugin.cart//0200; type=text; label= Table name: Enter the correct table name where the products are stored (e.g. tx_myext). + tableName = + + # cat=plugin.cart//0205; type=text; label= Table localisation column: Enter the correct column name where the localisation parent is stored (e.g. l10n_parent | l18n_parent). + l10n_parent = l10n_parent + + fields { + # cat=plugin.cart//0210; type=text; label= Title column: Enter the correct column name of the table where the product titles are stored (e.g. title). + title = title + # cat=plugin.cart//0220; type=text; label= Price column: Enter the correct column name of the table where the prices are stored (e.g. price). + price = price + # cat=plugin.cart//0230; type=text; label= Inherit Price column: Enter the correct column name of the table where the inherit price flag is stored (e.g. inherit_price). + inheritPrice = + # cat=plugin.cart//0235; type=text; label= Tax class column: Enter the correct column name of the table where the tax classes are stored (e.g. taxclass). + taxClassId = taxclass + # cat=plugin.cart//0240; type=text; label= SKU column: Enter the correct column name of the table where the SKUs are stored (e.g. sku). + sku = + # cat=plugin.cart//0243; type=text; label= Variants column: Enter the correct column name of the table where the variants are stored (e.g. variants). + variants = + # cat=plugin.cart//0250; type=text; label= Service Attribute 1 column: Enter the correct column name of the table where the service attribute 1 are stored (e.g. for weight). + serviceAttribute1 = + # cat=plugin.cart//0251; type=text; label= Service Attribute 2 column: Enter the correct column name of the table where the service attribute 2 are stored (e.g. for volume). + serviceAttribute2 = + # cat=plugin.cart//0252; type=text; label= Service Attribute 3 column: Enter the correct column name of the table where the service attribute 3 are stored (e.g. for length). + serviceAttribute3 = + # cat=plugin.cart//0260; type=text; label= Has FE Variant column: Enter the correct column name of the table where the "has fe variant" attribute are stored (e.g. has_fe_variant). + hasFeVariants = + } + } + + orderNumber { + # cat=plugin.cart//0600; type=text; label= Prefix (prepend) for order number (e.g. DE). + prefix = + # cat=plugin.cart//0610; type=text; label= Suffix (append) for order number (e.g. O). + suffix = + # cat=plugin.cart//0620; type=int+; label= Offset for order number: The offset is added to the order number (e.g. if the offset is 999 the first order number will be 1000). + offset = + } + + invoiceNumber { + # cat=plugin.cart//0630; type=text; label= Prefix (prepend) for invoice number (e.g. DE). + prefix = + # cat=plugin.cart//0640; type=text; label= Suffix (append) for invoice number (e.g. I). + suffix = + # cat=plugin.cart//0650; type=int+; label= Offset for invoice number: The offset is added to the invoice number (e.g. if the offset is 999 the first invoice number will be 1000). + offset = + } +} + +plugin.tx_cart { + variantRepository { + class = Extcode\Cart\Domain\Repository\Product\BeVariantRepository + } + + taxClassRepository { + class = Extcode\Cart\Domain\Repository\Product\TaxClassRepository + fields { + getId = getUid + getTitle = getTitle + getValue = getValue + getCalc = getCalc + } + } + + products { + repository { + class = Extcode\Cart\Domain\Repository\Product\ProductRepository + + fields { + getMinNumberInOrder = getMinNumberInOrder + getMaxNumberInOrder = getMaxNumberInOrder + getSpecialPrice = getBestSpecialPrice + getFeVariants = getFeVariants + } + + beVariants { + repository { + class = Extcode\Cart\Domain\Repository\Product\BeVariantRepository + } + } + } + } +} diff --git a/Configuration/TypoScript/setup.txt b/Configuration/TypoScript/setup.txt new file mode 100644 index 00000000..03dcd613 --- /dev/null +++ b/Configuration/TypoScript/setup.txt @@ -0,0 +1,214 @@ +config.tx_extbase { + objects { + TYPO3\CMS\Extbase\Domain\Model\Category { + className = Extcode\Cart\Domain\Model\Category + } + TYPO3\CMS\Extbase\Domain\Repository\CategoryRepository { + className = Extcode\Cart\Domain\Repository\CategoryRepository + } + } +} + +plugin.tx_cart { + persistence { + classes { + Extcode\Cart\Domain\Model\Category { + mapping { + tableName = sys_category + } + } + } + } +} + +page.includeCSS.tx_cart = EXT:cart/Resources/Public/Stylesheets/Default/style.css + +plugin.tx_cart { + + view { + templateRootPaths { + 0 = EXT:cart/Resources/Private/Templates/Default/ + 1 = {$plugin.tx_cart.view.default.templateRootPath} + } + partialRootPaths { + 0 = EXT:cart/Resources/Private/Partials/Default/ + 1 = {$plugin.tx_cart.view.default.partialRootPath} + } + layoutRootPaths { + 0 = EXT:cart/Resources/Private/Layouts/Default/ + 1 = {$plugin.tx_cart.view.default.layoutRootPath} + } + } + + persistence { + storagePid = {$plugin.tx_cart.persistence.storagePid} + } + + settings { + cart { + pid = {$plugin.tx_cart.settings.cart.pid} + isNetCart = {$plugin.tx_cart.settings.cart.isNetCart} + } + + order { + pid = {$plugin.tx_cart.settings.order.pid} + } + + format.currency { + currencySign = {$plugin.tx_cart.settings.format.currency.currencySign} + decimalSeparator = {$plugin.tx_cart.settings.format.currency.decimalSeparator} + thousandsSeparator = {$plugin.tx_cart.settings.format.currency.thousandsSeparator} + prependCurrency = {$plugin.tx_cart.settings.format.currency.prependCurrency} + separateCurrency = {$plugin.tx_cart.settings.format.currency.separateCurrency} + decimals = {$plugin.tx_cart.settings.format.currency.decimals} + } + + seller.emailAddress = test@extco.de + } + + db { + tableName = {$plugin.tx_cart.db.tableName} + l10n_parent = {$plugin.tx_cart.db.l10n_parent} + + fields { + title = {$plugin.tx_cart.db.fields.title} + price = {$plugin.tx_cart.db.fields.price} + inheritPrice = {$plugin.tx_cart.db.fields.inheritPrice} + taxClassId = {$plugin.tx_cart.db.fields.taxClassId} + sku = {$plugin.tx_cart.db.fields.sku} + serviceAttribute1 = {$plugin.tx_cart.db.fields.serviceAttribute1} + serviceAttribute2 = {$plugin.tx_cart.db.fields.serviceAttribute2} + serviceAttribute3 = {$plugin.tx_cart.db.fields.serviceAttribute3} + hasFeVariants = {$plugin.tx_cart.db.fields.hasFeVariants} + additional { + } + } + + variants { + db { + table = {$plugin.tx_cart.db.variants.db.table} + fields { + title = {$plugin.tx_cart.db.variants.db.title} + price = {$plugin.tx_cart.db.variants.db.price} + priceCalcMethod = {$plugin.tx_cart.db.variants.db.priceCalcMethod} + inheritPrice = {$plugin.tx_cart.db.variants.db.inheritPrice} + sku = {$plugin.tx_cart.db.variants.db.sku} + hasFeVariants = {$plugin.tx_cart.db.variants.db.hasFeVariants} + taxClassId = {$plugin.tx_cart.db.variants.db.taxClassId} + } + } + } + } + + gpValues { + productId = {$plugin.tx_cart.gpValues.productId} + tableId = {$plugin.tx_cart.gpValues.tableId} + repositoryId = {$plugin.tx_cart.gpValues.repositoryId} + contentId = {$plugin.tx_cart.gpValues.contentId} + quantity = {$plugin.tx_cart.gpValues.quantity} + + beVariants.1 = {$plugin.tx_cart.gpValues.beVariants.1} + beVariants.2 = {$plugin.tx_cart.gpValues.beVariants.2} + beVariants.3 = {$plugin.tx_cart.gpValues.beVariants.3} + multiple = {$plugin.tx_cart.gpValues.multiple} + } + + taxClasses { + 1 { + value = {$plugin.tx_cart.taxClasses.1.value} + calc = {$plugin.tx_cart.taxClasses.1.calc} + name = {$plugin.tx_cart.taxClasses.1.name} + } + 2 { + value = {$plugin.tx_cart.taxClasses.2.value} + calc = {$plugin.tx_cart.taxClasses.2.calc} + name = {$plugin.tx_cart.taxClasses.2.name} + } + 3 { + value = {$plugin.tx_cart.taxClasses.3.value} + calc = {$plugin.tx_cart.taxClasses.3.calc} + name = {$plugin.tx_cart.taxClasses.3.name} + } + } + + shippings { + preset = 1 + options { + 1 { + title = Standard + extra = 0.00 + taxClassId = 1 + status = open + } + } + } + + payments { + preset = 1 + options { + 1 { + title = Vorkasse + extra = 0.00 + taxClassId = 1 + status = open + } + } + } + + orderNumber = COA + orderNumber { + 10 = TEXT + 10.value = {$plugin.tx_cart.orderNumber.prefix} + + 20 = TEXT + 20.current = 1 + 20.setCurrent.field = orderNumber + 20.setCurrent.wrap = | + {$plugin.tx_cart.orderNumber.offset} + 20.prioriCalc = intval + + 30 = TEXT + 30.value = {$plugin.tx_cart.orderNumber.suffix} + } + + invoiceNumber = COA + invoiceNumber { + 10 = TEXT + 10.value = {$plugin.tx_cart.invoiceNumber.prefix} + + 20 = TEXT + 20.current = 1 + 20.setCurrent.field = invoiceNumber + 20.setCurrent.wrap = | + {$plugin.tx_cart.invoiceNumber.offset} + 20.prioriCalc = intval + + 30 = TEXT + 30.value = {$plugin.tx_cart.invoiceNumber.suffix} + } + +} + +plugin.tx_cart { + db > + + repository { + class = {$plugin.tx_cart.products.repository.class} + fields { + getMinNumber = {$plugin.tx_cart.products.repository.fields.getMinNumberInOrder} + getMaxNumber = {$plugin.tx_cart.products.repository.fields.getMaxNumberInOrder} + getSpecialPrice = {$plugin.tx_cart.products.repository.fields.getSpecialPrice} + getFeVariants = {$plugin.tx_cart.products.repository.fields.getFeVariants} + } + + beVariants { + repository { + class = {$plugin.tx_cart.products.repository.beVariants.repository.class} + } + } + } + + gpValues { + beVariants { + 1 = beVariants|1 + } + } +} \ No newline at end of file diff --git a/Documentation/AdministratorManual/Configuration/Index.rst b/Documentation/AdministratorManual/Configuration/Index.rst new file mode 100644 index 00000000..feaaf1a5 --- /dev/null +++ b/Documentation/AdministratorManual/Configuration/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Configuration +============= diff --git a/Documentation/AdministratorManual/Index.rst b/Documentation/AdministratorManual/Index.rst new file mode 100644 index 00000000..abf4a8c8 --- /dev/null +++ b/Documentation/AdministratorManual/Index.rst @@ -0,0 +1,14 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Administrator Manual +==================== + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + Installation/Index + Configuration/Index diff --git a/Documentation/AdministratorManual/Installation/Index.rst b/Documentation/AdministratorManual/Installation/Index.rst new file mode 100644 index 00000000..253597ae --- /dev/null +++ b/Documentation/AdministratorManual/Installation/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Installation +============ diff --git a/Documentation/DeveloperManual/DatabaseModel/Index.rst b/Documentation/DeveloperManual/DatabaseModel/Index.rst new file mode 100644 index 00000000..044a84ca --- /dev/null +++ b/Documentation/DeveloperManual/DatabaseModel/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Database Model +============== diff --git a/Documentation/DeveloperManual/Index.rst b/Documentation/DeveloperManual/Index.rst new file mode 100644 index 00000000..b403b672 --- /dev/null +++ b/Documentation/DeveloperManual/Index.rst @@ -0,0 +1,14 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Developer Manual +================ + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + DatabaseModel/Index + SignalSlots/Index diff --git a/Documentation/DeveloperManual/SignalSlots/Index.rst b/Documentation/DeveloperManual/SignalSlots/Index.rst new file mode 100644 index 00000000..8748c81f --- /dev/null +++ b/Documentation/DeveloperManual/SignalSlots/Index.rst @@ -0,0 +1,15 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Signal Slots +============ + +================================== ================================== ================================== +Signal Class Name Signal Name Description +================================== ================================== ================================== +Extcode\Cart\Utility\OrderUtility handlePaymentAfterOrder Used for Payment Provider +Extcode\Cart\Utility\OrderUtility addProductBeforeSetAdditionalData TODO +Extcode\Cart\Utility\OrderUtility addVariantBeforeSetAdditionalData TODO +================================== ================================== ================================== diff --git a/Documentation/EditorManual/Index.rst b/Documentation/EditorManual/Index.rst new file mode 100644 index 00000000..cd3203d0 --- /dev/null +++ b/Documentation/EditorManual/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +User Manual +=========== diff --git a/Documentation/Images/cart_logo.png b/Documentation/Images/cart_logo.png new file mode 100644 index 00000000..a6e59726 Binary files /dev/null and b/Documentation/Images/cart_logo.png differ diff --git a/Documentation/Includes.txt b/Documentation/Includes.txt new file mode 100644 index 00000000..58888ba3 --- /dev/null +++ b/Documentation/Includes.txt @@ -0,0 +1,18 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +.. ================================================== +.. DEFINE SOME TEXTROLES +.. -------------------------------------------------- + +.. role:: typoscript(code) + +.. role:: ts(typoscript) + :class: typoscript + +.. role:: php(code) + :language: php + +.. highlight:: php \ No newline at end of file diff --git a/Documentation/Index.rst b/Documentation/Index.rst new file mode 100644 index 00000000..be9bdacc --- /dev/null +++ b/Documentation/Index.rst @@ -0,0 +1,54 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +.. include:: Includes.txt + +.. _start: + +=========================== +EXT: Cart +=========================== + +.. image:: /Images/cart_logo.png + :height: 200 + :width: 200 + +.. only:: html + + :Version: + |release| + + :Language: + en + + :Description: + Cart is a powerful extension which adds a shopping cart to your TYPO3 installation. + + :Keywords: + cart, shop, shopping, e-commerce, ecommerce, checkout, payment + + :Author: + Daniel Lorenz + + :Email: + ext.cart@extco.de + + :Rendered: + |today| + + The content of this document is related to TYPO3, + a GNU/GPL CMS/Framework available from `www.typo3.org `__. + + **Table of Contents** + + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + Introduction/Index + EditorManual/Index + DeveloperManual/Index + AdministratorManual/Index diff --git a/Documentation/Introduction/DevelopmentTeam/Index.rst b/Documentation/Introduction/DevelopmentTeam/Index.rst new file mode 100644 index 00000000..9444b478 --- /dev/null +++ b/Documentation/Introduction/DevelopmentTeam/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Development Team +================ diff --git a/Documentation/Introduction/Index.rst b/Documentation/Introduction/Index.rst new file mode 100644 index 00000000..e2d8477e --- /dev/null +++ b/Documentation/Introduction/Index.rst @@ -0,0 +1,14 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Introduction +============ + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + DevelopmentTeam/Index + SupportersAndSponsors/Index diff --git a/Documentation/Introduction/SupportersAndSponsors/Index.rst b/Documentation/Introduction/SupportersAndSponsors/Index.rst new file mode 100644 index 00000000..dbf8bd42 --- /dev/null +++ b/Documentation/Introduction/SupportersAndSponsors/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Supporters and Sponsors +======================= diff --git a/Documentation/Settings.cfg b/Documentation/Settings.cfg new file mode 100644 index 00000000..553660c7 --- /dev/null +++ b/Documentation/Settings.cfg @@ -0,0 +1,31 @@ +# coding: utf-8 + +# ##### +# +# Settings.cfg - A TYPO3 Documentation Project's Configuration File +# +# About Syntax: +# See https://docs.python.org/2/library/configparser.html +# +# Put comments in separate lines! +# +# ##### + + +# Attention: +# LEAVE RIGHT SIDE EMPTY for a 'false' value like: +# example_of_false_value = + + +[general] + +; endless list of all of the general simple settings +; you can use in 'conf.py' + +project = Cart +version = 1.0 +release = 1.0.0 +t3author = Daniel Lorenz +copyright = Copyright since 1970 by My Authorname + +description = Short sample description of Cart diff --git a/Documentation/de_DE/AdministratorManual/Configuration/Index.rst b/Documentation/de_DE/AdministratorManual/Configuration/Index.rst new file mode 100644 index 00000000..9cb2f914 --- /dev/null +++ b/Documentation/de_DE/AdministratorManual/Configuration/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Konfiguration +============= diff --git a/Documentation/de_DE/AdministratorManual/Index.rst b/Documentation/de_DE/AdministratorManual/Index.rst new file mode 100644 index 00000000..7a5b9bc5 --- /dev/null +++ b/Documentation/de_DE/AdministratorManual/Index.rst @@ -0,0 +1,14 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Administratoren Handbuch +======================== + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + Installation/Index + Configuration/Index diff --git a/Documentation/de_DE/AdministratorManual/Installation/Index.rst b/Documentation/de_DE/AdministratorManual/Installation/Index.rst new file mode 100644 index 00000000..72a752b6 --- /dev/null +++ b/Documentation/de_DE/AdministratorManual/Installation/Index.rst @@ -0,0 +1,52 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Installation +============ + +Die Erweiterung wird wie jede andere Erweiterung im TYPO3 CMS installiert. + +Extension Manager +----------------- + +#. Wechsle in das Modul “Extension Manager”. + + #. **Get it from the Extension Manager:** Press the “Retrieve/Update” + button and search for the extension key *news* and import the + extension from the repository. + + #. **Get it from typo3.org:** You can always get current version from + `http://typo3.org/extensions/repository/view/news/current/ + `_ by + downloading either the t3x or zip version. Upload + the file afterwards in the Extension Manager. + +#. The Extension Manager offers some basic configuration which is + explained :ref:`here `. + +Versionsverwaltung (github) +--------------------------- +Die aktuellste Version lässt sich über github mit den üblichen git-Kommandos herunterladen. + +.. code-block:: bash + + git clone git@github.com:extcode/cart.git + +| + +Nachdem die Erweiterung heruntergeladen ist, kann sie über den Extension-Manager aktiviert werden. + +Vorbereitung: Include static TypoScript +--------------------------------------- + +The extension ships some TypoScript code which needs to be included. + +#. Switch to the root page of your site. + +#. Switch to the **Template module** and select *Info/Modify*. + +#. Press the link **Edit the whole template record** and switch to the tab *Includes*. + +#. Select **News (news)** at the field *Include static (from extensions):* diff --git a/Documentation/de_DE/DeveloperManual/DatabaseModel/Index.rst b/Documentation/de_DE/DeveloperManual/DatabaseModel/Index.rst new file mode 100644 index 00000000..08cfa644 --- /dev/null +++ b/Documentation/de_DE/DeveloperManual/DatabaseModel/Index.rst @@ -0,0 +1,43 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Datenbankmodell +=============== + +Die Datenbankmodelle sind entgegen der üblichen Extbase-Struktur noch einmal unterteilt, um eine bessere Übersicht +über die Modelle zu bekommen. Diese sind eingeteilt in Modelles des Warenkorbs (Cart), der Bestellungen (Order) und +die Produkte (Product). Durch die Verwendung von Namespaces können so auch in den Bestellungen (Order) und +Produkten (Product) Klassennamen wiederverwendet werden. + +Warenkorb (Cart) +---------------- + +Die Modelle im Verzeichnis Cart werden für die Repräsentation der Daten im Warenkorb verwandt. Diese sind einfache +Klassen und werden nicht von \TYPO3\CMS\Extbase\DomainObject\AbstractEntity abgeleitet. Die Modelle im Verzeichnis +Cart werden auch nicht in der Datenbank sondern lediglich in der Session gespeichert. Das Ableiten von +\TYPO3\CMS\Extbase\DomainObject\AbstractEntity würde den Platz für die Sessionverwaltung unnötig aufblasen. +Die Funktionen werden im Warenkorb nicht benötigt. + +*ER Diagram* + +Produkten (Product) +------------------- + +Die Modelle im Verzeichnis Product werden für die Repräsentation der Produkte benötigt. Produkte (Product) können durch +Varianten (Variant) und FeVarianten (FeVariant) angepasst werden. Weiterhin können Produkte sogenannte +Streichpreise (SpecialPrice) haben. Coupons (Coupon) gehören nicht direkt zum Produkt, werden aber auf Seite der +Produkte verwaltet. + +*ER Diagram* + +Bestellungen (Order) +-------------------- + +Die Modelle im Verzeichnis Order repräsentieren die einzelnen Bestellungen. Eine Bestellung (Item) hat dabei immer +Produkte (Product) eine Bestelladdresse (Address) und ggf. eine Versandadresse (Address). Weiterhin werden die +Steuerklassen (TaxClass) und errechneten Mehrwertsteuern (Tax) gespeichert. In einer Bestellung werden weiterhin die +verwendeten Coupons (Coupons) gespeicher. + +*ER Diagram* diff --git a/Documentation/de_DE/DeveloperManual/Index.rst b/Documentation/de_DE/DeveloperManual/Index.rst new file mode 100644 index 00000000..9cd3d8b6 --- /dev/null +++ b/Documentation/de_DE/DeveloperManual/Index.rst @@ -0,0 +1,14 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Entwickler Handbuch +=================== + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + DatabaseModel/Index + SignalSlots/Index diff --git a/Documentation/de_DE/DeveloperManual/SignalSlots/Index.rst b/Documentation/de_DE/DeveloperManual/SignalSlots/Index.rst new file mode 100644 index 00000000..7bc9cd29 --- /dev/null +++ b/Documentation/de_DE/DeveloperManual/SignalSlots/Index.rst @@ -0,0 +1,24 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Signal Slots +============ + +================================== ================================== ================================== +Signal Class Name Signal Name Description +================================== ================================== ================================== +Extcode\Cart\Utility\OrderUtility handlePaymentAfterOrder Anbindung von Payment Providern +Extcode\Cart\Utility\OrderUtility addProductBeforeSetAdditionalData TODO +Extcode\Cart\Utility\OrderUtility addVariantBeforeSetAdditionalData TODO +================================== ================================== ================================== + +handlePaymentAfterOrder +----------------------- + +Dieser Signal Slot dient der Anbindung von Payment Providers wie PayPal, Amazon Chackout oder anderen. +An dieser Stelle kann die normale Abarbeitung der Bestellung (Versand der E-Mails, Weiterleitung auf die Dankeseite) +unterbrochen und zur Seite des Anbieters für die Zahlungsabwicklung weitergeleitet werden. + +*Übergabeparameter* diff --git a/Documentation/de_DE/EditorManual/Index.rst b/Documentation/de_DE/EditorManual/Index.rst new file mode 100644 index 00000000..e63e7bbf --- /dev/null +++ b/Documentation/de_DE/EditorManual/Index.rst @@ -0,0 +1,15 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Benutzer Handbuch +================= + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + Records/Index + Modules/Index + Plugins/Index diff --git a/Documentation/de_DE/EditorManual/Modules/Index.rst b/Documentation/de_DE/EditorManual/Modules/Index.rst new file mode 100644 index 00000000..5c0656b4 --- /dev/null +++ b/Documentation/de_DE/EditorManual/Modules/Index.rst @@ -0,0 +1,15 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Module +====== + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + Orders/Index + OrderStatistics/Index + Products/Index diff --git a/Documentation/de_DE/EditorManual/Modules/OrderStatistics/Index.rst b/Documentation/de_DE/EditorManual/Modules/OrderStatistics/Index.rst new file mode 100644 index 00000000..73c34cca --- /dev/null +++ b/Documentation/de_DE/EditorManual/Modules/OrderStatistics/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Bestellstatistik +================ diff --git a/Documentation/de_DE/EditorManual/Modules/Orders/Index.rst b/Documentation/de_DE/EditorManual/Modules/Orders/Index.rst new file mode 100644 index 00000000..0ca1e678 --- /dev/null +++ b/Documentation/de_DE/EditorManual/Modules/Orders/Index.rst @@ -0,0 +1,9 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +.. _de_de_modules-orders: + +Bestellungen +============ diff --git a/Documentation/de_DE/EditorManual/Modules/Products/Index.rst b/Documentation/de_DE/EditorManual/Modules/Products/Index.rst new file mode 100644 index 00000000..0833ce2c --- /dev/null +++ b/Documentation/de_DE/EditorManual/Modules/Products/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Produkte +======== diff --git a/Documentation/de_DE/EditorManual/Plugins/Cart/Index.rst b/Documentation/de_DE/EditorManual/Plugins/Cart/Index.rst new file mode 100644 index 00000000..f79a223a --- /dev/null +++ b/Documentation/de_DE/EditorManual/Plugins/Cart/Index.rst @@ -0,0 +1,9 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Cart: Warenkorb +=============== + +Diese Plugin zeigt den aktuellen Warenkorb, die darin enthaltenen Produkte und das Formular für die Bestellung. diff --git a/Documentation/de_DE/EditorManual/Plugins/Index.rst b/Documentation/de_DE/EditorManual/Plugins/Index.rst new file mode 100644 index 00000000..4e7925b6 --- /dev/null +++ b/Documentation/de_DE/EditorManual/Plugins/Index.rst @@ -0,0 +1,16 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Plugins +======= + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + Product/Index + Cart/Index + MiniCart/Index + Order/Index diff --git a/Documentation/de_DE/EditorManual/Plugins/MiniCart/Index.rst b/Documentation/de_DE/EditorManual/Plugins/MiniCart/Index.rst new file mode 100644 index 00000000..ed8d98ef --- /dev/null +++ b/Documentation/de_DE/EditorManual/Plugins/MiniCart/Index.rst @@ -0,0 +1,9 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Cart: Mini-Warenkorb +==================== + +Dieses Plugin kann als Miniwarenkorb eingebunden werden und gibt eine Kurzansicht des Warenkorbs aus. diff --git a/Documentation/de_DE/EditorManual/Plugins/Order/Index.rst b/Documentation/de_DE/EditorManual/Plugins/Order/Index.rst new file mode 100644 index 00000000..cf6e57d3 --- /dev/null +++ b/Documentation/de_DE/EditorManual/Plugins/Order/Index.rst @@ -0,0 +1,9 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Cart: Bestellungen +================== + +Dieses Plugin zeigt die Bestellung des angemeldeten Frontend Benutzers an. diff --git a/Documentation/de_DE/EditorManual/Plugins/Product/Index.rst b/Documentation/de_DE/EditorManual/Plugins/Product/Index.rst new file mode 100644 index 00000000..24679bc2 --- /dev/null +++ b/Documentation/de_DE/EditorManual/Plugins/Product/Index.rst @@ -0,0 +1,13 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Cart: Produkte +============== + +Dieses Plugin zeigt Produkte an. Das Plugin bietet drei verschiedene Varianten Produkte darzustellen. + +* Liste und Detailseite +* Teaser +* Flexform diff --git a/Documentation/de_DE/EditorManual/Records/Coupons/Index.rst b/Documentation/de_DE/EditorManual/Records/Coupons/Index.rst new file mode 100644 index 00000000..ee9d8a85 --- /dev/null +++ b/Documentation/de_DE/EditorManual/Records/Coupons/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Coupons / Gutscheine +==================== diff --git a/Documentation/de_DE/EditorManual/Records/Index.rst b/Documentation/de_DE/EditorManual/Records/Index.rst new file mode 100644 index 00000000..43d31bfa --- /dev/null +++ b/Documentation/de_DE/EditorManual/Records/Index.rst @@ -0,0 +1,16 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Datensätze +---------- + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + Orders/Index + Products/Index + ProductVariants/Index + Coupons/Index diff --git a/Documentation/de_DE/EditorManual/Records/Orders/Index.rst b/Documentation/de_DE/EditorManual/Records/Orders/Index.rst new file mode 100644 index 00000000..4652e299 --- /dev/null +++ b/Documentation/de_DE/EditorManual/Records/Orders/Index.rst @@ -0,0 +1,13 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Bestellungen +============ + +Die Datensätze der Bestellungen enthalten die Daten einer Bestellung und sollen später nicht mehr verändert werden. +Im Backend lassen sich die Datensätze auflisten und öffnen, die Änderungen sind hier nicht möglich. Bitte verwenden +Sie das bereitgestellte Backend-Modul :ref:`de_de_modules-orders`. Dieses Backend-Modul bietet einen optimierten Filter um +Bestellungen schnell aufzufinden. Die übersichtlichere Darstellung einzelner Bestellungen ermöglicht eine bessere +Abarbeitung eingegangener Bestellungen und Veränderung des Status für die Bezahlung und den Versand. diff --git a/Documentation/de_DE/EditorManual/Records/ProductVariants/Index.rst b/Documentation/de_DE/EditorManual/Records/ProductVariants/Index.rst new file mode 100644 index 00000000..9d904ba3 --- /dev/null +++ b/Documentation/de_DE/EditorManual/Records/ProductVariants/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Produktvarianten +================ diff --git a/Documentation/de_DE/EditorManual/Records/Products/Index.rst b/Documentation/de_DE/EditorManual/Records/Products/Index.rst new file mode 100644 index 00000000..69ced65f --- /dev/null +++ b/Documentation/de_DE/EditorManual/Records/Products/Index.rst @@ -0,0 +1,24 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Produkte +======== + +Derzeit können drei verschiedene Datensätze angelegt werden. + +* Produkte +* Varianten +* Coupons + +Produkte +-------- + +Varianten +--------- + +Coupons +------- + +Coupons oder auch Gutscheine werden derzeit nur auf den gesamten Warenkorb angerechnet. diff --git a/Documentation/de_DE/Index.rst b/Documentation/de_DE/Index.rst new file mode 100644 index 00000000..7d5f620f --- /dev/null +++ b/Documentation/de_DE/Index.rst @@ -0,0 +1,55 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +.. include:: ../Includes.txt + +.. _start: + +=========================== +EXT: Cart +=========================== + +.. image:: ../Images/cart_logo.png + :height: 200 + :width: 200 + + +.. only:: html + + :Version: + |release| + + :Sprache: + de + + :Beschreibung: + Cart ist eine Erweiterung, die einen Shop in TYPO3 integriert + + :Keywords: + cart, shop, shopping, e-commerce, ecommerce, checkout, payment + + :Autor: + Daniel Lorenz + + :E-Mail: + ext.cart@extco.de + + :Rendered: + |today| + + The content of this document is related to TYPO3, + a GNU/GPL CMS/Framework available from `www.typo3.org `__. + + **Inhaltsverzeichnis** + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + Introduction/Index + EditorManual/Index + DeveloperManual/Index + AdministratorManual/Index + Misc/Index diff --git a/Documentation/de_DE/Introduction/DevelopmentTeam/Index.rst b/Documentation/de_DE/Introduction/DevelopmentTeam/Index.rst new file mode 100644 index 00000000..20d0ec9a --- /dev/null +++ b/Documentation/de_DE/Introduction/DevelopmentTeam/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Entwickler-Team +=============== diff --git a/Documentation/de_DE/Introduction/Index.rst b/Documentation/de_DE/Introduction/Index.rst new file mode 100644 index 00000000..d9045ca7 --- /dev/null +++ b/Documentation/de_DE/Introduction/Index.rst @@ -0,0 +1,15 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Einführung +---------- + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + DevelopmentTeam/Index + SupportersAndSponsors/Index + Support/Index diff --git a/Documentation/de_DE/Introduction/Support/Index.rst b/Documentation/de_DE/Introduction/Support/Index.rst new file mode 100644 index 00000000..99d03f3e --- /dev/null +++ b/Documentation/de_DE/Introduction/Support/Index.rst @@ -0,0 +1,28 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Support +======= + +Slack +----- +Auf Slack wurde ein eigener Kanal eingerichtet, um mit den Entwicklern und anderen Nutzern von Cart in Kontakt zu +treten! + +Die URL lautet: https://typo3.slack.com/messages/ext-cart/ + +.. note:: + + Noch nicht auf Slack registriert? Unter http://forger.typo3.org/slack kann ein Zugang eingerichtet werden. + +Sponsoring +---------- +Gibt es eine Funktion, die in Cart noch nicht umgesetzt wurde, können Sie mich jederzeit kontaktieren. + +Unterstützung +------------- +Wenn Sie privaten oder persönliche Unterstützung benötigen, wenden Sie sich gern an mich. + +**Diese Unterstützung kann nicht in jedem Fall kostenfrei erfolgen!** diff --git a/Documentation/de_DE/Introduction/SupportersAndSponsors/Index.rst b/Documentation/de_DE/Introduction/SupportersAndSponsors/Index.rst new file mode 100644 index 00000000..45070ee9 --- /dev/null +++ b/Documentation/de_DE/Introduction/SupportersAndSponsors/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Unterstützer und Sponsoren +========================== diff --git a/Documentation/de_DE/Misc/Changelog/Index.rst b/Documentation/de_DE/Misc/Changelog/Index.rst new file mode 100644 index 00000000..7c05450e --- /dev/null +++ b/Documentation/de_DE/Misc/Changelog/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +ChangeLog +========= diff --git a/Documentation/de_DE/Misc/Index.rst b/Documentation/de_DE/Misc/Index.rst new file mode 100644 index 00000000..989a02de --- /dev/null +++ b/Documentation/de_DE/Misc/Index.rst @@ -0,0 +1,14 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Sonstiges +========= + +.. toctree:: + :maxdepth: 5 + :titlesonly: + + Changelog/Index + Todos/Index diff --git a/Documentation/de_DE/Misc/Todos/Index.rst b/Documentation/de_DE/Misc/Todos/Index.rst new file mode 100644 index 00000000..2c52dc69 --- /dev/null +++ b/Documentation/de_DE/Misc/Todos/Index.rst @@ -0,0 +1,7 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +Todos +===== diff --git a/README.md b/README.md new file mode 100644 index 00000000..fa30005a --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +# Cart + +[![build status](http://134.119.13.156:8080/project/Cart/builds/status.png?ref=master)](http://134.119.13.156:8080/project/Cart/builds/status.png?ref=master) + +## Description + +Cart is a small but powerful extension which "solely" adds a shopping cart +to your TYPO3 installation. +The extension allows you to create coupons, products with or without variants, +special prices. + +## Website + +Homepage: http://cart.extco.de \ No newline at end of file diff --git a/Resources/Private/Backend/Layouts/Default.html b/Resources/Private/Backend/Layouts/Default.html new file mode 100644 index 00000000..4a0e0aa0 --- /dev/null +++ b/Resources/Private/Backend/Layouts/Default.html @@ -0,0 +1,32 @@ +{namespace cart=Extcode\Cart\ViewHelpers} + + + +
+
+
+ +
+
+ + +
+
+
+
+ +
+
+ + + +
+
+
+
+
+ + +
+
+
\ No newline at end of file diff --git a/Resources/Private/Backend/Partials/FormErrors.html b/Resources/Private/Backend/Partials/FormErrors.html new file mode 100644 index 00000000..04979d29 --- /dev/null +++ b/Resources/Private/Backend/Partials/FormErrors.html @@ -0,0 +1,16 @@ + +
+ {error.message} + +

+ {error.propertyName}: + + {propertyPath} + + {error.code}: {error} + + +

+
+
+
\ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/Filter/List.html b/Resources/Private/Backend/Partials/Order/Filter/List.html new file mode 100644 index 00000000..d18523af --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/Filter/List.html @@ -0,0 +1,96 @@ +
+
+ + +
+ + +

+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
 

+ +
+ + +
+
+ + +
+
 

+ +
+ +
+ +
 
+
+ +
+
\ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/Filter/Statistic.html b/Resources/Private/Backend/Partials/Order/Filter/Statistic.html new file mode 100644 index 00000000..3aee4259 --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/Filter/Statistic.html @@ -0,0 +1,55 @@ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
 

+ +
+ +
+ +
 
+
+ +
+
\ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/FormFields.html b/Resources/Private/Backend/Partials/Order/FormFields.html new file mode 100644 index 00000000..8e28daca --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/FormFields.html @@ -0,0 +1,30 @@ +

+
+ + + {orderItem.invoiceNumber} + + + + + +

+

+
+ + + + + + + {icon} + + +

\ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/List/Actions.html b/Resources/Private/Backend/Partials/Order/List/Actions.html new file mode 100644 index 00000000..e1a691ae --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/List/Actions.html @@ -0,0 +1,13 @@ +
+ + + + + + + +
\ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/List/Item.html b/Resources/Private/Backend/Partials/Order/List/Item.html new file mode 100644 index 00000000..dc3d9a19 --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/List/Item.html @@ -0,0 +1,67 @@ + + + {orderItem.billingAddress.firstName} + + + {orderItem.billingAddress.lastName} + + + {orderItem.billingAddress.company} + + + + + {orderItem.orderNumber} + + + + + + + + + + {orderItem.invoiceNumber} + + + + + + + + + {orderItem.totalGross} + + + + + {orderItem.totalNet} + + + + {orderItem.payment.name}
+ ( + + ) + + + {orderItem.shipping.name}
+ ( + + ) + + + + + \ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/Show/Actions.html b/Resources/Private/Backend/Partials/Order/Show/Actions.html new file mode 100644 index 00000000..f982a6c9 --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/Show/Actions.html @@ -0,0 +1,20 @@ +
+ + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/Show/Address.html b/Resources/Private/Backend/Partials/Order/Show/Address.html new file mode 100644 index 00000000..f711136f --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/Show/Address.html @@ -0,0 +1,23 @@ +
+
+ {address.salutation} {address.title} {address.firstName} {address.lastName}
+ + {address.company}
+
+ {address.street}
+ {address.zip} {address.city}
+ {address.country} +
+
+
+ + {address.email}
+
+ + {address.phone}
+
+ + {address.fax}
+
+
+
\ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/Show/Cart.html b/Resources/Private/Backend/Partials/Order/Show/Cart.html new file mode 100644 index 00000000..bb471f75 --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/Show/Cart.html @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/Show/OrderTax.html b/Resources/Private/Backend/Partials/Order/Show/OrderTax.html new file mode 100644 index 00000000..f5b16115 --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/Show/OrderTax.html @@ -0,0 +1,13 @@ +
  • + + : + + {orderTax.tax} + +
  • \ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/Show/Product.html b/Resources/Private/Backend/Partials/Order/Show/Product.html new file mode 100644 index 00000000..2283b69d --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/Show/Product.html @@ -0,0 +1,70 @@ + + + {product.sku} + + + {product.title} + + + + {product.price} + + + + + {product.discount} + + + + {product.count} + + + + {product.net} + + + + + {product.gross} + + + + + + + + {product.orderTax.tax} + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/Show/Properties.html b/Resources/Private/Backend/Partials/Order/Show/Properties.html new file mode 100644 index 00000000..48c9e12a --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/Show/Properties.html @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + : + + {orderItem.orderNumber} + + + : + + {orderItem.invoiceNumber} +
    + + : + + + + + + + : + + + + +
    + + : + + {orderItem.payment.name} + + + : + + {orderItem.shipping.name} +
    + + + + + + + +
    +
    + +
    +
    + + + + : + + + +
    + +
    + + + + : + + + +
    + +
    +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Order/Show/ServiceStatus.html b/Resources/Private/Backend/Partials/Order/Show/ServiceStatus.html new file mode 100644 index 00000000..e69de29b diff --git a/Resources/Private/Backend/Partials/Order/Show/Summary.html b/Resources/Private/Backend/Partials/Order/Show/Summary.html new file mode 100644 index 00000000..49940259 --- /dev/null +++ b/Resources/Private/Backend/Partials/Order/Show/Summary.html @@ -0,0 +1,170 @@ + + + + + + + {orderItem.net} + + + + + {orderItem.gross} + + + + + + {orderTax.tax} + + + + + + + + + {orderItem.orderShipping.name} + + + + {orderItem.orderShipping.net} + + + + + {orderItem.orderShipping.gross} + + + + + + + + {orderItem.orderShipping.orderTax.tax} + + + + + + + + + + + + + + {orderItem.orderPayment.name} + + + + {orderItem.orderPayment.net} + + + + + {orderItem.orderPayment.gross} + + + + + + + + {orderItem.orderPayment.orderTax.tax} + + + + + + + + + + + + + + + + + {orderItem.totalNet} + + + + + {orderItem.totalGross} + + + + + + {orderTotalTax.tax} + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Backend/Partials/Product/Filter.html b/Resources/Private/Backend/Partials/Product/Filter.html new file mode 100644 index 00000000..6a7b8061 --- /dev/null +++ b/Resources/Private/Backend/Partials/Product/Filter.html @@ -0,0 +1,28 @@ +
    +
    + + +
    + + +
    +
    + + +
    +
    + +
    +
    + +
    + +
    +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Partials/VariantSet/Filter.html b/Resources/Private/Backend/Partials/VariantSet/Filter.html new file mode 100644 index 00000000..8806f649 --- /dev/null +++ b/Resources/Private/Backend/Partials/VariantSet/Filter.html @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/Order/Edit.html b/Resources/Private/Backend/Templates/Order/Edit.html new file mode 100644 index 00000000..93ec1bc7 --- /dev/null +++ b/Resources/Private/Backend/Templates/Order/Edit.html @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/Order/Export.csv b/Resources/Private/Backend/Templates/Order/Export.csv new file mode 100644 index 00000000..4ba59031 --- /dev/null +++ b/Resources/Private/Backend/Templates/Order/Export.csv @@ -0,0 +1,3 @@ +{namespace cart=Extcode\Cart\ViewHelpers} + + \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/Order/List.html b/Resources/Private/Backend/Templates/Order/List.html new file mode 100644 index 00000000..c19260af --- /dev/null +++ b/Resources/Private/Backend/Templates/Order/List.html @@ -0,0 +1,84 @@ + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    ( + + ) +
    + +
    ( + + ) +
    +   +
    +
    +
    + + Select a Page where Order Item Dataset are saved. + +
    +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/Order/Show.html b/Resources/Private/Backend/Templates/Order/Show.html new file mode 100644 index 00000000..ac86d005 --- /dev/null +++ b/Resources/Private/Backend/Templates/Order/Show.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + +
    + +
    + + + +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/Order/Statistic.html b/Resources/Private/Backend/Templates/Order/Statistic.html new file mode 100644 index 00000000..114d51e8 --- /dev/null +++ b/Resources/Private/Backend/Templates/Order/Statistic.html @@ -0,0 +1,79 @@ + + + + + + + + + + +
    + +

    + OrderItemCount: {statistics.orderItemCount} +

    +

    + OrderProductCount: {statistics.orderProductCount} +

    + +
    + + + + + + + + + + + + + + + + + + + + +
     TotalAverage
    Gross: + + {statistics.orderItemGross} + + + + {statistics.orderItemAverageGross} + +
    Net: + + {statistics.orderItemNet} + + + + {statistics.orderItemAverageNet} + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/Product/List.html b/Resources/Private/Backend/Templates/Product/List.html new file mode 100644 index 00000000..7e9366d2 --- /dev/null +++ b/Resources/Private/Backend/Templates/Product/List.html @@ -0,0 +1,79 @@ + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + +   +
    + {product.sku} + + {product.title} + + {product.stock} + (!) + + + + + : + + {product.minPrice} + + + + + {product.price} + + + + +
    + + + +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/Product/Show.html b/Resources/Private/Backend/Templates/Product/Show.html new file mode 100644 index 00000000..08cb11a3 --- /dev/null +++ b/Resources/Private/Backend/Templates/Product/Show.html @@ -0,0 +1,146 @@ + + + + + + + + + +

    + +

    +

    {product.title} ({product.sku})

    + + + + + + + + +
    {product.description}
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + {product.beVariantAttribute1.title} ( + + ) + {product.beVariantAttribute2.title} ( + + ) + {product.beVariantAttribute3.title} ( + + ) + + + + +
    + + {variant.sku} + + {variant.beVariantAttributeOption1.title}{variant.beVariantAttributeOption2.title}{variant.beVariantAttributeOption2.title}{variant.stock} + + {variant.price} + +
    +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + +
    + {relatedProduct.sku} + + + {relatedProduct.title} + + + {product.stock} + (!) + + + {relatedProduct.price} + +
    +
    + + + + :
    + + + + {file.originalResource.title} + {file.originalResource.name} + +
    +
    +
    + +

    + Back to Product List +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/Variant/Edit.html b/Resources/Private/Backend/Templates/Variant/Edit.html new file mode 100644 index 00000000..3f6e1e09 --- /dev/null +++ b/Resources/Private/Backend/Templates/Variant/Edit.html @@ -0,0 +1,24 @@ + + + + + + +

    {variant.product.title} ({variant.product.sku})

    + + + + +
    + +
    + +
    + + Back to Variant + Back to Product + + +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/Variant/Show.html b/Resources/Private/Backend/Templates/Variant/Show.html new file mode 100644 index 00000000..8f290a88 --- /dev/null +++ b/Resources/Private/Backend/Templates/Variant/Show.html @@ -0,0 +1,77 @@ + + + + + + +

    {variant.product.title} ({variant.product.sku})

    + + edit + + + + + + + + + + + + + + + + +
    + + : {variant.product.beVariantAttribute1.title} + {variant.beVariantAttributeOption1.title} + + : {variant.product.beVariantAttribute2.title} + {variant.beVariantAttributeOption2.title} + + : {variant.product.beVariantAttribute3.title} + {variant.beVariantAttributeOption3.title}
    + + + + + + + + + + + + + + + + + +
    + + {variant.stock}
    + + + + {variant.price} + + {variant.priceMeasure} {variant.priceMeasureUnit}
    + + + + {variant.basePrice} + + {variant.product.basePriceMeasure} {variant.product.basePriceMeasureUnit}
    + + Back to Product + + Back to Product List + +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/VariantAttribute/Edit.html b/Resources/Private/Backend/Templates/VariantAttribute/Edit.html new file mode 100644 index 00000000..b8a04313 --- /dev/null +++ b/Resources/Private/Backend/Templates/VariantAttribute/Edit.html @@ -0,0 +1,33 @@ + + + + + + + + +
    + + +
    +
    + + +
    +
    + + +
    +
    + +
    +
    + +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/VariantAttribute/New.html b/Resources/Private/Backend/Templates/VariantAttribute/New.html new file mode 100644 index 00000000..5a1213f6 --- /dev/null +++ b/Resources/Private/Backend/Templates/VariantAttribute/New.html @@ -0,0 +1,33 @@ + + + + + + + + +
    + + +
    +
    + + +
    +
    + + +
    +
    + +
    +
    + +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/VariantSet/Edit.html b/Resources/Private/Backend/Templates/VariantSet/Edit.html new file mode 100644 index 00000000..830a0bc1 --- /dev/null +++ b/Resources/Private/Backend/Templates/VariantSet/Edit.html @@ -0,0 +1,32 @@ + + + + + + + + +
    + + +
    +
    + + +
    +
    + + +
    +
    + +
    +
    + +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/VariantSet/List.html b/Resources/Private/Backend/Templates/VariantSet/List.html new file mode 100644 index 00000000..9d60670a --- /dev/null +++ b/Resources/Private/Backend/Templates/VariantSet/List.html @@ -0,0 +1,50 @@ + + + + + + +
    + New +
    +
    + + + +
    + + + + + + + + + + + + + + + + + +
    + + + +
    + {beVariantAttribute.sku} + + + {beVariantAttribute.title} + + + Show + | + Edit + | + Delete +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/VariantSet/New.html b/Resources/Private/Backend/Templates/VariantSet/New.html new file mode 100644 index 00000000..0c5707fa --- /dev/null +++ b/Resources/Private/Backend/Templates/VariantSet/New.html @@ -0,0 +1,32 @@ + + + + + + + + +
    + + +
    +
    + + +
    +
    + + +
    +
    + +
    +
    + +
    \ No newline at end of file diff --git a/Resources/Private/Backend/Templates/VariantSet/Show.html b/Resources/Private/Backend/Templates/VariantSet/Show.html new file mode 100644 index 00000000..413cc8dc --- /dev/null +++ b/Resources/Private/Backend/Templates/VariantSet/Show.html @@ -0,0 +1,80 @@ + + + + + + +

    + +

    + +
    + Edit +
    +
    + + + + + + + + + + + + + + + + +
    + + {beVariantAttribute.sku}
    + + {beVariantAttribute.title}
    + + {beVariantAttribute.description}
    + +
    + New + +
    +
    + + + + + + + + + + + + + + + + + + +
    + +
    + + + +  
    {beVariantAttributeOption.title}{beVariantAttributeOption.sku} + Edit + + | + Delete + +
    + +

    + Back to Variant Set List +
    \ No newline at end of file diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf new file mode 100644 index 00000000..12778437 --- /dev/null +++ b/Resources/Private/Language/de.locallang.xlf @@ -0,0 +1,490 @@ + + + +
    + + + + Cart is empty. + Der Warenkorb ist leer. + + + Go to shopping cart. + Gehe zum Warenkorb. + + + + Product + Produkt + + + Stock Keeping Unit + Artikelnummer + + + SKU + Art.-Nr + + + Quantity + Anzahl + + + Unit Price + Einzelpreis + + + Subtotal + Zwischensumme + + + Tax (%s) + Umsatzsteuer (%s) + + + Price (net) + Preis (netto) + + + Price (gross) + Preis (brutto) + + + Total Price (net) + Gesamtpreis (netto) + + + Total Price (gross) + Gesamtpreis (brutto) + + + Service- and Shipping costs (net) + Service- und Versandkosten (brutto) + + + Service- and Shipping costs (gross) + Service- und Versandkosten (brutto) + + + + Order Number + Bestellnummer + + + Order Date + Bestelldatum + + + + Total Price (Gross) + Gesamtpreis + + + Total Price (Net) + Gesamtpreis (Netto) + + + + Invoice Number + Rechnungsnummer + + + Invoice Date + Rechnungsdatum + + + Billing Address + Rechnungsadresse + + + Shipping Address + Versandadresse + + + Comment + Bemerkung + + + I have read the conditions and agree to them. + Ich habe die Widerrufsbelehrung gelesen und stimme dieser zu. + + + I have read the general terms and agree to them. + Ich habe die Allgemeinen Geschäftsbedingungen gelesen und stimme diesen zu. + + + + Order Address + + + Title + Titel + + + Salutation + Anrede + + + First Name + Vorname + + + First Name + Nachname + + + Email + E-Mail + + + Company + Firma + + + Street (or Pack Station) + Straße (oder Packstation) + + + Zip + PLZ + + + City + Stadt + + + Country + Land + + + + Shipping + Versand + + + Name + Name + + + Price (gross) + Preis (Brutto) + + + Price (net) + Preis (Netto) + + + Tax + Umsatzsteuer + + + Tax Class + Steuerklasse + + + Status + Status + + + all + alle + + + open + offen + + + on hold + on Wartestellung + + + in process + in Bearbeitung + + + shipped + ausgeliefert + + + + Payment + Zahlung + + + Name + Name + + + Price (gross) + Preis (Brutto) + + + Price (net) + Preis (Netto) + + + Tax + Umsatzsteuer + + + Tax Class + Steuerklasse + + + Status + Status + + + all + alle + + + open + offen + + + pending + ausstehend + + + paid + bezahlt + + + canceled + storniert + + + + Subject for Buyer + Betreff für Käufer + + + Subject for Seller + Betreff für Verkäufer + + + + filter + filter + + + Customer + Kunde + + + Order Number + Bestellnummer + + + Invoice Number + Rechnungsnummer + + + Start Date + Start Datum + + + End Date + End Datum + + + + add to cart + in den Warenkorb + + + remove + entfernen + + + clear cart + Warenkorb löschen + + + submit order + Kostenpflichtig bestellen + + + update cart + Warenkorb aktualisieren + + + add coupon + Gutscheincode absenden + + + + Produkt - Liste + + + Produkt - Details + + + Variantgruppen Liste + + + Variantgruppen Details + + + + Filter Liste + + + + Tax Class + Steuerklasse + + + normal + normal + + + reduced + reduziert + + + free + frei + + + + Produkt + + + SKU + + + Titel + + + Teaser + + + Beschreibung + + + Preis + + + ab + + + Steuerklasse + + + Variant Set + + + Variante 1 + + + Variante 2 + + + Variante 3 + + + Variants + + + Related Products + + + Bilder + + + Dateien + + + Lagerbestand + + + + Variant Set + + + Sku + + + Title + + + Description + + + Variantattribute + + + + in den Warenkorb + + + + Tax Class + + + Name + + + Value + + + Calc + + + + Variant Set + + + SKU + + + Titel + + + Beschreibung + + + Variant + + + Variant Attribute + + + + Variant Attribute + + + SKU + + + Titel + + + Beschreibung + + + + Variant + + + Attribut 1 + + + Attribut 2 + + + Attribut 3 + + + Lagerbestand + + + Preis + + + + + + \ No newline at end of file diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf new file mode 100644 index 00000000..2aa5d100 --- /dev/null +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -0,0 +1,836 @@ + + + +
    + + + + Shopping Cart - Example Configuration + Shopping Cart - Beispielkonfiguration + + + + Shopping Cart + Shopping Cart + + + Orders + Bestellungen + + + Order Statistics + Bestellstatistik + + + Products + Produkte + + + + Cart: Mini-Cart + Cart: Mini-Warenkorb + + + Cart: Cart + Cart: Warenkorb + + + Cart: Product + Cart: Produkt + + + Cart: Orders + Cart: Bestellungen + + + + Product Id + Produkt ID + + + Cart Page Id + Warenkorb SeitenID + + + Sender email address for email to the Seller + Absender-E-Mail-Adresse für E-Mail an den Verkäufer + + + Receiver email address for email to the Seller + Empfänger-E-Mail-Adresse für E-Mail an den Verkäufer + + + Sender email address for email to the Buyer + Absender-E-Mail-Adresse für E-Mail an den Käufer + + + + Order + Bestellung + + + Order and Invoice Number + Bestell- und Rechnungsnummer + + + Purchaser + + + Addresses + Adressen + + + Price + Preis + + + Total Price + Gesamtpreis + + + Payment + Bezahlung + + + Shipping + Versand + + + User + Benutzer + + + not available + nicht verfügbar + + + Order Number + Bestellnummer + + + Order Date + Bestelldatum + + + Invoice Number + Rechnungsnummer + + + Invoice Date + Rechnungsdatum + + + Shipping Address + Versandadresse + + + Billing Address + Rechnungsadresse + + + Tax Classes + Steuerklassen + + + Currency + Währung + + + Price (Gross) + Preis (Brutto) + + + Price (Net) + Preis (Netto) + + + Total Price (Gross) + Gesamtpreis (Brutto) + + + Total Price (Net) + Gesamtpreis (Netto) + + + Additional Data + Zusätzliche Daten + + + Order PDF + Bestell PDF + + + Invoice PDF + Rechnung PDF + + + Tax + Steuer + + + Order Total Tax + Steuer (gesamt) + + + Order Products + Produkte der Bestellung + + + Order Coupons + Coupons der Bestellung + + + Shipping + Versand + + + Payment + Bezahlung + + + + Title + Titel + + + Salutation + Anrede + + + First Name + Vorname + + + Last Name + Nachname + + + Email + E-Mail + + + Company + Firma + + + Street + Straße + + + Zip + Postleitzahl + + + City + Ort + + + Country + Land + + + Phone + Telefon + + + Fax + Fax + + + + Order Tax + Umsatzsteuer + + + Tax + Umsatzsteuer + + + Tax Class + Steuerklasse + + + + Product + Produkt + + + SKU + Artikelnummer + + + Title + Titel + + + Count + Anzahl + + + Price + + + Base Price + Basispreis + + + Discount + Rabatt + + + Price (gross) + Preis (Brutto) + + + Price (net) + Preis (Netto) + + + Tax + Umsatzsteuer + + + Tax Class + Steuerklasse + + + Additional Data + Zusätzliche Daten + + + Product Additional + Product Additional + + + + Coupon + Coupon + + + Title + Titel + + + Code + Code + + + Discount + Rabatt + + + Tax Class + Steuerklasse + + + normal + normal + + + reduced + reduziert + + + free + frei + + + Tax + Umsatzsteuer + + + + Order Product Additional + + + Type + + + Key + + + Value + + + Data + + + + Order Shipping + Versandmethode + + + Name + Name + + + Price (gross) + Preis (Brutto) + + + Price (net) + Preis (Netto) + + + Tax + Umsatzsteuer + + + Tax Class + Steuerklasse + + + Status + Status + + + open + offen + + + on hold + on Wartestellung + + + in process + in Bearbeitung + + + shipped + ausgeliefert + + + Hinweis + + + + Order Payment + Bezahlmethode + + + Name + Name + + + Provider + Anbieter + + + Price (gross) + Preis (Brutto) + + + Price (net) + Preis (Netto) + + + Tax + Umsatzsteuer + + + Tax Class + Steuerklasse + + + Status + Status + + + open + offen + + + pending + ausstehend + + + paid + bezahlt + + + canceled + storniert + + + Hinweis + + + Transaḱtionen + + + + Transaḱtion + + + Transaḱtion ID + + + + Tax Class + Steuerklasse + + + Title + Titel + + + Value + Wert + + + Calc + mathematischer Wert + + + + Coupons + Coupons + + + Title + Titel + + + Code + Code + + + Is Relative Discount + Ist relativer Rabatt + + + Discount + Rabatt + + + Tax Class + Steuerklasse + + + normal + normal + + + reduced + reduziert + + + free + frei + + + Minimum Price in Cart + Minimaler Warenkorbpreis + + + Is Combinable with other Coupons + Kombinierbar mit anderen Coupons + + + Number of Coupons available + Anzahl der verfügbaren Coupons + + + Number of Coupons used + Anzahl der verwendeten Coupons + + + + + + + + + + + + Products + Produkte + + + Produkte + + + Select Controller and Action + + + List and Show products + + + Teaser product + + + Choose a product to teaser + + + Flexform + + + + Titel + + + Artikelnummer + + + Preis + + + Steuerklasse + + + normal + + + reduziert + + + frei + + + Ist Netto Preis + + + Zusätzliche Attribute + + + + Beschreibung + + + Bilder / Dateien + + + Prices + Preise + + + Variants + Varianten + + + Related Products + Verwandte Produkte + + + + Preise + + + Maßangaben + + + Lager + + + + Produkt + + + SKU + Artikelnummer + + + Titel + + + Teaser + + + Beschreibung + + + Inhalt + + + Minimale Anzahl an Produkten in einer Bestellung + + + Maximum Anzahl an Produkten in einer Bestellung + + + Prices + Preis + + + Special Prices + Spezialpreise + + + Steuerklasse + + + normal + + + reduziert + + + frei + + + Messwert + + + Messeinheit + + + Grundmesseinheit + + + keine Meßeinheit + + + Gewicht + + + Volumen + + + Länge + + + Fläche + + + Backend Varianten + + + Backend Variant Attribute + + + Backend Variant Attribut 1 + + + Backend Variant Attribut 2 + + + Backend Variant Attribut 3 + + + Frontend Varianten + + + Related Products + Verwandte Produkte + + + Related Products (from) + Verwandte Produkte (von) + + + Bilder + + + Dateien + + + Lagerbestand verwalten + + + Lagerbestand + + + + Backend Variant Attributes + Backend Variant Attribute + + + SKU + Artikelnummer + + + Title + Titel + + + Description + Beschreibung + + + Backend Variant + + + Backend Variant Attribut Optionen + + + + Backend Variant Attribute Option + Backend Variant Attribut Option + + + SKU + Artikelnummer + + + Title + Titel + + + Description + Beschreibung + + + + Varianten + + + Backend Varianten + + + Backend Varianten Attribut Option 1 + + + Backend Varianten Attribut Option 2 + + + Backend Varianten Attribut Option 3 + + + Lagerbestand + + + Preisberechnungsmethode + + + 0: Produktpreis + + + 1: Variantenpreis + + + 2: Produktpreis - Variantenpreis + + + 3: Produktpreis - (Variantenpreis %) + + + 4: Produktpreis + Variantenpreis + + + 5: Produktpreis + (Variantenpreis %) + + + + Frontend Variante + + + SKU + Artikelnummer + + + Title + Titel + + + + Special Price + Spezialpreis + + + Price + Preis + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf new file mode 100644 index 00000000..d94694ed --- /dev/null +++ b/Resources/Private/Language/locallang.xlf @@ -0,0 +1,610 @@ + + + +
    + + + + Cart is empty. + + + Go to shopping cart. + + + + Product + + + Product Id + + + Stock Keeping Unit + + + SKU + + + Quantity + + + Unit Price + + + Subtotal# + + + Tax (%s) + + + Currently there are no products in your cart. + + + Price (net) + + + Price (gross) + + + Total Price (net) + + + Total Price (gross) + + + Shipping Options + + + from + + + each + + + free shipping from + + + free shipping until + + + shipping available from + + + shipping available until + + + Service Options + + + free service option from + + + free service option until + + + service option available from + + + service option available until + + + Special Options + + + free special option from + + + free special option until + + + special option available from + + + special option available until + + + %s each + + + Service- and Shipping costs (net) + + + Service- and Shipping costs (gross) + + + Remove this product from cart. + + + Order number + + + Invoice number + + + + filter + + + Customer + + + Order Number + + + Invoice Number + + + Start Date + + + End Date + + + + add to cart + + + remove + + + clear cart + + + submit order + + + update cart + + + add coupon + + + + Actions + + + Show + + + Edit + + + List + + + Export (CSV) + + + Generate Invoice Number + + + Generate Invoice Document + + + Download Invoice Document + + + Statistic of Orders + + + + Order + + + Order and Invoice Number + + + Purchaser + + + Addresses + + + Price + + + Payment + + + Shipping + + + User + + + Order Number + + + Order Date + + + Invoice Number + + + Invoice Date + + + Shipping Address + + + Billing Address + + + Price (gross) + + + Price (net) + + + Total Price (Gross) + + + Total Price (Net) + + + Price + + + Total Price + + + Additional Data + + + Order Pdf + + + Invoice Pdf + + + Order Tax + + + Order Total Tax + + + Order Product + + + Order Shipping + + + Order Payment + + + Order Date + + + Comment + + + I have read the conditions and agree to them. + + + I have read the general terms and agree to them. + + + + Order Tax + + + Name + + + Value + + + Calc + + + Sum + + + + Order Product + + + Count + + + Price + + + Discount + + + Gross + + + Net + + + Additional Data + + + Order Product Additional + + + + Order Product Additional + + + Type + + + Key + + + Value + + + Data + + + + Shipping + + + Name + + + Gross + + + Net + + + Tax + + + Status + + + all + + + open + + + on hold + + + in process + + + shipped + + + + Payment + + + Name + + + Gross + + + Net + + + Tax + + + Status + + + all + + + open + + + pending + + + paid + + + canceled + + + + Order Address + + + Title + + + Salutation + + + First Name + + + Last Name + + + Email + + + Company + + + Street (or Pack Station) + + + Zip + + + City + + + Country + + + + Subject for Buyer + + + Subject for Seller + + + + + + Product Listing + + + Product Show + + + Variant Set Listing + + + Variant Set Show + + + + Filter List + + + + Tax Class + + + normal + + + reduced + + + free + + + + Add to cart + + + + SKU + + + Tilte + + + + Product + + + Sku + + + Title + + + Teaser + + + Description + + + Price + + + from + + + Tax Class + + + Variant Set + + + Variant Set 1 + + + Variant Set 2 + + + Variant Set 3 + + + Variants + + + Related Products + + + Images + + + Files + + + Stock + + + + Variant Set + + + Sku + + + Title + + + Description + + + Variant Attributes + + + + Tax Class + + + Name + + + Value + + + Calc + + + + Variant Attribute + + + Sku + + + Title + + + Description + + + + Variant + + + Variant Attribute 1 + + + Variant Attribute 2 + + + Variant Attribute 3 + + + Stock + + + Price + + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_address.xml b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_address.xml new file mode 100644 index 00000000..9ea66e73 --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_address.xml @@ -0,0 +1,22 @@ + + + + Context Sensitive Help (CSH) for table tx_cart_domain_model_order_address + CSH + tx_cart_domain_model_order_address + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_item.xml b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_item.xml new file mode 100644 index 00000000..03bd0aac --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_item.xml @@ -0,0 +1,22 @@ + + + + Context Sensitive Help (CSH) for table tx_cart_domain_model_order_item + CSH + tx_cart_domain_model_order_item + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_payment.xml b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_payment.xml new file mode 100644 index 00000000..251bb4bb --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_payment.xml @@ -0,0 +1,17 @@ + + + + Context Sensitive Help (CSH) for table tx_cart_domain_model_order_payment + CSH + tx_cart_domain_model_order_payment + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_product.xml b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_product.xml new file mode 100644 index 00000000..57a53e68 --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_product.xml @@ -0,0 +1,18 @@ + + + + Context Sensitive Help (CSH) for table tx_cart_domain_model_order_product + CSH + tx_cart_domain_model_order_product + + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_shipping.xml b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_shipping.xml new file mode 100644 index 00000000..f055454a --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_shipping.xml @@ -0,0 +1,17 @@ + + + + Context Sensitive Help (CSH) for table tx_cart_domain_model_order_shipping + CSH + tx_cart_domain_model_order_shipping + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_tax.xml b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_tax.xml new file mode 100644 index 00000000..373097c9 --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_order_tax.xml @@ -0,0 +1,16 @@ + + + + Context Sensitive Help (CSH) for table tx_cart_domain_model_order_tax + CSH + tx_cart_domain_model_order_tax + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_coupon.xml b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_coupon.xml new file mode 100644 index 00000000..bd09b2b2 --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_coupon.xml @@ -0,0 +1,13 @@ + + + + Context Sensitive Help (CSH) for table tx_cart_domain_model_product_coupon + CSH + tx_cart_domain_model_product_coupon + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_product.xlf b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_product.xlf new file mode 100644 index 00000000..4917bfe5 --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_product.xlf @@ -0,0 +1,20 @@ + + + +
    + + + SKU + + + Content is not used, if the product has variants. + + + Content is not used, if the product has variants. + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_taxclass.xlf b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_taxclass.xlf new file mode 100644 index 00000000..8c990f7d --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_taxclass.xlf @@ -0,0 +1,17 @@ + + + +
    + + + title + + + value + + + calc + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_variant.xlf b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_variant.xlf new file mode 100644 index 00000000..f881f2c3 --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_variant.xlf @@ -0,0 +1,17 @@ + + + +
    + + + SKU + + + Title + + + Description + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_variantattribute.xlf b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_variantattribute.xlf new file mode 100644 index 00000000..f881f2c3 --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_variantattribute.xlf @@ -0,0 +1,17 @@ + + + +
    + + + SKU + + + Title + + + Description + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_variantset.xlf b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_variantset.xlf new file mode 100644 index 00000000..f881f2c3 --- /dev/null +++ b/Resources/Private/Language/locallang_csh_tx_cart_domain_model_product_variantset.xlf @@ -0,0 +1,17 @@ + + + +
    + + + SKU + + + Title + + + Description + + + + \ No newline at end of file diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf new file mode 100644 index 00000000..0fc50b47 --- /dev/null +++ b/Resources/Private/Language/locallang_db.xlf @@ -0,0 +1,717 @@ + + + +
    + + + + Shopping Cart - Example Configuration + + + + Shopping Cart + + + Orders + + + Order Statistics + + + Products + + + + Cart: Mini-Cart + + + Cart: Cart + + + Cart: Product + + + Cart: Orders + + + + Product Id + + + Cart Page Id + + + Sender email address for email to the Seller + + + Receiver email address for email to the Seller + + + Sender email address for email to the Buyer + + + + Order + + + Order and Invoice Number + + + Purchaser + + + Addresses + + + Price + + + Total Price + + + Payment + + + Shipping + + + User + + + not available + + + Order Number + + + Order Date + + + Invoice Number + + + Invoice Date + + + Firstname + + + Lastname + + + Email + + + Billing Address + + + Shipping Address + + + Tax Classes + + + Currency + + + Price (Gross) + + + Price (Net) + + + Total Price (Gross) + + + Total Price (Net) + + + Additional Data + + + Order PDF + + + Invoice PDF + + + Tax + + + Total Tax + + + Products + + + Coupons + + + Shipping + + + Payment + + + + Title + + + Salutation + + + First Name + + + Last Name + + + Email + + + Company + + + Street + + + Zip + + + City + + + Country + + + Phone + + + Fax + + + + Order Tax + + + Tax + + + Tax Class + + + + Product + + + SKU + + + Title + + + Count + + + Price + + + Base Price + + + Discount + + + Price (gross) + + + Price (net) + + + Tax Class + + + Tax + + + Additional Data + + + Product Additional + + + + Coupon + + + Title + + + Code + + + Discount + + + Tax Class + + + normal + + + reduced + + + free + + + Tax + + + + Order Product Additional + + + Type + + + Key + + + Value + + + Data + + + + Shipping + + + Name + + + Price (gross) + + + Price (net) + + + Tax + + + Tax Class + + + Status + + + open + + + on hold + + + in process + + + shipped + + + Note + + + + Payment + + + Name + + + Provider + + + Price (gross) + + + Price (net) + + + Tax + + + Tax Class + + + Status + + + open + + + pending + + + paid + + + canceled + + + Note + + + Transactions + + + + Transaction + + + Transaction ID + + + + Order Tax Class + + + Title + + + Value + + + Calc + + + + Order Address + + + + Coupon + + + Title + + + Code + + + Is Relative Discount + + + Discount + + + Tax Class + + + normal + + + reduced + + + free + + + Minimum Price in Cart + + + Is Combinable with other Coupons + + + Number of Coupons available + + + Number of Coupons used + + + + + + + + Select Controller and Action + + + List and Show products + + + Teaser product + + + Choose a product to teaser + + + Flexform + + + + Title + + + SKU + + + Price + + + Special Prices + + + Is Net Price + + + Tax Class + + + normal + + + reduced + + + free + + + Additional Attributes + + + + Description + + + Images / Files + + + Prices + + + Special Price + + + Tax Class + + + normal + + + reduced + + + free + + + Variants + + + Related Products + + + + Prices + + + Measures + + + Stock + + + + Product + + + SKU + + + Title + + + Teaser + + + Description + + + Content + + + Minimum numbers of product items per order + + + Maximum number of product items per order + + + Price + + + Price Measure + + + Price Measure Unit + + + Base Price Measure Unit + + + No Measuring Unit + + + Weight + + + Volume + + + Length + + + Area + + + Tax Class + + + Backend Variants + + + Backend Variant Attributes + + + Backend Variant Attribute 1 + + + Backend Variant Attribute 2 + + + Backend Variant Attribute 3 + + + Frontend Variants + + + Related Products + + + Related Products (from) + + + Images + + + Files + + + Stock handling + + + Stock + + + + Tax Class + + + Title + + + Value + + + Calc + + + + Backend Variant Attribute + + + SKU + + + Title + + + Description + + + Backend Variant + + + Backend Variant Attribute Options + + + + Backend Variant Attribute Option + + + SKU + + + Title + + + Description + + + + Variants + + + Backend Variant + + + Backend Variant Attribute Option 1 + + + Backend Variant Attribute Option 2 + + + Backend Variant Attribute Option 3 + + + Stock + + + Price Calc Method + + + 0: Product Price + + + 1: Variant Price + + + 2: Product Price - Variant Price + + + 3: Product Price - (Variant Price %) + + + 4: Product Price + Variant Price + + + 5: Product Price + (Variant Price %) + + + + Frontend Variant + + + SKU + + + Title + + + + Special Price + + + Price + + + + \ No newline at end of file diff --git a/Resources/Private/Layouts/Bootstrap/Default.html b/Resources/Private/Layouts/Bootstrap/Default.html new file mode 100644 index 00000000..38108069 --- /dev/null +++ b/Resources/Private/Layouts/Bootstrap/Default.html @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/Resources/Private/Layouts/Default/Default.html b/Resources/Private/Layouts/Default/Default.html new file mode 100644 index 00000000..38108069 --- /dev/null +++ b/Resources/Private/Layouts/Default/Default.html @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/Resources/Private/Layouts/Default/Mail.html b/Resources/Private/Layouts/Default/Mail.html new file mode 100644 index 00000000..38108069 --- /dev/null +++ b/Resources/Private/Layouts/Default/Mail.html @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/Resources/Private/Layouts/Foundation/Default.html b/Resources/Private/Layouts/Foundation/Default.html new file mode 100644 index 00000000..38108069 --- /dev/null +++ b/Resources/Private/Layouts/Foundation/Default.html @@ -0,0 +1,3 @@ +
    + +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Bootstrap/Cart/Form/Address/Billing.html b/Resources/Private/Partials/Bootstrap/Cart/Form/Address/Billing.html new file mode 100644 index 00000000..d1bf54c6 --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/Form/Address/Billing.html @@ -0,0 +1,101 @@ +
    1Rechnungsadresse
    +
    +
    + + +
    + +
    +
    +
    + + +
    + +
    +
    + +
    + + +
    + +
    +
    +
    + + +
    + +
    +
    + + +
    + + +
    + +
    +
    + +
    + + +
    + +
    +
    +
    + + +
    + +
    +
    +
    + + +
    + +
    +
    +
    + + +
    + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Bootstrap/Cart/Form/Address/Shipping.html b/Resources/Private/Partials/Bootstrap/Cart/Form/Address/Shipping.html new file mode 100644 index 00000000..c3a2e707 --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/Form/Address/Shipping.html @@ -0,0 +1,102 @@ +
    Versandadresse
    +
    +
    + + +
    + +
    +
    +
    + + +
    + +
    +
    + +
    + + +
    + +
    +
    +
    + + +
    + +
    +
    + + +
    + + +
    + +
    +
    + +
    + + +
    + +
    +
    +
    + + +
    + +
    +
    +
    + + +
    + +
    +
    +
    + + +
    + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Bootstrap/Cart/Form/Cart.html b/Resources/Private/Partials/Bootstrap/Cart/Form/Cart.html new file mode 100644 index 00000000..0945d118 --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/Form/Cart.html @@ -0,0 +1,29 @@ +
    4Kassenübersicht
    +
    + +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    + + +
    + +
    +
    + + + +
    diff --git a/Resources/Private/Partials/Bootstrap/Cart/Form/PaymentMethod.html b/Resources/Private/Partials/Bootstrap/Cart/Form/PaymentMethod.html new file mode 100644 index 00000000..50b43221 --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/Form/PaymentMethod.html @@ -0,0 +1,15 @@ +
    3Zahlart
    +
    + +
    + + + {payment.name} + + + {payment.name} + + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Bootstrap/Cart/Form/ShippingMethod.html b/Resources/Private/Partials/Bootstrap/Cart/Form/ShippingMethod.html new file mode 100644 index 00000000..3d003036 --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/Form/ShippingMethod.html @@ -0,0 +1,16 @@ +
    2Versandart
    +
    + +
    + + + {shipping.name} + + + {shipping.name} + + + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Bootstrap/Cart/Product.html b/Resources/Private/Partials/Bootstrap/Cart/Product.html new file mode 100644 index 00000000..5b688f1e --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/Product.html @@ -0,0 +1,46 @@ +
    +
    {cartProduct.title}
    +
    {cartProduct.sku}
    +
    + + +   + + + + {cartProduct.price} + + + +
    +
    + {cartProduct.qty} +
    +
    + + {cartProduct.gross} + +
    +
    + delete +
    +
    + + + + + + + + +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Bootstrap/Cart/ProductList.html b/Resources/Private/Partials/Bootstrap/Cart/ProductList.html new file mode 100644 index 00000000..2042983f --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/ProductList.html @@ -0,0 +1,26 @@ +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    + + + +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Bootstrap/Cart/ProductVariant.html b/Resources/Private/Partials/Bootstrap/Cart/ProductVariant.html new file mode 100644 index 00000000..e45db3b7 --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/ProductVariant.html @@ -0,0 +1,34 @@ +{namespace cart=Extcode\Cart\ViewHelpers} + +
    +
    {variant.title}
    +
    {variant.sku}
    +
    + + {variant.price} + +
    +
    + {variant.qty} +
    +
    + + {variant.gross} + +
    +
    + delete + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Bootstrap/Cart/Service.html b/Resources/Private/Partials/Bootstrap/Cart/Service.html new file mode 100644 index 00000000..4f614b8f --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/Service.html @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Bootstrap/Cart/Special.html b/Resources/Private/Partials/Bootstrap/Cart/Special.html new file mode 100644 index 00000000..7f8faf36 --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/Special.html @@ -0,0 +1,11 @@ +

    + {special.name}: + + {special.gross} + +

    \ No newline at end of file diff --git a/Resources/Private/Partials/Bootstrap/Cart/Summary.html b/Resources/Private/Partials/Bootstrap/Cart/Summary.html new file mode 100644 index 00000000..6c4e3b7c --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/Summary.html @@ -0,0 +1,106 @@ + \ No newline at end of file diff --git a/Resources/Private/Partials/Bootstrap/Cart/Tax.html b/Resources/Private/Partials/Bootstrap/Cart/Tax.html new file mode 100644 index 00000000..31cbacfb --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/Tax.html @@ -0,0 +1,12 @@ +
    +
    +
    + + {tax} + +
    diff --git a/Resources/Private/Partials/Bootstrap/Cart/TaxList.html b/Resources/Private/Partials/Bootstrap/Cart/TaxList.html new file mode 100644 index 00000000..77ca79a1 --- /dev/null +++ b/Resources/Private/Partials/Bootstrap/Cart/TaxList.html @@ -0,0 +1,5 @@ +
    + + + +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/CartForm.html b/Resources/Private/Partials/Default/Cart/CartForm.html new file mode 100644 index 00000000..09846f65 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/CartForm.html @@ -0,0 +1,55 @@ + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + +   +
    + +
    + + + +
    +
    + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/CouponForm.html b/Resources/Private/Partials/Default/Cart/CouponForm.html new file mode 100644 index 00000000..f1517b95 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/CouponForm.html @@ -0,0 +1,17 @@ + +
    +
    +
    + + +
    + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Empty.html b/Resources/Private/Partials/Default/Cart/Empty.html new file mode 100644 index 00000000..a6434af9 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Empty.html @@ -0,0 +1,5 @@ +
    +
    + +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Form/Address/Billing.html b/Resources/Private/Partials/Default/Cart/Form/Address/Billing.html new file mode 100644 index 00000000..cab749e0 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Form/Address/Billing.html @@ -0,0 +1,124 @@ +
    +
    1
    +
    +
    +
      +
    • +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
    • +
    • + + +
      + +
      +
    • +
    • + + +
      + +
      +
    • +
    • +
      +
      + + +
      + +
      +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
    • +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Form/Address/Shipping.html b/Resources/Private/Partials/Default/Cart/Form/Address/Shipping.html new file mode 100644 index 00000000..c9f4306b --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Form/Address/Shipping.html @@ -0,0 +1,123 @@ +
    +
    +
    +
    +
      +
    • +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
    • +
    • + + +
      + +
      +
    • +
    • + + +
      + +
      +
    • +
    • +
      +
      + + +
      + +
      +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
    • +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Form/Cart.html b/Resources/Private/Partials/Default/Cart/Form/Cart.html new file mode 100644 index 00000000..70860631 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Form/Cart.html @@ -0,0 +1,47 @@ +
    +
    5Bestellübersicht
    + +
    +
    +
      +
    • +
      + +
      +
      + +
      +
    • +
    • + +
    • +
    +
    + + + + + + + + + + + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Form/Coupon.html b/Resources/Private/Partials/Default/Cart/Form/Coupon.html new file mode 100644 index 00000000..9ad6fa00 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Form/Coupon.html @@ -0,0 +1,47 @@ +
    +
    4Gutschein
    + +
    +
    + + +
      + +
    • + {coupon.title} - + + + {coupon.discount} + + + + + + Gutschein kann nicht angerechnet werden. Mindestbestellwert: + + {coupon.cartMinPrice} + + + + +
    • +
      +
    +
    + + Keine Gutscheinmöglichkeit verfügbar. + +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Form/PaymentMethod.html b/Resources/Private/Partials/Default/Cart/Form/PaymentMethod.html new file mode 100644 index 00000000..9512b0be --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Form/PaymentMethod.html @@ -0,0 +1,47 @@ +
    +
    2Versandart
    + +
    +
    +
    + +
    {payment.name}
    +
    +
      +
    • + + + + {payment.gross} + + + + + + +
    • +
    +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Form/ShippingMethod.html b/Resources/Private/Partials/Default/Cart/Form/ShippingMethod.html new file mode 100644 index 00000000..2d89e57a --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Form/ShippingMethod.html @@ -0,0 +1,48 @@ +
    +
    3Zahlmethode
    + +
    +
    +
    + +
    {shipping.name}
    +
    +
      +
    • + + + Versand + + {shipping.gross} + + + + + + +
    • +
    +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Mail/Cart.html b/Resources/Private/Partials/Default/Cart/Mail/Cart.html new file mode 100644 index 00000000..5805783f --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Mail/Cart.html @@ -0,0 +1,6 @@ +
    + + + +
    +
    diff --git a/Resources/Private/Partials/Default/Cart/Mail/Product.html b/Resources/Private/Partials/Default/Cart/Mail/Product.html new file mode 100644 index 00000000..08c8e55f --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Mail/Product.html @@ -0,0 +1,32 @@ + + +
    {product.title} - {product.feVariant.value}
    +

    + + : {product.sku} +

    + + + + {product.bestPrice} + + + + {product.quantity} + + + + {product.gross} + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Mail/ProductList.html b/Resources/Private/Partials/Default/Cart/Mail/ProductList.html new file mode 100644 index 00000000..c5f98c18 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Mail/ProductList.html @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Resources/Private/Partials/Default/Cart/Mail/ProductWithVariant.html b/Resources/Private/Partials/Default/Cart/Mail/ProductWithVariant.html new file mode 100644 index 00000000..3f8ebba7 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Mail/ProductWithVariant.html @@ -0,0 +1,94 @@ +{namespace cart=Extcode\Cart\ViewHelpers} + + + + + + + + + + +   + +
    {variant.title}
    +

    + + : {variant.sku} +

    + + + + {variant.priceCalculated} + + + + {variant.quantity} + + + + {variant.gross} + + + +
    +
    + +
    + + + +
    {product.title} - {product.feVariant.value}
    + + +   + + +   + + +   + + +   + + + + + + + + + +   + + +   + + + {product.quantity} + + + + {product.gross} + + + +   + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Mail/Summary.html b/Resources/Private/Partials/Default/Cart/Mail/Summary.html new file mode 100644 index 00000000..77c30480 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Mail/Summary.html @@ -0,0 +1,116 @@ + + + + + + + + {cart.net} + + + + + + + + + + + + {cart.gross} + + + + + + + + + + + + + + + {cart.serviceNet} + + + + + + + + + + + + {cart.serviceGross} + + + + + + + + + + + + + + + {cart.totalNet} + + + + + + + + + + + + {cart.totalGross} + + + + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Mail/TaxList.html b/Resources/Private/Partials/Default/Cart/Mail/TaxList.html new file mode 100644 index 00000000..e1ed6bcb --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Mail/TaxList.html @@ -0,0 +1,22 @@ + + + + + ( + + ) + + + + + {tax} + + + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/OrderForm.html b/Resources/Private/Partials/Default/Cart/OrderForm.html new file mode 100644 index 00000000..d3fba49c --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/OrderForm.html @@ -0,0 +1,54 @@ + +
    +
    +
    + +
      +
    • + +
    • +
    + +
    +
    +
    +
    +
    +
    + + + +
    +
    + +
    +
    + + + + +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Product.html b/Resources/Private/Partials/Default/Cart/Product.html new file mode 100644 index 00000000..0b196b47 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Product.html @@ -0,0 +1,53 @@ + + +
    {product.title} - {product.feVariant.value}
    +

    + + : {product.sku} +

    + + + + + {product.bestPrice} + + + + +
    + +
    + + + + + + {product.gross} + + + + + Mindestbestellmenge nicht erreicht. + + + Maximalbestellmenge überschritten. + + + + + + + x + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/ProductList.html b/Resources/Private/Partials/Default/Cart/ProductList.html new file mode 100644 index 00000000..5fad788b --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/ProductList.html @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Resources/Private/Partials/Default/Cart/ProductWithVariant.html b/Resources/Private/Partials/Default/Cart/ProductWithVariant.html new file mode 100644 index 00000000..99b2f087 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/ProductWithVariant.html @@ -0,0 +1,120 @@ +{namespace cart=Extcode\Cart\ViewHelpers} + + + + + + + + + + +   + +
    {variant.title}
    +

    + + : {variant.sku} +

    + + + + {variant.priceCalculated} + + + +
    + +
    + + + + + + {variant.gross} + + + + + Mindestbestellmenge nicht erreicht. + + + Maximalbestellmenge überschritten. + + + + + + + x + + + +
    +
    + +
    + + + +
    {product.title} - {product.feVariant.value}
    + + +   + + +   + + +   + + +   + + + + + + + + + +   + + +   + + +
    + {product.quantity} +
    + + + + + + {product.gross} + + + + + +   + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Service.html b/Resources/Private/Partials/Default/Cart/Service.html new file mode 100644 index 00000000..4f614b8f --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Service.html @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Special.html b/Resources/Private/Partials/Default/Cart/Special.html new file mode 100644 index 00000000..7f8faf36 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Special.html @@ -0,0 +1,11 @@ +

    + {special.name}: + + {special.gross} + +

    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/Summary.html b/Resources/Private/Partials/Default/Cart/Summary.html new file mode 100644 index 00000000..9b3e9e40 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/Summary.html @@ -0,0 +1,110 @@ + + + + + + + + {cart.net} + + + + + + + + + + + + {cart.gross} + + + + + + + + + + + + + + + {cart.serviceNet} + + + + + + + + + + + + {cart.serviceGross} + + + + + + + + + + + + + + + {cart.totalNet} + + + + + + + + + + + + {cart.totalGross} + + + + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Cart/TaxList.html b/Resources/Private/Partials/Default/Cart/TaxList.html new file mode 100644 index 00000000..3a894f07 --- /dev/null +++ b/Resources/Private/Partials/Default/Cart/TaxList.html @@ -0,0 +1,22 @@ + + + + + ( + + ) + + + + + {tax} + + + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Order/List/Item.html b/Resources/Private/Partials/Default/Order/List/Item.html new file mode 100644 index 00000000..587b0bd0 --- /dev/null +++ b/Resources/Private/Partials/Default/Order/List/Item.html @@ -0,0 +1,43 @@ + + + {orderItem.orderNumber} + + + + + + + +   + + + + + {orderItem.invoiceNumber} + + + + + + + +   + + + + + + {orderItem.totalGross} + + + + + show + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Order/Show/Address.html b/Resources/Private/Partials/Default/Order/Show/Address.html new file mode 100644 index 00000000..f711136f --- /dev/null +++ b/Resources/Private/Partials/Default/Order/Show/Address.html @@ -0,0 +1,23 @@ +
    +
    + {address.salutation} {address.title} {address.firstName} {address.lastName}
    + + {address.company}
    +
    + {address.street}
    + {address.zip} {address.city}
    + {address.country} +
    +
    +
    + + {address.email}
    +
    + + {address.phone}
    +
    + + {address.fax}
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Order/Show/Cart.html b/Resources/Private/Partials/Default/Order/Show/Cart.html new file mode 100644 index 00000000..bb471f75 --- /dev/null +++ b/Resources/Private/Partials/Default/Order/Show/Cart.html @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Order/Show/Product.html b/Resources/Private/Partials/Default/Order/Show/Product.html new file mode 100644 index 00000000..2283b69d --- /dev/null +++ b/Resources/Private/Partials/Default/Order/Show/Product.html @@ -0,0 +1,70 @@ + + + {product.sku} + + + {product.title} + + + + {product.price} + + + + + {product.discount} + + + + {product.count} + + + + {product.net} + + + + + {product.gross} + + + + + + + + {product.orderTax.tax} + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Order/Show/Properties.html b/Resources/Private/Partials/Default/Order/Show/Properties.html new file mode 100644 index 00000000..48c9e12a --- /dev/null +++ b/Resources/Private/Partials/Default/Order/Show/Properties.html @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + : + + {orderItem.orderNumber} + + + : + + {orderItem.invoiceNumber} +
    + + : + + + + + + + : + + + + +
    + + : + + {orderItem.payment.name} + + + : + + {orderItem.shipping.name} +
    + + + + + + + +
    +
    + +
    +
    + + + + : + + + +
    + +
    + + + + : + + + +
    + +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Order/Show/ServiceStatus.html b/Resources/Private/Partials/Default/Order/Show/ServiceStatus.html new file mode 100644 index 00000000..e69de29b diff --git a/Resources/Private/Partials/Default/Order/Show/Summary.html b/Resources/Private/Partials/Default/Order/Show/Summary.html new file mode 100644 index 00000000..853a6ee6 --- /dev/null +++ b/Resources/Private/Partials/Default/Order/Show/Summary.html @@ -0,0 +1,170 @@ + + + + + + + {orderItem.net} + + + + + {orderItem.gross} + + + + + + {orderTax.tax} + + + + + + + + + {orderItem.orderShipping.name} + + + + {orderItem.orderShipping.net} + + + + + {orderItem.orderShipping.gross} + + + + + + + + {orderItem.orderShipping.orderTax.tax} + + + + + + + + + + + + + + {orderItem.orderPayment.name} + + + + {orderItem.orderPayment.net} + + + + + {orderItem.orderPayment.gross} + + + + + + + + {orderItem.orderPayment.orderTax.tax} + + + + + + + + + + + + + + + + + {orderItem.totalNet} + + + + + {orderItem.totalGross} + + + + + + {orderTotalTax.tax} + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Product/BasePrice.html b/Resources/Private/Partials/Default/Product/BasePrice.html new file mode 100644 index 00000000..c8466333 --- /dev/null +++ b/Resources/Private/Partials/Default/Product/BasePrice.html @@ -0,0 +1,58 @@ + + + +
    + + {variant.priceCalculated} + / {variant.priceMeasure} {variant.priceMeasureUnit} : + + + + {variant.calculatedBasePrice} + / 1 {product.basePriceMeasureUnit} + + + --- + + +
    +
    +
    + +
    + + {product.bestSpecialPrice} + / {product.priceMeasure} {product.priceMeasureUnit} : + + + + {product.calculatedBasePrice} + / 1 {product.basePriceMeasureUnit} + + + --- + + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Product/CartForm.html b/Resources/Private/Partials/Default/Product/CartForm.html new file mode 100644 index 00000000..3d29038b --- /dev/null +++ b/Resources/Private/Partials/Default/Product/CartForm.html @@ -0,0 +1,20 @@ +{namespace cart=Extcode\Cart\ViewHelpers} + +
    + + + + + + + + + {feVariant.title}: + + + + + +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Product/Price.html b/Resources/Private/Partials/Default/Product/Price.html new file mode 100644 index 00000000..918d72a9 --- /dev/null +++ b/Resources/Private/Partials/Default/Product/Price.html @@ -0,0 +1,38 @@ + + + + {product.bestSpecialPrice} + + bisher: + + + {product.price} + + + (Sie sparen: {product.bestSpecialPricePercentageDiscount} %) + + + + + : + + + {product.minPrice} + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Product/Properties.html b/Resources/Private/Partials/Default/Product/Properties.html new file mode 100644 index 00000000..e42eacf4 --- /dev/null +++ b/Resources/Private/Partials/Default/Product/Properties.html @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + +
    + + + {cartProduct.sku} +
    + + + {cartProduct.title} +
    + + + {cartProduct.teaser} +
    + + + {cartProduct.description} +
    + + + {cartProduct.price} +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Default/Product/RelatedProduct.html b/Resources/Private/Partials/Default/Product/RelatedProduct.html new file mode 100644 index 00000000..6e76bf25 --- /dev/null +++ b/Resources/Private/Partials/Default/Product/RelatedProduct.html @@ -0,0 +1 @@ +{product.title} \ No newline at end of file diff --git a/Resources/Private/Partials/Foundation/Cart/Empty.html b/Resources/Private/Partials/Foundation/Cart/Empty.html new file mode 100644 index 00000000..737cb1e3 --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/Empty.html @@ -0,0 +1,5 @@ +
    +
    + +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Foundation/Cart/Form.html b/Resources/Private/Partials/Foundation/Cart/Form.html new file mode 100644 index 00000000..e8b61e39 --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/Form.html @@ -0,0 +1,51 @@ + +
    +
    +
    + +
      +
    • + +
    • +
    + +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + +
    +
    + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Foundation/Cart/Form/Address/Billing.html b/Resources/Private/Partials/Foundation/Cart/Form/Address/Billing.html new file mode 100644 index 00000000..878c82f2 --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/Form/Address/Billing.html @@ -0,0 +1,124 @@ +
    +
    1
    +
    +
    +
      +
    • +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
    • +
    • + + +
      + +
      +
    • +
    • + + +
      + +
      +
    • +
    • +
      +
      + + +
      + +
      +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
    • +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Foundation/Cart/Form/Address/Shipping.html b/Resources/Private/Partials/Foundation/Cart/Form/Address/Shipping.html new file mode 100644 index 00000000..06a63022 --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/Form/Address/Shipping.html @@ -0,0 +1,123 @@ +
    +
    +
    +
    +
      +
    • +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
      + + +
      + +
      +
      +
    • +
    • + + +
      + +
      +
    • +
    • + + +
      + +
      +
    • +
    • +
      +
      + + +
      + +
      +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
      +
      +
      + + +
      + +
      +
      +
      +
    • +
    +
    +
    +
    diff --git a/Resources/Private/Partials/Foundation/Cart/Form/Cart.html b/Resources/Private/Partials/Foundation/Cart/Form/Cart.html new file mode 100644 index 00000000..6729f61b --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/Form/Cart.html @@ -0,0 +1,66 @@ +
    +
    4Bestellübersicht
    + +
    +
    +
      +
    • +
      + +
      +
      + +
      +
    • +
    • + +
    • +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Foundation/Cart/Form/PaymentMethod.html b/Resources/Private/Partials/Foundation/Cart/Form/PaymentMethod.html new file mode 100644 index 00000000..b8b48666 --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/Form/PaymentMethod.html @@ -0,0 +1,47 @@ +
    +
    3Zahlmethode
    + +
    +
    +
    + +
    {payment.name}
    +
    +
      +
    • + + + + {payment.gross} + + + + + + +
    • +
    +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Foundation/Cart/Form/ShippingMethod.html b/Resources/Private/Partials/Foundation/Cart/Form/ShippingMethod.html new file mode 100644 index 00000000..36589832 --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/Form/ShippingMethod.html @@ -0,0 +1,48 @@ +
    +
    2Versandart
    + +
    +
    +
    + +
    {shipping.name}
    +
    +
      +
    • + + + Versand + + {shipping.gross} + + + + + + +
    • +
    +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Partials/Foundation/Cart/ProductList.html b/Resources/Private/Partials/Foundation/Cart/ProductList.html new file mode 100644 index 00000000..ad1e2cc2 --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/ProductList.html @@ -0,0 +1,54 @@ + + + +
    {cartProduct.title}
    +

    + + : {cartProduct.sku} +

    +

    + + + +

    + + + + +   + + + + {cartProduct.price} + + + + + +
    + {cartProduct.quantity} +
    + + + + + + {cartProduct.gross} + + + + + + +
    + diff --git a/Resources/Private/Partials/Foundation/Cart/ProductVariantList.html b/Resources/Private/Partials/Foundation/Cart/ProductVariantList.html new file mode 100644 index 00000000..7dd8e304 --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/ProductVariantList.html @@ -0,0 +1,45 @@ +{namespace cart=Extcode\Cart\ViewHelpers} + + + + + + +
    {cartProduct.title} ({variant.title})
    +

    + + : {variant.sku} +

    +

    + + + +

    + + + + {variant.price} + + + + {variant.quantity} + + + + {variant.gross} + + + +
    +
    +
    diff --git a/Resources/Private/Partials/Foundation/Cart/Service.html b/Resources/Private/Partials/Foundation/Cart/Service.html new file mode 100644 index 00000000..4f614b8f --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/Service.html @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Foundation/Cart/Special.html b/Resources/Private/Partials/Foundation/Cart/Special.html new file mode 100644 index 00000000..7f8faf36 --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/Special.html @@ -0,0 +1,11 @@ +

    + {special.name}: + + {special.gross} + +

    \ No newline at end of file diff --git a/Resources/Private/Partials/Foundation/Cart/Summary.html b/Resources/Private/Partials/Foundation/Cart/Summary.html new file mode 100644 index 00000000..22681062 --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/Summary.html @@ -0,0 +1,110 @@ + + + + + + + + {cart.net} + + + + + + + + + + + + {cart.gross} + + + + + + + + + + + + + + + {cart.serviceNet} + + + + + + + + + + + + {cart.serviceGross} + + + + + + + + + + + + + + + {cart.totalNet} + + + + + + + + + + + + {cart.totalGross} + + + + + + \ No newline at end of file diff --git a/Resources/Private/Partials/Foundation/Cart/TaxList.html b/Resources/Private/Partials/Foundation/Cart/TaxList.html new file mode 100644 index 00000000..942f8d19 --- /dev/null +++ b/Resources/Private/Partials/Foundation/Cart/TaxList.html @@ -0,0 +1,19 @@ + + + + + + + + + {tax} + + + + + \ No newline at end of file diff --git a/Resources/Private/Templates/Bootstrap/Cart/Show.html b/Resources/Private/Templates/Bootstrap/Cart/Show.html new file mode 100644 index 00000000..2093ac66 --- /dev/null +++ b/Resources/Private/Templates/Bootstrap/Cart/Show.html @@ -0,0 +1,55 @@ + + + + +
    +
    +
    + +
      +
    • + +
    • +
    + +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + +
    +
    + +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Templates/Bootstrap/Cart/ShowMini.html b/Resources/Private/Templates/Bootstrap/Cart/ShowMini.html new file mode 100644 index 00000000..1018cf1c --- /dev/null +++ b/Resources/Private/Templates/Bootstrap/Cart/ShowMini.html @@ -0,0 +1,83 @@ + + + +
    + + +
    + + + + +
    +
    + {cartProduct.title} ({variant.title}) +
    +
    + {variant.qty} +
    +
    + + {variant.gross} + +
    +
    +
    +
    +
    + +
    +
    + {cartProduct.title} +
    +
    + {cartProduct.qty} +
    +
    + + {cartProduct.gross} + +
    +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + + {cart.gross} + +
    +
    + + + + +
    + + + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Templates/Bootstrap/Product/Show.html b/Resources/Private/Templates/Bootstrap/Product/Show.html new file mode 100644 index 00000000..c96eea34 --- /dev/null +++ b/Resources/Private/Templates/Bootstrap/Product/Show.html @@ -0,0 +1,14 @@ + + + + {settings.title} +
    + + + + + +
    +
    \ No newline at end of file diff --git a/Resources/Private/Templates/Default/Cart/Mail/OrderBuyer.html b/Resources/Private/Templates/Default/Cart/Mail/OrderBuyer.html new file mode 100644 index 00000000..90b3e993 --- /dev/null +++ b/Resources/Private/Templates/Default/Cart/Mail/OrderBuyer.html @@ -0,0 +1,13 @@ + + + + + Vielen Dank für Ihre Bestellung. + + + {orderItem.orderNumber} + + + + + \ No newline at end of file diff --git a/Resources/Private/Templates/Default/Cart/Mail/OrderSeller.html b/Resources/Private/Templates/Default/Cart/Mail/OrderSeller.html new file mode 100644 index 00000000..62cb9c96 --- /dev/null +++ b/Resources/Private/Templates/Default/Cart/Mail/OrderSeller.html @@ -0,0 +1,13 @@ + + + + + Es ist folgende Bestellung eingegangen. + + + {orderItem.orderNumber} + + + + + \ No newline at end of file diff --git a/Resources/Private/Templates/Default/Cart/OrderCart.html b/Resources/Private/Templates/Default/Cart/OrderCart.html new file mode 100644 index 00000000..40bbfe3c --- /dev/null +++ b/Resources/Private/Templates/Default/Cart/OrderCart.html @@ -0,0 +1,7 @@ + + + +
    + Thank you for your order. +
    +
    \ No newline at end of file diff --git a/Resources/Private/Templates/Default/Cart/ShowCart.html b/Resources/Private/Templates/Default/Cart/ShowCart.html new file mode 100644 index 00000000..4845507e --- /dev/null +++ b/Resources/Private/Templates/Default/Cart/ShowCart.html @@ -0,0 +1,25 @@ + + + +
    + + + + + + + + + + + + +
    +
    \ No newline at end of file diff --git a/Resources/Private/Templates/Default/Order/List.html b/Resources/Private/Templates/Default/Order/List.html new file mode 100644 index 00000000..9c71c36b --- /dev/null +++ b/Resources/Private/Templates/Default/Order/List.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + +   +
    +
    +
    + + Select a Page where Order Item Dataset are saved. + +
    +
    \ No newline at end of file diff --git a/Resources/Private/Templates/Default/Order/Show.html b/Resources/Private/Templates/Default/Order/Show.html new file mode 100644 index 00000000..0a30e5e3 --- /dev/null +++ b/Resources/Private/Templates/Default/Order/Show.html @@ -0,0 +1,17 @@ + + + + + +
    + +
    + +
    + +
    + +
    + +
    +
    \ No newline at end of file diff --git a/Resources/Private/Templates/Default/Product/Flexform.html b/Resources/Private/Templates/Default/Product/Flexform.html new file mode 100644 index 00000000..c96eea34 --- /dev/null +++ b/Resources/Private/Templates/Default/Product/Flexform.html @@ -0,0 +1,14 @@ + + + + {settings.title} +
    + + + + + +
    +
    \ No newline at end of file diff --git a/Resources/Private/Templates/Default/Product/List.html b/Resources/Private/Templates/Default/Product/List.html new file mode 100644 index 00000000..3f97bf6a --- /dev/null +++ b/Resources/Private/Templates/Default/Product/List.html @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + +
    +   + + + + +
    + + + + + + + {product.title} + + +
    + +
    \ No newline at end of file diff --git a/Resources/Private/Templates/Default/Product/Show.html b/Resources/Private/Templates/Default/Product/Show.html new file mode 100644 index 00000000..7e19261b --- /dev/null +++ b/Resources/Private/Templates/Default/Product/Show.html @@ -0,0 +1,62 @@ +{namespace cart=Extcode\Cart\ViewHelpers} + + + + +

    {product.title}

    + + + + + + + + + + + +
    + + {product.teaser} + +
    +
    + + {product.description} + +
    + + + +
    + +
    +
    +
    + + + + + + + + + +
      + +
    • + +
    • +
      +
    +
    + + Back to list +
    +
    \ No newline at end of file diff --git a/Resources/Private/Templates/Default/Product/Teaser.html b/Resources/Private/Templates/Default/Product/Teaser.html new file mode 100644 index 00000000..ba160fd4 --- /dev/null +++ b/Resources/Private/Templates/Default/Product/Teaser.html @@ -0,0 +1,22 @@ + + + + + +

    {cartProduct.title}

    + + + + + +
    {product.teaser}
    + + + + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Private/Templates/Foundation/Cart/Show.html b/Resources/Private/Templates/Foundation/Cart/Show.html new file mode 100644 index 00000000..dd0d2314 --- /dev/null +++ b/Resources/Private/Templates/Foundation/Cart/Show.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Private/Templates/Foundation/Cart/ShowMini.html b/Resources/Private/Templates/Foundation/Cart/ShowMini.html new file mode 100644 index 00000000..9c998440 --- /dev/null +++ b/Resources/Private/Templates/Foundation/Cart/ShowMini.html @@ -0,0 +1,83 @@ + + + +
    + + +
    + + + + +
    +
    + {cartProduct.title} ({variant.title}) +
    +
    + {variant.qty} +
    +
    + + {variant.gross} + +
    +
    +
    +
    +
    + +
    +
    + {cartProduct.title} +
    +
    + {cartProduct.qty} +
    +
    + + {cartProduct.gross} + +
    +
    +
    +
    +
    +
    +
    + +
    + +
    +
    + + {cart.gross} + +
    +
    + + + + +
    + + + +
    +
    +
    \ No newline at end of file diff --git a/Resources/Public/Icons/Order/Address.png b/Resources/Public/Icons/Order/Address.png new file mode 100644 index 00000000..3d7f7b62 Binary files /dev/null and b/Resources/Public/Icons/Order/Address.png differ diff --git a/Resources/Public/Icons/Order/Coupon.png b/Resources/Public/Icons/Order/Coupon.png new file mode 100644 index 00000000..b27eaf94 Binary files /dev/null and b/Resources/Public/Icons/Order/Coupon.png differ diff --git a/Resources/Public/Icons/Order/Item.png b/Resources/Public/Icons/Order/Item.png new file mode 100644 index 00000000..bb2e26ec Binary files /dev/null and b/Resources/Public/Icons/Order/Item.png differ diff --git a/Resources/Public/Icons/Order/Payment.png b/Resources/Public/Icons/Order/Payment.png new file mode 100644 index 00000000..ee297e02 Binary files /dev/null and b/Resources/Public/Icons/Order/Payment.png differ diff --git a/Resources/Public/Icons/Order/Product.png b/Resources/Public/Icons/Order/Product.png new file mode 100644 index 00000000..26f49db0 Binary files /dev/null and b/Resources/Public/Icons/Order/Product.png differ diff --git a/Resources/Public/Icons/Order/ProductAdditional.png b/Resources/Public/Icons/Order/ProductAdditional.png new file mode 100644 index 00000000..c27215b3 Binary files /dev/null and b/Resources/Public/Icons/Order/ProductAdditional.png differ diff --git a/Resources/Public/Icons/Order/Shipping.png b/Resources/Public/Icons/Order/Shipping.png new file mode 100644 index 00000000..b9dbf3e5 Binary files /dev/null and b/Resources/Public/Icons/Order/Shipping.png differ diff --git a/Resources/Public/Icons/Order/Tax.png b/Resources/Public/Icons/Order/Tax.png new file mode 100644 index 00000000..813c6daf Binary files /dev/null and b/Resources/Public/Icons/Order/Tax.png differ diff --git a/Resources/Public/Icons/Order/TaxClass.png b/Resources/Public/Icons/Order/TaxClass.png new file mode 100644 index 00000000..f4a2ad4c Binary files /dev/null and b/Resources/Public/Icons/Order/TaxClass.png differ diff --git a/Resources/Public/Icons/Order/Transaction.png b/Resources/Public/Icons/Order/Transaction.png new file mode 100644 index 00000000..9d6d6d75 Binary files /dev/null and b/Resources/Public/Icons/Order/Transaction.png differ diff --git a/Resources/Public/Icons/Product/BeVariant.png b/Resources/Public/Icons/Product/BeVariant.png new file mode 100644 index 00000000..bc95b9a1 Binary files /dev/null and b/Resources/Public/Icons/Product/BeVariant.png differ diff --git a/Resources/Public/Icons/Product/BeVariantAttribute.png b/Resources/Public/Icons/Product/BeVariantAttribute.png new file mode 100644 index 00000000..07a27e61 Binary files /dev/null and b/Resources/Public/Icons/Product/BeVariantAttribute.png differ diff --git a/Resources/Public/Icons/Product/BeVariantAttributeOption.png b/Resources/Public/Icons/Product/BeVariantAttributeOption.png new file mode 100644 index 00000000..9bb25154 Binary files /dev/null and b/Resources/Public/Icons/Product/BeVariantAttributeOption.png differ diff --git a/Resources/Public/Icons/Product/Coupon.png b/Resources/Public/Icons/Product/Coupon.png new file mode 100644 index 00000000..206e4a40 Binary files /dev/null and b/Resources/Public/Icons/Product/Coupon.png differ diff --git a/Resources/Public/Icons/Product/FeVariant.png b/Resources/Public/Icons/Product/FeVariant.png new file mode 100644 index 00000000..bc95b9a1 Binary files /dev/null and b/Resources/Public/Icons/Product/FeVariant.png differ diff --git a/Resources/Public/Icons/Product/Product.png b/Resources/Public/Icons/Product/Product.png new file mode 100644 index 00000000..56a9bab6 Binary files /dev/null and b/Resources/Public/Icons/Product/Product.png differ diff --git a/Resources/Public/Icons/Product/SpecialPrice.png b/Resources/Public/Icons/Product/SpecialPrice.png new file mode 100644 index 00000000..0d99ddac Binary files /dev/null and b/Resources/Public/Icons/Product/SpecialPrice.png differ diff --git a/Resources/Public/Icons/Product/TaxClass.png b/Resources/Public/Icons/Product/TaxClass.png new file mode 100644 index 00000000..16b85f76 Binary files /dev/null and b/Resources/Public/Icons/Product/TaxClass.png differ diff --git a/Resources/Public/Icons/module.svg b/Resources/Public/Icons/module.svg new file mode 100644 index 00000000..2e6099e6 --- /dev/null +++ b/Resources/Public/Icons/module.svg @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Public/Icons/module_order_statistics.png b/Resources/Public/Icons/module_order_statistics.png new file mode 100644 index 00000000..0aca9a9f Binary files /dev/null and b/Resources/Public/Icons/module_order_statistics.png differ diff --git a/Resources/Public/Icons/module_order_statistics.svg b/Resources/Public/Icons/module_order_statistics.svg new file mode 100644 index 00000000..0aaea0da --- /dev/null +++ b/Resources/Public/Icons/module_order_statistics.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Public/Icons/module_orders.png b/Resources/Public/Icons/module_orders.png new file mode 100644 index 00000000..91f0cff8 Binary files /dev/null and b/Resources/Public/Icons/module_orders.png differ diff --git a/Resources/Public/Icons/module_orders.svg b/Resources/Public/Icons/module_orders.svg new file mode 100644 index 00000000..052537fb --- /dev/null +++ b/Resources/Public/Icons/module_orders.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Public/Icons/module_products.png b/Resources/Public/Icons/module_products.png new file mode 100644 index 00000000..035d804c Binary files /dev/null and b/Resources/Public/Icons/module_products.png differ diff --git a/Resources/Public/Icons/module_products.svg b/Resources/Public/Icons/module_products.svg new file mode 100644 index 00000000..a4c523f7 --- /dev/null +++ b/Resources/Public/Icons/module_products.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Resources/Public/Icons/pages_orders_icon.png b/Resources/Public/Icons/pages_orders_icon.png new file mode 100644 index 00000000..c71a97fc Binary files /dev/null and b/Resources/Public/Icons/pages_orders_icon.png differ diff --git a/Resources/Public/Icons/pages_products_icon.png b/Resources/Public/Icons/pages_products_icon.png new file mode 100644 index 00000000..035d804c Binary files /dev/null and b/Resources/Public/Icons/pages_products_icon.png differ diff --git a/Resources/Public/Stylesheets/Backend/style.css b/Resources/Public/Stylesheets/Backend/style.css new file mode 100644 index 00000000..0a366a34 --- /dev/null +++ b/Resources/Public/Stylesheets/Backend/style.css @@ -0,0 +1,128 @@ +.tx_cart_module_products_filter { + background-color: #dddddd; + border: 1px solid #a2aab8; + margin: 15px 0; + width: 100%; +} + +.tx_cart_module_products_filter_inner { + margin: 15px; +} + +#module_cartorders_search_form label { + width: 150px; + display: inline-block; +} + +#module_cartorders_search_form input { + width: 150px; + display: inline-block; + margin-right: 50px; +} + + +#module_cartorders_search_form .col-25 { + width: 25%; + display: block; + float: left; +} + +#module_cartorders_search_form .col-50 { + width: 50%; + display: block; + float: left; +} + +#module_cartorders_search_form .col-75 { + width: 75%; + display: block; + float: left; +} + +.download-links { + float:right; + margin-bottom: 15px; + display: block; +} + +.download-button { + background: #f6f6f6 -moz-linear-gradient(center top, #f6f6f6 10%, #d5d5d5 90%) repeat-x center bottom; + border: 1px solid #7c7c7c; + border-radius: 1px; + color: #434343; + cursor: pointer; + padding: 5px; +} + +.filter { + float:left; + margin-bottom: 15px; + display: block; +} + +.clear { + height: 1px; + clear: both; +} + +.block-left { + width: 45%; + float: left; +} + +.block-right { + width: 45%; + float: right; +} + +.label { + font-weight: bold; +} + +tr.sum { + background-color: #666; + color: #fff; +} + +.f3-widget-paginator { + display: inline-block; + border-radius: 4px; + margin: 20px 0; + padding-left: 0; +} + +.f3-widget-paginator > li { + display: inline; +} + +.f3-widget-paginator > li > a, +.f3-widget-paginator > li.current { + position: relative; + float: left; + padding: 6px 12px; + margin-left: -1px; + text-decoration: none; + border: 1px solid #DDD; + background-color: #FFF; + color: #FF8700; +} + +.f3-widget-paginator > li.current, +.f3-widget-paginator > li > a:hover, +.f3-widget-paginator > li > a:focus { + text-decoration: underline; + background-color: #EEE; +} + +.f3-widget-paginator > li:first-child > a, +.f3-widget-paginator > li.current:first-child { + margin-left: 0; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; +} + +.f3-widget-paginator > li:last-child > a, +.f3-widget-paginator > li.current:last-child { + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; +} \ No newline at end of file diff --git a/Resources/Public/Stylesheets/Default/style.css b/Resources/Public/Stylesheets/Default/style.css new file mode 100644 index 00000000..9448c5ec --- /dev/null +++ b/Resources/Public/Stylesheets/Default/style.css @@ -0,0 +1,691 @@ +.tx-cart * { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.tx-cart *:before, .tx-cart *:after { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.tx-cart textarea { + height: auto; + min-height: 50px; +} +.tx-cart select { + width: 100%; +} +.tx-cart .form-row { + width: 100%; + margin-left: auto; + margin-right: auto; + margin-top: 0; + margin-bottom: 0; + max-width: 62.5rem; +} +.tx-cart .form-row:before { + content: " "; + display: table; +} +.tx-cart .form-row:after { + content: " "; + display: table; + clear: both; +} +.tx-cart .form-row .form-row { + width: auto; + margin-left: -0.9375rem; + margin-right: -0.9375rem; + margin-top: 0; + margin-bottom: 0; + max-width: none; +} +.tx-cart .form-row .form-row:before { + content: " "; + display: table; +} +.tx-cart .form-row .form-row:after { + content: " "; + display: table; + clear: both; +} +.tx-cart .form-columns { + padding-left: 0.9375rem; + padding-right: 0.9375rem; + width: 100%; + float: left; +} +.tx-cart [class*="column"] + [class*="column"]:last-child { + float: right; +} +@media only screen { + .tx-cart .form-columns { + position: relative; + padding-left: 0.9375rem; + padding-right: 0.9375rem; + float: left; + } + .tx-cart .small-4 { + width: 33.33333%; + } + .tx-cart .small-6 { + width: 50%; + } + .tx-cart .small-8 { + width: 66.66667%; + } +} +@media only screen and (min-width: 40.063em) { + .tx-cart .form-columns { + position: relative; + padding-left: 0.9375rem; + padding-right: 0.9375rem; + float: left; + } + .tx-cart .medium-6 { + width: 50%; + } + .tx-cart .medium-12 { + width: 100%; + } +} +@media only screen and (min-width: 64.063em) { + .tx-cart .form-columns { + position: relative; + padding-left: 0.9375rem; + padding-right: 0.9375rem; + float: left; + } + .tx-cart .large-4 { + width: 33.33333%; + } + .tx-cart .large-6 { + width: 50%; + } + .tx-cart .large-8 { + width: 66.66666%; + } +} +.tx-cart form input[type="submit"] { + width: auto; +} +.tx-cart button, .tx-cart .button { + border-style: solid; + border-width: 0; + cursor: pointer; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + font-weight: normal; + line-height: normal; + margin: 0 0 1.25rem; + position: relative; + text-decoration: none; + text-align: center; + -webkit-appearance: none; + border-radius: 0; + display: inline-block; + padding-top: 1rem; + padding-right: 2rem; + padding-bottom: 1.0625rem; + padding-left: 2rem; + font-size: 1rem; + background-color: #008cba; + border-color: #007095; + color: #fff; + transition: background-color 300ms ease-out; +} +.tx-cart button:hover, .tx-cart button:focus { + color: #fff; + background-color: #007095; +} +.tx-cart .button:hover, .tx-cart .button:focus { + color: #fff; + background-color: #007095; +} +.tx-cart button::-moz-focus-inner, .tx-cart .button::-moz-focus-inner { + border: 0; + padding: 0; +} +.tx-cart button a { + color: #fff; + text-decoration: none; +} +.tx-cart button a:hover, .tx-cart button a:focus { + color: #fff; + text-decoration: none; +} +.tx-cart button.secondary { + background-color: #E9E9E9; + color: #1D1D1D; + border: 1px solid #C3C3C3; +} +.tx-cart .button.secondary { + background-color: #E9E9E9; + color: #1D1D1D; + border: 1px solid #C3C3C3; +} +.tx-cart button.secondary:hover, .tx-cart button.secondary:focus { + background-color: #b9b9b9; +} +.tx-cart .button.secondary:hover, .tx-cart .button.secondary:focus { + background-color: #b9b9b9; +} +@media only screen and (min-width: 40.063em) { + .tx-cart button { + display: inline-block; + } +} +.tx-cart form { + margin: 0 0 1rem; +} +.tx-cart form .form-row .form-row { + margin: 0 -0.5rem; +} +.tx-cart form .form-row .form-row .form-columns { + padding: 0 0.5rem; +} +.tx-cart label { + font-size: 0.875rem; + color: #4d4d4d; + cursor: pointer; + display: block; + font-weight: normal; + line-height: 1.5; + margin-bottom: 0; +} +.tx-cart input[type="text"], .tx-cart input[type="password"] { + -webkit-appearance: none; + border-radius: 0; + background-color: #fff; + font-family: inherit; + border-style: solid; + border-width: 1px; + border-color: #ccc; + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + color: rgba(0, 0, 0, 0.75); + display: block; + font-size: 0.875rem; + margin: 0 0 1rem 0; + padding: 0.5rem; + height: 2.3125rem; + width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + transition: box-shadow 0.45s, border-color 0.45s ease-in-out; +} +.tx-cart textarea { + -webkit-appearance: none; + border-radius: 0; + background-color: #fff; + font-family: inherit; + border-style: solid; + border-width: 1px; + border-color: #ccc; + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); + color: rgba(0, 0, 0, 0.75); + display: block; + font-size: 0.875rem; + margin: 0 0 1rem 0; + padding: 0.5rem; + height: 2.3125rem; + width: 100%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + transition: box-shadow 0.45s, border-color 0.45s ease-in-out; +} +.tx-cart input[type="text"]:focus, .tx-cart input[type="password"]:focus { + box-shadow: 0 0 5px #999; + border-color: #999; +} +.tx-cart textarea:focus { + box-shadow: 0 0 5px #999; + border-color: #999; +} +.tx-cart input[type="text"]:focus, .tx-cart input[type="password"]:focus { + background: #fafafa; + border-color: #999; + outline: none; +} +.tx-cart textarea:focus { + background: #fafafa; + border-color: #999; + outline: none; +} +.tx-cart input[type="text"]:disabled, .tx-cart input[type="password"]:disabled { + background-color: #ddd; + cursor: default; +} +.tx-cart textarea { + max-width: 100%; +} +.tx-cart textarea:disabled { + background-color: #ddd; + cursor: default; +} +.tx-cart select { + -webkit-appearance: none !important; + border-radius: 0; + background-color: #fafafa; + background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgeD0iMTJweCIgeT0iMHB4IiB3aWR0aD0iMjRweCIgaGVpZ2h0PSIzcHgiIHZpZXdCb3g9IjAgMCA2IDMiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDYgMyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBvbHlnb24gcG9pbnRzPSI1Ljk5MiwwIDIuOTkyLDMgLTAuMDA4LDAgIi8+PC9zdmc+); + background-position: 100% center; + background-repeat: no-repeat; + border-style: solid; + border-width: 1px; + border-color: #ccc; + padding: 0.5rem; + font-size: 0.875rem; + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + color: rgba(0, 0, 0, 0.75); + line-height: normal; + height: 2.3125rem; +} +.tx-cart select::-ms-expand { + display: none; +} +.tx-cart select:hover { + background-color: #f3f3f3; + border-color: #999; +} +.tx-cart select:disabled { + background-color: #ddd; + cursor: default; +} +.tx-cart input[type="checkbox"], .tx-cart input[type="radio"] { + margin: 0 0 1rem 0; +} +.tx-cart select { + margin: 0 0 1rem 0; +} +.tx-cart fieldset { + border: 1px solid #ddd; + padding: 1.25rem; + margin: 1.125rem 0; +} +@-webkit-keyframes rotate { + from { + -webkit-transform: rotate(0deg); + } + to { + -webkit-transform: rotate(360deg); + } +} +@-moz-keyframes rotate { + from { + -moz-transform: rotate(0deg); + } + to { + -moz-transform: rotate(360deg); + } +} +@-o-keyframes rotate { + from { + -o-transform: rotate(0deg); + } + to { + -o-transform: rotate(360deg); + } +} +@keyframes rotate { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} +.tx-cart div, .tx-cart dl, .tx-cart dt, .tx-cart dd, .tx-cart ul, .tx-cart ol, .tx-cart li, .tx-cart h1, .tx-cart h2, .tx-cart h3, .tx-cart h4, .tx-cart h5, .tx-cart h6, .tx-cart pre, .tx-cart form, .tx-cart p, .tx-cart blockquote, .tx-cart th, .tx-cart td { + margin: 0; + padding: 0; +} +.tx-cart p { + font-family: inherit; + font-weight: normal; + font-size: 1rem; + line-height: 1.6; + margin-bottom: 1.25rem; + text-rendering: optimizeLegibility; +} +.tx-cart h1, .tx-cart h2, .tx-cart h3, .tx-cart h4, .tx-cart h5, .tx-cart h6 { + font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; + font-weight: normal; + font-style: normal; + color: #222; + text-rendering: optimizeLegibility; + margin-top: 0.2rem; + margin-bottom: 0.5rem; + line-height: 1.4; +} +.tx-cart h1 { + font-size: 2.125rem; +} +.tx-cart h2 { + font-size: 1.6875rem; +} +.tx-cart h3 { + font-size: 1.375rem; +} +.tx-cart h4, .tx-cart h5 { + font-size: 1.125rem; +} +.tx-cart h6 { + font-size: 1rem; +} +.tx-cart hr { + border: solid #ddd; + border-width: 1px 0 0; + clear: both; + margin: 1.25rem 0 1.1875rem; + height: 0; +} +.tx-cart em, .tx-cart i { + font-style: italic; + line-height: inherit; +} +.tx-cart strong, .tx-cart b { + font-weight: bold; + line-height: inherit; +} +.tx-cart small { + font-size: 60%; + line-height: inherit; +} +.tx-cart code { + font-family: Consolas, "Liberation Mono", Courier, monospace; + font-weight: normal; + color: #333; + background-color: #f8f8f8; + border-width: 1px; + border-style: solid; + border-color: #dfdfdf; + padding: 0.125rem 0.3125rem 0.0625rem; +} +.tx-cart ul, .tx-cart ol, .tx-cart dl { + font-size: 1rem; + line-height: 1.6; + margin-bottom: 1.25rem; + list-style: none; + font-family: inherit; +} +.tx-cart ul { + margin-left: 1.1rem; +} +.tx-cart ul li ul { + margin-left: 1.25rem; + margin-bottom: 0; +} +.tx-cart ol { + margin-left: 1.4rem; +} +.tx-cart dl dt { + margin-bottom: 0.3rem; + font-weight: bold; +} +.tx-cart dl dd { + margin-bottom: 0.75rem; +} +.tx-cart abbr, .tx-cart acronym { + text-transform: uppercase; + font-size: 90%; + color: #222; + cursor: help; +} +.tx-cart abbr { + text-transform: none; +} +@media only screen and (min-width: 40.063em) { + .tx-cart h1, .tx-cart h2, .tx-cart h3, .tx-cart h4, .tx-cart h5, .tx-cart h6 { + line-height: 1.4; + } + .tx-cart h1 { + font-size: 2.75rem; + } + .tx-cart h2 { + font-size: 2.3125rem; + } + .tx-cart h3 { + font-size: 1.6875rem; + } + .tx-cart h4 { + font-size: 1.4375rem; + } + .tx-cart h5 { + font-size: 1.125rem; + } + .tx-cart h6 { + font-size: 1rem; + } +} +.tx-cart dialog { + visibility: hidden; + display: none; + position: absolute; + z-index: 1005; + width: 100vw; + top: 0; + border-radius: 3px; + left: 0; + background-color: #fff; + border: solid 1px #666; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.4); + padding: 1.875rem; + display: none; +} +.tx-cart dialog::backdrop, .tx-cart dialog + .backdrop { + position: absolute; + top: 0; + bottom: 0; + right: 0; + background: #000; + background: rgba(0, 0, 0, 0.45); + z-index: auto; + display: none; + left: 0; +} +@media only screen and (max-width: 40em) { + .tx-cart dialog { + min-height: 100vh; + } +} +@media only screen and (min-width: 40.063em) { + .tx-cart dialog { + width: 80%; + max-width: 62.5rem; + left: 0; + right: 0; + margin: 0 auto; + } +} +@media only screen and (min-width: 40.063em) { + .tx-cart dialog { + top: 6.25rem; + } +} +.tx-cart table { + background: #fff; + margin-bottom: 1.25rem; + border: solid 1px #ddd; + table-layout: auto; + width: 100%; + border-collapse: collapse; +} +.tx-cart table thead { + background: #f5f5f5; +} +.tx-cart table thead tr th { + padding: 0.5rem 0.625rem 0.625rem; + font-size: 0.875rem; + font-weight: bold; + color: #222; +} +.tx-cart table tfoot { + background: #f5f5f5; +} +.tx-cart table tfoot tr td { + padding: 0.5rem 0.625rem 0.625rem; + font-size: 0.875rem; + font-weight: bold; + color: #222; +} +.tx-cart table tr th, .tx-cart table tr td { + padding: 0.5625rem 0.625rem; + font-size: 0.875rem; + color: #222; + text-align: left; +} +.tx-cart table tr:nth-of-type(even) { + background: #f9f9f9; +} +.tx-cart table thead tr th, .tx-cart table tfoot tr td, .tx-cart table tbody tr td, .tx-cart table tr td { + display: table-cell; + line-height: 1.125rem; +} +.tx-cart form#form-order .form-row, .tx-cart form#form-cart .form-row { + max-width: 100%; +} +.tx-cart form#form-order .no-display, .tx-cart form#form-cart .no-display { + display: none; +} +.tx-cart form#form-order .a-center, .tx-cart form#form-cart .a-center { + text-align: center; +} +.tx-cart form#form-order .a-left, .tx-cart form#form-cart .a-left { + text-align: left; +} +.tx-cart form#form-order .a-right, .tx-cart form#form-cart .a-right { + text-align: right; +} +.tx-cart form#form-order ul, .tx-cart form#form-cart ul { + list-style: none; + padding: 0; + margin: 0; +} +.tx-cart form#form-order ul li, .tx-cart form#form-cart ul li { + padding: 0; + margin: 0; +} +.tx-cart form#form-order ul li ul, .tx-cart form#form-cart ul ul { + margin: 0; +} +.tx-cart form#form-order ul.form-list, .tx-cart form#form-cart ul.form-list, .tx-cart form#form-order ul.form-list li, .tx-cart form#form-cart ul.form-list li { + margin-bottom: 20px; +} +.tx-cart form#form-order ul.radio-list li .configuration, .tx-cart form#form-cart ul.radio-list li .configuration { + padding-left: 22px; + padding-top: 10px; +} +.tx-cart form#form-order ul.radio-list li label.checked, .tx-cart form#form-cart ul.radio-list li label.checked { + font-weight: bolder; +} +.tx-cart form#form-order ul.radio-list li label.checked + .configuration, .tx-cart form#form-cart ul.radio-list li label.checked + .configuration { + display: block; +} +.tx-cart form#form-order .form-column .form-block, .tx-cart form#form-cart .form-column .form-block { + margin-bottom: 20px; + background: #efefef; + padding: 0 20px; +} +.tx-cart form#form-order .form-column .form-block#checkout-review, .tx-cart form#form-cart .form-column .form-block#checkout-review { + padding: 0; +} +.tx-cart form#form-order .form-title, .tx-cart form#form-cart .form-title { + background: #ccc; + margin: 0 -20px 0 -20px; + padding: 0 20px; + line-height: 2; +} +.tx-cart form#form-order .form-title .num, .tx-cart form#form-cart .form-title .num { + background: #333; + color: #fff; + display: inline-block; + width: 20px; + border-radius: 50%; + text-align: center; + height: 20px; + line-height: 20px; + font-size: 0.75em; + vertical-align: middle; + margin-right: 10px; + margin-top: -3px; +} +.tx-cart form#form-order #checkout-review .form-title, .tx-cart form#form-cart #checkout-review .form-title { + margin: 0; +} +.tx-cart form#form-order .form-content *, .tx-cart form#form-cart .form-content * { + font-size: 12px; +} +.tx-cart form#form-order fieldset, .tx-cart form#form-cart fieldset { + margin: 0; + border: none; + padding: 20px 0; +} +.tx-cart form#form-order label em, .tx-cart form#form-cart label em { + color: red; + margin-right: 5px; +} +.tx-cart form#form-order label .checkbox, .tx-cart form#form-order label .radio form#form-cart label .checkbox { + margin-right: 10px; + margin-bottom: 0; +} +.tx-cart form#form-cart label .radio { + margin-right: 10px; + margin-bottom: 0; +} +.tx-cart form#form-order label .price, .tx-cart form#form-cart label .price { + font-weight: bolder; +} +.tx-cart form#form-order table tfoot tr td, .tx-cart form#form-cart table tfoot tr td { + background: #ccc; +} +.tx-cart form#form-order table tr, .tx-cart form#form-cart table tr { + border-bottom: 1px solid #999; +} +.tx-cart form#form-order table tr td, .tx-cart form#form-order table tr th { + border-right: 1px solid #999; +} +.tx-cart form#form-cart table tr td, .tx-cart form#form-cart table tr th { + border-right: 1px solid #999; +} +.tx-cart form#form-order table tr td:last-child, .tx-cart form#form-order table tr th:last-child { + border: none; +} +.tx-cart form#form-cart table tr td:last-child, .tx-cart form#form-cart table tr th:last-child { + border: none; +} +.tx-cart form#form-order table tr td p, .tx-cart form#form-order table tr th p { + margin-bottom: 0; +} +.tx-cart form#form-cart table tr td p, .tx-cart form#form-cart table tr th p { + margin-bottom: 0; +} +.tx-cart .data-table > tbody > tr.danger > td, .tx-cart .data-table > tbody > tr.danger > th { + background-color: #f2dede; +} +.tx-cart .data-table > tbody > tr > td.danger, .tx-cart .data-table > tbody > tr > th.danger { + background-color: #f2dede; +} +.tx-cart .data-table > tfoot > tr.danger > td, .tx-cart .data-table > tfoot > tr.danger > th { + background-color: #f2dede; +} +.tx-cart .data-table > tfoot > tr > td.danger, .tx-cart .data-table > tfoot > tr > th.danger { + background-color: #f2dede; +} +.tx-cart .data-table > thead > tr.danger > td, .tx-cart .data-table > thead > tr.danger > th { + background-color: #f2dede; +} +.tx-cart .table > thead > tr > td.danger, .tx-cart .table > thead > tr > th.danger { + background-color: #f2dede; +} +.tx-cart .delete-link { + background: red; + color: #fff; + display: inline-block; + width: 20px; + border-radius: 50%; + text-align: center; + height: 20px; + line-height: 20px; + font-size: 1em; + vertical-align: middle; + font-weight: bold; +} diff --git a/Tests/Unit/Controller/CartControllerTest.php b/Tests/Unit/Controller/CartControllerTest.php new file mode 100644 index 00000000..890a495d --- /dev/null +++ b/Tests/Unit/Controller/CartControllerTest.php @@ -0,0 +1,55 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +class CartControllerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * Fixture + * @var \Extcode\Cart\Controller\CartController + */ + protected $controller = null; + + public function setUp() + { + $this->controller = new \Extcode\Cart\Controller\CartController; + } + + /** + * @test + */ + public function addCouponActionAddsCouponToCart() + { + // Optional: Test anything here, if you want. + $this->assertTrue(true, 'This should already work.'); + + // Stop here and mark this test as incomplete. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/Tests/Unit/Domain/Model/Cart/BeVariantTest.php b/Tests/Unit/Domain/Model/Cart/BeVariantTest.php new file mode 100644 index 00000000..560d756a --- /dev/null +++ b/Tests/Unit/Domain/Model/Cart/BeVariantTest.php @@ -0,0 +1,445 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Variant Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class BeVariantTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + protected $taxClass = null; + + /** + * @var \Extcode\Cart\Domain\Model\Cart\BeVariant + */ + protected $beVariant = null; + + /** + * @var string + */ + protected $id; + + /** + * @var string + */ + protected $title; + + /** + * @var string + */ + protected $sku; + + /** + * @var int + */ + protected $priceCalcMethod; + + /** + * @var float + */ + protected $price; + + /** + * @var int + */ + protected $quantity; + + /** + * Set Up + */ + public function setUp() + { + $this->taxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(1, '19', 0.19, 'normal'); + + $cartProduct = $this->getMock('Extcode\\Cart\\Domain\\Model\\Cart\\Product', array(), array(), '', false); + $cartProduct->expects($this->any())->method('getTaxClass')->will($this->returnValue($this->taxClass)); + $cartProduct->expects($this->any())->method('getSku')->will($this->returnValue('test-product')); + + $this->id = '1'; + $this->title = 'Test Variant'; + $this->sku = 'test-variant-sku'; + $this->priceCalcMethod = 0; + $this->price = 1.00; + $this->quantity = 1; + + $this->beVariant = new \Extcode\Cart\Domain\Model\Cart\BeVariant( + $this->id, + $cartProduct, + null, + $this->title, + $this->sku, + $this->priceCalcMethod, + $this->price, + $this->quantity + ); + } + + /** + * @test + */ + public function getIdReturnsIdSetByConstructor() + { + $this->assertSame( + $this->id, + $this->beVariant->getId() + ); + } + + /** + * @test + */ + public function getSkuReturnsSkuSetByConstructor() + { + $sku = 'test-product' . '-' . $this->sku; + $this->assertSame( + $sku, + $this->beVariant->getSku() + ); + } + + /** + * @test + */ + public function getSkuWithSkuDelimiterReturnsSkuSetByConstructorWithGivenSkuDelimiter() + { + $skuDelimiter = '_'; + $this->beVariant->setSkuDelimiter($skuDelimiter); + + $sku = 'test-product' . $skuDelimiter . $this->sku; + $this->assertSame( + $sku, + $this->beVariant->getSku() + ); + } + + /** + * @test + */ + public function getTitleReturnsTitleSetByConstructor() + { + $this->assertSame( + $this->title, + $this->beVariant->getTitle() + ); + } + + /** + * @test + */ + public function getPriceReturnsPriceSetByConstructor() + { + $this->assertSame( + $this->price, + $this->beVariant->getPrice() + ); + } + + /** + * @test + */ + public function getPriceCalcMethodReturnsPriceCalcSetByConstructor() + { + $this->assertSame( + $this->priceCalcMethod, + $this->beVariant->getPriceCalcMethod() + ); + } + + /** + * @test + */ + public function getQuantityReturnsQuantitySetByConstructor() + { + $this->assertSame( + $this->quantity, + $this->beVariant->getQuantity() + ); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function constructVariantWithoutCartProductOrVariantThrowsInvalidArgumentException() + { + new \Extcode\Cart\Domain\Model\Cart\BeVariant( + $this->id, + null, + null, + $this->sku, + $this->title, + $this->priceCalcMethod, + $this->price, + $this->quantity + ); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function constructVariantWithCartProductAndVariantThrowsInvalidArgumentException() + { + $cartProduct = $this->getMock('Extcode\\Cart\\Domain\\Model\\Cart\\Product', array(), array(), '', false); + $cartProduct->expects($this->any())->method('getTaxClass')->will($this->returnValue($this->taxClass)); + $variant = $this->getMock('Extcode\\Cart\\Domain\\Model\\Variant', array(), array(), '', false); + $variant->expects($this->any())->method('getTaxClass')->will($this->returnValue($this->taxClass)); + + new \Extcode\Cart\Domain\Model\Cart\BeVariant( + $this->id, + $cartProduct, + $variant, + $this->sku, + $this->title, + $this->priceCalcMethod, + $this->price, + $this->quantity + ); + } + + /** + * @test + */ + public function constructWithoutTitleThrowsException() + { + $cartProduct = $this->getMock('Extcode\\Cart\\Domain\\Model\\Cart\\Product', array(), array(), '', false); + $cartProduct->expects($this->any())->method('getTaxClass')->will($this->returnValue($this->taxClass)); + + + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $title for constructor.', + 1437166475 + ); + + new \Extcode\Cart\Domain\Model\Cart\BeVariant( + 1, + $cartProduct, + null, + null, + 'test-variant-sku', + 0, + 1.0, + 1 + ); + } + + /** + * @test + */ + public function constructWithoutSkuThrowsException() + { + $cartProduct = $this->getMock('Extcode\\Cart\\Domain\\Model\\Cart\\Product', array(), array(), '', false); + $cartProduct->expects($this->any())->method('getTaxClass')->will($this->returnValue($this->taxClass)); + + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $sku for constructor.', + 1437166615 + ); + + new \Extcode\Cart\Domain\Model\Cart\BeVariant( + 1, + $cartProduct, + null, + 'Test Variant', + null, + 0, + 1.0, + 1 + ); + } + + /** + * @test + */ + public function constructWithoutQuantityThrowsException() + { + $cartProduct = $this->getMock('Extcode\\Cart\\Domain\\Model\\Cart\\Product', array(), array(), '', false); + $cartProduct->expects($this->any())->method('getTaxClass')->will($this->returnValue($this->taxClass)); + + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $quantity for constructor.', + 1437166805 + ); + + new \Extcode\Cart\Domain\Model\Cart\BeVariant( + 1, + $cartProduct, + null, + 'Test Variant', + 'test-variant-sku', + 0, + 1.0, + null + ); + } + + /** + * @test + */ + public function getMinReturnsInitialValueMin() + { + $this->assertSame( + 0, + $this->beVariant->getMin() + ); + } + + /** + * @test + */ + public function setMinIfMinIsEqualToMax() + { + $min = 1; + $max = 1; + + $this->beVariant->setMax($max); + $this->beVariant->setMin($min); + + $this->assertEquals( + $min, + $this->beVariant->getMin() + ); + } + + /** + * @test + */ + public function setMinIfMinIsLesserThanMax() + { + $min = 1; + $max = 2; + + $this->beVariant->setMax($max); + $this->beVariant->setMin($min); + + $this->assertEquals( + $min, + $this->beVariant->getMin() + ); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function throwsInvalidArgumentExceptionIfMinIsGreaterThanMax() + { + $min = 2; + $max = 1; + + $this->beVariant->setMax($max); + $this->beVariant->setMin($min); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function throwsInvalidArgumentExceptionIfMinIsNegativ() + { + $min = -1; + $max = 1; + + $this->beVariant->setMax($max); + $this->beVariant->setMin($min); + } + + /** + * @test + */ + public function getMaxReturnsInitialValueMax() + { + $this->assertSame( + 0, + $this->beVariant->getMax() + ); + } + + /** + * @test + */ + public function setMaxIfMaxIsEqualToMin() + { + $min = 1; + $max = 1; + +//sets max before because $min and $max are 0 by default + $this->beVariant->setMax($max); + $this->beVariant->setMin($min); + + $this->beVariant->setMax($max); + + $this->assertEquals( + $max, + $this->beVariant->getMax() + ); + } + + /** + * @test + */ + public function setMaxIfMaxIsGreaterThanMin() + { + $min = 1; + $max = 2; + + //sets max before because $min and $max are 0 by default + $this->beVariant->setMax($min); + $this->beVariant->setMin($min); + + $this->beVariant->setMax($max); + + $this->assertEquals( + $max, + $this->beVariant->getMax() + ); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function throwsInvalidArgumentExceptionIfMaxIsLesserThanMin() + { + $min = 2; + $max = 1; + + $this->beVariant->setMin($min); + $this->beVariant->setMax($max); + } +} diff --git a/Tests/Unit/Domain/Model/Cart/CartTest.php b/Tests/Unit/Domain/Model/Cart/CartTest.php new file mode 100644 index 00000000..beb8d7ae --- /dev/null +++ b/Tests/Unit/Domain/Model/Cart/CartTest.php @@ -0,0 +1,1453 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Cart Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class CartTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + + /** + * @var \Extcode\Cart\Domain\Model\Cart\Cart + */ + protected $grossCart = null; + + /** + * @var \Extcode\Cart\Domain\Model\Cart\Cart + */ + protected $netCart = null; + + /** + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + protected $normalTaxClass = null; + + /** + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + protected $reducedTaxClass = null; + + /** + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + protected $freeTaxClass = null; + + /** + * @var array + */ + protected $taxClasses = array(); + + /** + * + */ + public function setUp() + { + + $this->normalTaxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(1, '19', 0.19, 'Normal'); + $this->reducedTaxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(2, '7%', 0.07, 'Reduced'); + $this->freeTaxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(3, '0%', 0.00, 'Free'); + + $this->taxClasses = array( + 1 => $this->normalTaxClass, + 2 => $this->reducedTaxClass, + 3 => $this->freeTaxClass + ); + + $this->grossCart = new \Extcode\Cart\Domain\Model\Cart\Cart($this->taxClasses, false); + $this->netCart = new \Extcode\Cart\Domain\Model\Cart\Cart($this->taxClasses, true); + } + + /** + * + */ + public function tearDown() + { + unset($this->grossCart); + unset($this->netCart); + unset($taxClasses); + } + + /** + * @test + */ + public function getNetInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->grossCart->getNet() + ); + + $this->assertSame( + 0.0, + $this->netCart->getNet() + ); + } + + /** + * @test + */ + public function getSubtotalNetInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->grossCart->getSubtotalNet() + ); + + $this->assertSame( + 0.0, + $this->netCart->getSubtotalNet() + ); + } + + /** + * @test + */ + public function getTotalNetInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->grossCart->getTotalNet() + ); + + $this->assertSame( + 0.0, + $this->netCart->getTotalNet() + ); + } + + /** + * @test + */ + public function getGrossInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->grossCart->getGross() + ); + + $this->assertSame( + 0.0, + $this->netCart->getGross() + ); + } + + /** + * @test + */ + public function getTotalGrossInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->grossCart->getTotalGross() + ); + + $this->assertSame( + 0.0, + $this->netCart->getTotalGross() + ); + } + + /** + * @test + */ + public function getTaxesInitiallyReturnsEmptyArray() + { + $this->assertEmpty( + $this->grossCart->getTaxes() + ); + + $this->assertEmpty( + $this->netCart->getTaxes() + ); + } + + /** + * @test + */ + public function getCouponTaxesInitiallyReturnsEmptyArray() + { + $this->assertEmpty( + $this->grossCart->getCouponTaxes() + ); + + $this->assertEmpty( + $this->netCart->getCouponTaxes() + ); + } + + /** + * @test + */ + public function getSubtotalTaxesInitiallyReturnsEmptyArray() + { + $this->assertEmpty( + $this->grossCart->getSubtotalTaxes() + ); + + $this->assertEmpty( + $this->netCart->getSubtotalTaxes() + ); + } + + /** + * @test + */ + public function getTotalTaxesInitiallyReturnsEmptyArray() + { + $this->assertEmpty( + $this->grossCart->getTotalTaxes() + ); + + $this->assertEmpty( + $this->netCart->getTotalTaxes() + ); + } + + /** + * @test + */ + public function getCountInitiallyReturnsZero() + { + $this->assertSame( + 0, + $this->grossCart->getCount() + ); + } + + /** + * @test + */ + public function getProductsInitiallyReturnsEmptyArray() + { + $this->assertCount( + 0, + $this->grossCart->getProducts() + ); + } + + /** + * @test + */ + public function setInitiallyOrderNumberSetsOrderNumber() + { + $this->grossCart->setOrderNumber('ValidOrderNumber'); + + $this->assertSame( + 'ValidOrderNumber', + $this->grossCart->getOrderNumber() + ); + } + + /** + * @test + */ + public function resetSameOrderNumberSetsOrderNumber() + { + $this->grossCart->setOrderNumber('ValidOrderNumber'); + + $this->grossCart->setOrderNumber('ValidOrderNumber'); + + $this->assertSame( + 'ValidOrderNumber', + $this->grossCart->getOrderNumber() + ); + } + + /** + * @test + */ + public function resetDifferentOrderNumberThrowsException() + { + $this->grossCart->setOrderNumber('ValidOrderNumber'); + + $this->setExpectedException( + 'LogicException', + 'You can not redeclare the order number of your cart.', + 1413969668 + ); + + $this->grossCart->setOrderNumber('NotValidOrderNumber'); + } + + /** + * @test + */ + public function setInitiallyInvoiceNumberSetsInvoiceNumber() + { + $this->grossCart->setInvoiceNumber('ValidInvoiceNumber'); + + $this->assertSame( + 'ValidInvoiceNumber', + $this->grossCart->getInvoiceNumber() + ); + } + + /** + * @test + */ + public function resetSameInvoiceNumberSetsInvoiceNumber() + { + $this->grossCart->setInvoiceNumber('ValidInvoiceNumber'); + + $this->grossCart->setInvoiceNumber('ValidInvoiceNumber'); + + $this->assertSame( + 'ValidInvoiceNumber', + $this->grossCart->getInvoiceNumber() + ); + } + + /** + * @test + */ + public function resetDifferentInvoiceNumberThrowsException() + { + $this->grossCart->setInvoiceNumber('ValidInvoiceNumber'); + + $this->setExpectedException( + 'LogicException', + 'You can not redeclare the invoice number of your cart.', + 1413969712 + ); + + $this->grossCart->setInvoiceNumber('NotValidInvoiceNumber'); + } + + /** + * @test + */ + public function addFirstCartProductToCartChangeCountOfProducts() + { + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Product', + 10.00, + $this->normalTaxClass, + 1, + false + ); + + $this->grossCart->addProduct($product); + + $this->assertSame( + 1, + $this->grossCart->getCount() + ); + } + + // Change Net Of Cart + + /** + * @test + */ + public function addFirstGrossCartProductToGrossCartChangeNetOfCart() + { + $productPrice = 10.00; + $grossProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Gross Product', + $productPrice, + $this->normalTaxClass, + 1, + false + ); + + $this->grossCart->addProduct($grossProduct); + + $this->assertSame( + $productPrice / (1 + $this->normalTaxClass->getCalc()), + $this->grossCart->getNet() + ); + } + + /** + * @test + */ + public function addFirstNetCartProductToNetCartChangeNetOfCart() + { + $productPrice = 10.00; + $netProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Net Product', + $productPrice, + $this->normalTaxClass, + 1, + true + ); + + $this->netCart->addProduct($netProduct); + + $this->assertSame( + $productPrice, + $this->netCart->getNet() + ); + } + + /** + * @test + */ + public function addFirstGrossCartProductToNetCartChangeNetOfCart() + { + $productPrice = 10.00; + $grossProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Gross Product', + $productPrice, + $this->normalTaxClass, + 1, + false + ); + + $this->netCart->addProduct($grossProduct); + + $this->assertSame( + $productPrice / (1 + $this->normalTaxClass->getCalc()), + $this->netCart->getNet() + ); + } + + /** + * @test + */ + public function addFirstNetCartProductToGrossCartChangeNetOfCart() + { + $productPrice = 10.00; + $netProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Net Product', + $productPrice, + $this->normalTaxClass, + 1, + true + ); + + $this->grossCart->addProduct($netProduct); + + $this->assertSame( + $productPrice, + $this->grossCart->getNet() + ); + } + + // Change Gross Of Cart + + /** + * @test + */ + public function addFirstGrossCartProductToGrossCartChangeGrossOfCart() + { + $productPrice = 10.00; + $grossProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Gross Product', + $productPrice, + $this->normalTaxClass, + 1, + false + ); + + $this->grossCart->addProduct($grossProduct); + + $this->assertSame( + $productPrice, + $this->grossCart->getGross() + ); + } + + /** + * @test + */ + public function addFirstNetCartProductToNetCartChangeGrossOfCart() + { + $productPrice = 10.00; + $netProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Net Product', + $productPrice, + $this->normalTaxClass, + 1, + true + ); + + $this->netCart->addProduct($netProduct); + + $this->assertSame( + $productPrice * (1 + $this->normalTaxClass->getCalc()), + $this->netCart->getGross() + ); + } + + /** + * @test + */ + public function addFirstGrossCartProductToNetCartChangeGrossOfCart() + { + $productPrice = 10.00; + $grossProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Gross Product', + $productPrice, + $this->normalTaxClass, + 1, + false + ); + + $this->netCart->addProduct($grossProduct); + + $this->assertSame( + $productPrice, + $this->netCart->getGross() + ); + } + + /** + * @test + */ + public function addFirstNetCartProductToGrossCartChangeGrossOfCart() + { + $productPrice = 10.00; + $netProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 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() + ); + } + + /** + * @test + */ + public function addFirstCartProductToCartChangeTaxArray() + { + $taxId = 1; + $productPrice = 10.00; + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Product', + $productPrice, + $this->normalTaxClass, + 1, + false + ); + + $this->grossCart->addProduct($product); + + $cartTaxes = $this->grossCart->getTaxes(); + + $this->assertSame( + $productPrice - ($productPrice / (1 + $this->normalTaxClass->getCalc())), + $cartTaxes[$taxId] + ); + } + + /** + * @test + */ + public function addSecondCartProductWithSameTaxClassToCartChangeTaxArray() + { + $firstCartProductPrice = 10.00; + $firstCartProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1001, + 'First Product', + $firstCartProductPrice, + $this->normalTaxClass, + 1, + false + ); + $this->grossCart->addProduct($firstCartProduct); + + $secondCartProductPrice = 20.00; + $secondCartProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 2, + 0, + 0, + 1002, + 'Second Product', + $secondCartProductPrice, + $this->normalTaxClass, + 1, + false + ); + $this->grossCart->addProduct($secondCartProduct); + + $cartTaxes = $this->grossCart->getTaxes(); + + $this->assertSame( + ($firstCartProductPrice + $secondCartProductPrice) - (($firstCartProductPrice + $secondCartProductPrice) / (1 + $this->normalTaxClass->getCalc())), + $cartTaxes[$this->normalTaxClass->getId()] + ); + } + + /** + * @test + */ + public function addSecondCartProductWithDifferentTaxClassToCartChangeTaxArray() + { + $firstCartProductPrice = 10.00; + $firstCartProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1001, + 'First Product', + $firstCartProductPrice, + $this->normalTaxClass, + 1, + false + ); + $this->grossCart->addProduct($firstCartProduct); + + $secondCartProductPrice = 20.00; + $secondCartProduct = new \Extcode\Cart\Domain\Model\Cart\Product( + 2, + 0, + 0, + 1002, + 'Second Product', + $secondCartProductPrice, + $this->reducedTaxClass, + 1, + false + ); + $this->grossCart->addProduct($secondCartProduct); + + $cartTaxes = $this->grossCart->getTaxes(); + + $this->assertSame( + $firstCartProductPrice - ($firstCartProductPrice / (1 + $this->normalTaxClass->getCalc())), + $cartTaxes[$this->normalTaxClass->getId()] + ); + $this->assertSame( + $secondCartProductPrice - ($secondCartProductPrice / (1 + $this->reducedTaxClass->getCalc())), + $cartTaxes[$this->reducedTaxClass->getId()] + ); + } + + /** + * @test + */ + public function isOrderableOfEmptyCartReturnsFalse() + { + $this->assertFalse( + $this->grossCart->getIsOrderable() + ); + } + + /** + * @test + */ + public function isOrderableOfCartReturnsTrueWhenProductNumberIsInRangeForAllProducts() + { + $taxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(1, '19', 0.19, 'normal'); + + $product = $this->getMock('Extcode\\Cart\\Domain\\Model\\Cart\\Product', array(), array(), '', false); + $product->expects($this->any())->method('getId')->will($this->returnValue(1)); + $product->expects($this->any())->method('getQuantityIsInRange')->will($this->returnValue(true)); + $product->expects($this->any())->method('getTaxClass')->will($this->returnValue($taxClass)); + + $this->grossCart->addProduct($product); + + $product = $this->getMock('Extcode\\Cart\\Domain\\Model\\Cart\\Product', array(), array(), '', false); + $product->expects($this->any())->method('getId')->will($this->returnValue(2)); + $product->expects($this->any())->method('getQuantityIsInRange')->will($this->returnValue(true)); + $product->expects($this->any())->method('getTaxClass')->will($this->returnValue($taxClass)); + + $this->grossCart->addProduct($product); + + $product = $this->getMock('Extcode\\Cart\\Domain\\Model\\Cart\\Product', array(), array(), '', false); + $product->expects($this->any())->method('getId')->will($this->returnValue(3)); + $product->expects($this->any())->method('getQuantityIsInRange')->will($this->returnValue(true)); + $product->expects($this->any())->method('getTaxClass')->will($this->returnValue($taxClass)); + + $this->grossCart->addProduct($product); + + $this->assertTrue( + $this->grossCart->getIsOrderable() + ); + } + + /** + * @test + */ + public function isOrderableOfCartReturnsFalseWhenProductNumberIsNotInRangeForOneProduct() + { + $taxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(1, '19', 0.19, 'normal'); + + $product = $this->getMock('Extcode\\Cart\\Domain\\Model\\Cart\\Product', array(), array(), '', false); + $product->expects($this->any())->method('getId')->will($this->returnValue(1)); + $product->expects($this->any())->method('getQuantityIsInRange')->will($this->returnValue(true)); + $product->expects($this->any())->method('getTaxClass')->will($this->returnValue($taxClass)); + + $this->grossCart->addProduct($product); + + $product = $this->getMock('Extcode\\Cart\\Domain\\Model\\Cart\\Product', array(), array(), '', false); + $product->expects($this->any())->method('getId')->will($this->returnValue(2)); + $product->expects($this->any())->method('getQuantityIsInRange')->will($this->returnValue(false)); + $product->expects($this->any())->method('getTaxClass')->will($this->returnValue($taxClass)); + + $this->grossCart->addProduct($product); + + $product = $this->getMock('Extcode\\Cart\\Domain\\Model\\Cart\\Product', array(), array(), '', false); + $product->expects($this->any())->method('getId')->will($this->returnValue(3)); + $product->expects($this->any())->method('getQuantityIsInRange')->will($this->returnValue(true)); + $product->expects($this->any())->method('getTaxClass')->will($this->returnValue($taxClass)); + + $this->grossCart->addProduct($product); + + $this->assertFalse( + $this->grossCart->getIsOrderable() + ); + } + + /** + * @test + */ + public function getCouponsInitiallyReturnsEmptyArray() + { + $this->assertEmpty( + $this->grossCart->getCoupons() + ); + + $this->assertEmpty( + $this->netCart->getCoupons() + ); + } + + /** + * @test + */ + public function addCouponAddsNewCoupon() + { + $coupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array('getCode', 'getTitle', 'getDiscount', 'getTaxClassId'), + array(), + '', + false + ); + $coupon->expects($this->any())->method('getCode')->will($this->returnValue('couponCode')); + $coupon->expects($this->any())->method('getTitle')->will($this->returnValue('couponTitle')); + $coupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $coupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + + $this->grossCart->addCoupon($coupon); + $this->assertCount( + 1, + $this->grossCart->getCoupons() + ); + + $this->netCart->addCoupon($coupon); + $this->assertCount( + 1, + $this->netCart->getCoupons() + ); + } + + /** + * @test + */ + public function addSameCouponReturnsReturnCodeOne() + { + $coupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array('getCode', 'getTitle', 'getDiscount', 'getTaxClassId'), + array(), + '', + false + ); + $coupon->expects($this->any())->method('getCode')->will($this->returnValue('couponCode')); + $coupon->expects($this->any())->method('getTitle')->will($this->returnValue('couponTitle')); + $coupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $coupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + + $this->assertSame( + 1, + $this->grossCart->addCoupon($coupon) + ); + + $this->assertSame( + 1, + $this->netCart->addCoupon($coupon) + ); + } + + /** + * @test + */ + public function addSameCouponDoesNotChangeCouponNumberInCart() + { + $coupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array('getCode', 'getTitle', 'getDiscount', 'getTaxClassId'), + array(), + '', + false + ); + $coupon->expects($this->any())->method('getCode')->will($this->returnValue('couponCode')); + $coupon->expects($this->any())->method('getTitle')->will($this->returnValue('couponTitle')); + $coupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $coupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + + $this->grossCart->addCoupon($coupon); + $this->grossCart->addCoupon($coupon); + $this->assertCount( + 1, + $this->grossCart->getCoupons() + ); + + $this->netCart->addCoupon($coupon); + $this->netCart->addCoupon($coupon); + $this->assertCount( + 1, + $this->netCart->getCoupons() + ); + } + + /** + * @test + */ + public function addSameCouponReturnsErrorCodeMinusOne() + { + $coupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array('getCode', 'getTitle', 'getDiscount', 'getTaxClassId'), + array(), + '', + false + ); + $coupon->expects($this->any())->method('getCode')->will($this->returnValue('couponCode')); + $coupon->expects($this->any())->method('getTitle')->will($this->returnValue('couponTitle')); + $coupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $coupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + + $this->grossCart->addCoupon($coupon); + $this->assertSame( + -1, + $this->grossCart->addCoupon($coupon) + ); + + $this->netCart->addCoupon($coupon); + $this->assertSame( + -1, + $this->netCart->addCoupon($coupon) + ); + } + + /** + * @test + */ + public function addSecondNotCombinableCouponDoesNotChangeCouponNumberInCart() + { + $firstCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array('getCode', 'getTitle', 'getDiscount', 'getTaxClassId'), + array(), + '', + false + ); + $firstCoupon->expects($this->any())->method('getCode')->will($this->returnValue('firstCouponCode')); + $firstCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('firstCouponTitle')); + $firstCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $firstCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + + $secondCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array('getCode', 'getTitle', 'getDiscount', 'getTaxClassId'), + array(), + '', + false + ); + $secondCoupon->expects($this->any())->method('getCode')->will($this->returnValue('secondCouponCode')); + $secondCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('secondCouponTitle')); + $secondCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $secondCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + + $this->grossCart->addCoupon($firstCoupon); + $this->grossCart->addCoupon($secondCoupon); + $this->assertCount( + 1, + $this->grossCart->getCoupons() + ); + + $this->netCart->addCoupon($firstCoupon); + $this->netCart->addCoupon($secondCoupon); + $this->assertCount( + 1, + $this->netCart->getCoupons() + ); + } + + /** + * @test + */ + public function addSecondNotCombinableCouponReturnsReturnErrorCodeMinusTwo() + { + $firstCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array('getCode', 'getTitle', 'getDiscount', 'getTaxClassId'), + array(), + '', + false + ); + $firstCoupon->expects($this->any())->method('getCode')->will($this->returnValue('firstCouponCode')); + $firstCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('firstCouponTitle')); + $firstCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $firstCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + + $secondCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array('getCode', 'getTitle', 'getDiscount', 'getTaxClassId'), + array(), + '', + false + ); + $secondCoupon->expects($this->any())->method('getCode')->will($this->returnValue('secondCouponCode')); + $secondCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('secondCouponTitle')); + $secondCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $secondCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + + $this->grossCart->addCoupon($firstCoupon); + $this->assertSame( + -2, + $this->grossCart->addCoupon($secondCoupon) + ); + + $this->netCart->addCoupon($firstCoupon); + $this->assertSame( + -2, + $this->netCart->addCoupon($secondCoupon) + ); + } + + /** + * @test + */ + public function addSecondCombinableCouponToNotCombinableCouponsDoesNotChangeCouponNumberInCart() + { + $firstCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array('getCode', 'getTitle', 'getDiscount', 'getTaxClassId'), + array(), + '', + false + ); + $firstCoupon->expects($this->any())->method('getCode')->will($this->returnValue('firstCouponCode')); + $firstCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('firstCouponTitle')); + $firstCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $firstCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + + $secondCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array(), + array(), + '', + false + ); + $secondCoupon->expects($this->any())->method('getCode')->will($this->returnValue('secondCouponCode')); + $secondCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('secondCouponTitle')); + $secondCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $secondCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + $secondCoupon->expects($this->any())->method('getIsCombinable')->will($this->returnValue(true)); + + $this->grossCart->addCoupon($firstCoupon); + $this->grossCart->addCoupon($secondCoupon); + $this->assertCount( + 1, + $this->grossCart->getCoupons() + ); + + $this->netCart->addCoupon($firstCoupon); + $this->netCart->addCoupon($secondCoupon); + $this->assertCount( + 1, + $this->netCart->getCoupons() + ); + } + + /** + * @test + */ + public function addSecondCombinableCouponToNotCombinableCouponsReturnsReturnErrorCodeMinusTwo() + { + $firstCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array('getCode', 'getTitle', 'getDiscount', 'getTaxClassId'), + array(), + '', + false + ); + $firstCoupon->expects($this->any())->method('getCode')->will($this->returnValue('firstCouponCode')); + $firstCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('firstCouponTitle')); + $firstCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $firstCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + + $secondCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array(), + array(), + '', + false + ); + $secondCoupon->expects($this->any())->method('getCode')->will($this->returnValue('secondCouponCode')); + $secondCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('secondCouponTitle')); + $secondCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $secondCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + $secondCoupon->expects($this->any())->method('getIsCombinable')->will($this->returnValue(true)); + + $this->grossCart->addCoupon($firstCoupon); + $this->assertSame( + -2, + $this->grossCart->addCoupon($secondCoupon) + ); + + $this->netCart->addCoupon($firstCoupon); + $this->assertSame( + -2, + $this->netCart->addCoupon($secondCoupon) + ); + } + + /** + * @test + */ + public function addSecondCombinableCouponAddsCoupon() + { + $firstCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array(), + array(), + '', + false + ); + $firstCoupon->expects($this->any())->method('getCode')->will($this->returnValue('firstCouponCode')); + $firstCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('firstCouponTitle')); + $firstCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $firstCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + $firstCoupon->expects($this->any())->method('getIsCombinable')->will($this->returnValue(true)); + + $secondCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array(), + array(), + '', + false + ); + $secondCoupon->expects($this->any())->method('getCode')->will($this->returnValue('secondCouponCode')); + $secondCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('secondCouponTitle')); + $secondCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue(10.0)); + $secondCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + $secondCoupon->expects($this->any())->method('getIsCombinable')->will($this->returnValue(true)); + + $this->grossCart->addCoupon($firstCoupon); + $this->grossCart->addCoupon($secondCoupon); + $this->assertCount( + 2, + $this->grossCart->getCoupons() + ); + + $this->netCart->addCoupon($firstCoupon); + $this->netCart->addCoupon($secondCoupon); + $this->assertCount( + 2, + $this->netCart->getCoupons() + ); + } + + /** + * @test + */ + public function getCouponGrossInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->grossCart->getCouponGross() + ); + + $this->assertSame( + 0.0, + $this->netCart->getCouponGross() + ); + } + + /** + * @test + */ + public function getCouponNetInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->grossCart->getCouponNet() + ); + + $this->assertSame( + 0.0, + $this->netCart->getCouponNet() + ); + } + + /** + * @test + */ + public function getCouponGrossReturnsAllCouponsGrossSum() + { + + $gross = 10.00; + + $firstCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array(), + array(), + '', + false + ); + $firstCoupon->expects($this->any())->method('getCode')->will($this->returnValue('firstCouponCode')); + $firstCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('firstCouponTitle')); + $firstCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue($gross)); + $firstCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + $firstCoupon->expects($this->any())->method('getIsCombinable')->will($this->returnValue(true)); + + $this->grossCart->addCoupon($firstCoupon); + + $this->assertSame( + $gross, + $this->grossCart->getCouponGross() + ); + + $this->netCart->addCoupon($firstCoupon); + + $this->assertSame( + $gross, + $this->netCart->getCouponGross() + ); + } + + protected function addFirstProductToCarts() + { + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Product', + 10.00, + $this->normalTaxClass, + 1, + false + ); + + $this->grossCart->addProduct($product); + $this->netCart->addProduct($product); + } + + /** + * @test + */ + public function getCouponGrossReturnsCouponsGrossSumOfCouponsWhenCartMinPriceWasReached() + { + $this->addFirstProductToCarts(); + + $discount = 5.00; + $cartMinPrice = 15.00; + + $firstCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array(), + array(), + '', + false + ); + $firstCoupon->expects($this->any())->method('getCode')->will($this->returnValue('firstCouponCode')); + $firstCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('firstCouponTitle')); + $firstCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue($discount)); + $firstCoupon->expects($this->any())->method('getCartMinPrice')->will($this->returnValue($cartMinPrice)); + $firstCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + + $this->grossCart->addCoupon($firstCoupon); + + $this->assertSame( + 0.0, + $this->grossCart->getCouponGross() + ); + + $this->netCart->addCoupon($firstCoupon); + + $this->assertSame( + 0.0, + $this->netCart->getCouponGross() + ); + } + + /** + * @test + */ + public function getCouponNetReturnsAllCouponsNetSum() + { + $discount = 10.00; + $net = $discount / ($this->normalTaxClass->getCalc() + 1); + + $firstCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array(), + array(), + '', + false + ); + $firstCoupon->expects($this->any())->method('getCode')->will($this->returnValue('firstCouponCode')); + $firstCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('firstCouponTitle')); + $firstCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue($discount)); + $firstCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + $firstCoupon->expects($this->any())->method('getIsCombinable')->will($this->returnValue(true)); + + $this->grossCart->addCoupon($firstCoupon); + + $this->assertSame( + $net, + $this->grossCart->getCouponNet() + ); + + $this->netCart->addCoupon($firstCoupon); + + $this->assertSame( + $net, + $this->netCart->getCouponNet() + ); + } + + /** + * @test + */ + public function getCouponTaxReturnsAllCouponsTaxSum() + { + $gross = 10.00; + $net = $gross / 1.19; + $tax = $gross - $net; + + $firstCoupon = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Product\\Coupon', + array(), + array(), + '', + false + ); + $firstCoupon->expects($this->any())->method('getCode')->will($this->returnValue('firstCouponCode')); + $firstCoupon->expects($this->any())->method('getTitle')->will($this->returnValue('firstCouponTitle')); + $firstCoupon->expects($this->any())->method('getDiscount')->will($this->returnValue($gross)); + $firstCoupon->expects($this->any())-> + method('getTaxClassId')-> + will($this->returnValue($this->normalTaxClass->getId())); + $firstCoupon->expects($this->any())->method('getIsCombinable')->will($this->returnValue(true)); + + $this->grossCart->addCoupon($firstCoupon); + + $this->assertArraySubset( + array($this->normalTaxClass->getId() => $tax), + $this->grossCart->getCouponTaxes() + ); + + $this->netCart->addCoupon($firstCoupon); + + $this->assertArraySubset( + array($this->normalTaxClass->getId() => $tax), + $this->netCart->getCouponTaxes() + ); + } + + /** + * @test + */ + public function getSubtotalGrossInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->grossCart->getSubtotalGross() + ); + + $this->assertSame( + 0.0, + $this->netCart->getSubtotalGross() + ); + } + + /** + * @test + */ + public function getSubtotalGrossReturnsSubtotalGross() + { + $price = 100.00; + $couponGross = 10.00; + + $cart = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Cart\\Cart', + array('getCouponGross'), + array(), + '', + false + ); + $cart->expects($this->any())->method('getCouponGross')->will($this->returnValue($couponGross)); + + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Product', + 100.00, + $this->normalTaxClass, + 1, + false + ); + + $cart->addProduct($product); + + $this->assertSame( + $price - $couponGross, + $cart->getSubtotalGross() + ); + } + + /** + * @test + */ + public function getSubtotalNetReturnsSubtotalNet() + { + $price = 100.00; + $couponGross = 10.00; + $couponNet = $couponGross / 1.19; + + $cart = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Cart\\Cart', + array('getCouponNet'), + array(), + '', + false + ); + $cart->expects($this->any())->method('getCouponNet')->will($this->returnValue($couponNet)); + + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + 1, + 0, + 0, + 1, + 'First Product', + $price, + $this->normalTaxClass, + 1, + false + ); + $cart->addProduct($product); + + $subtotalNet = ($price / (1 + $this->normalTaxClass->getCalc())) - $couponNet; + + $this->assertSame( + $subtotalNet, + $cart->getSubtotalNet() + ); + } + +} diff --git a/Tests/Unit/Domain/Model/Cart/CouponTest.php b/Tests/Unit/Domain/Model/Cart/CouponTest.php new file mode 100644 index 00000000..4026e092 --- /dev/null +++ b/Tests/Unit/Domain/Model/Cart/CouponTest.php @@ -0,0 +1,373 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Coupon Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class CouponTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Cart\Coupon + */ + protected $coupon = null; + + /** + * Title + * + * @var string + */ + protected $title; + + /** + * Code + * + * @var string + */ + protected $code; + + /** + * Discount + * + * @var float + */ + protected $discount; + + /** + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + protected $taxClass = null; + + /** + * Cart Min Price + * + * @var float + */ + protected $cartMinPrice = 0.0; + + /** + * + */ + public function setUp() + { + $this->taxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(1, '19', 0.19, 'normal'); + + $this->title = 'CouponTitle'; + $this->code = 'CouponTitle'; + $this->discount = 10.00; + + $this->coupon = new \Extcode\Cart\Domain\Model\Cart\Coupon( + $this->title, + $this->code, + $this->discount, + $this->taxClass, + $this->cartMinPrice + ); + } + + /** + * @test + */ + public function constructCouponWithoutTitleThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $title for constructor.', + 1448230010 + ); + + $this->coupon = new \Extcode\Cart\Domain\Model\Cart\Coupon( + null, + $this->code, + $this->discount, + $this->taxClass, + $this->cartMinPrice + ); + } + + /** + * @test + */ + public function constructCouponWithoutCodeThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $code for constructor.', + 1448230020 + ); + + $this->coupon = new \Extcode\Cart\Domain\Model\Cart\Coupon( + $this->title, + null, + $this->discount, + $this->taxClass, + $this->cartMinPrice + ); + } + + /** + * @test + */ + public function constructCouponWithoutDiscountThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $discount for constructor.', + 1448230030 + ); + + $this->coupon = new \Extcode\Cart\Domain\Model\Cart\Coupon( + $this->title, + $this->code, + null, + $this->taxClass, + $this->cartMinPrice + ); + } + + /** + * @test + */ + public function constructCouponWithoutTaxClassThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $taxClass for constructor.', + 1448230040 + ); + + $this->coupon = new \Extcode\Cart\Domain\Model\Cart\Coupon( + $this->title, + $this->code, + $this->discount, + null, + $this->cartMinPrice + ); + } + + /** + * @test + */ + public function getIsCombinableInitiallyReturnsFalse() + { + $this->assertFalse( + $this->coupon->getIsCombinable() + ); + } + + /** + * @test + */ + public function constructorSetsIsCombinable() + { + $coupon = new \Extcode\Cart\Domain\Model\Cart\Coupon( + $this->title, + $this->code, + $this->discount, + $this->taxClass, + $this->cartMinPrice, + true + ); + + $this->assertTrue( + $coupon->getIsCombinable() + ); + } + + /** + * @test + */ + public function getDiscountInitiallyReturnsDiscountSetDirectlyByConstructor() + { + $this->assertSame( + 10.00, + $this->coupon->getDiscount() + ); + } + + /** + * @test + */ + public function getGrossInitiallyReturnsGrossSetDirectlyByConstructor() + { + $this->assertSame( + 10.00, + $this->coupon->getGross() + ); + } + + /** + * @test + */ + public function getNetInitiallyReturnsNetSetIndirectlyByConstructor() + { + $net = $this->discount / ($this->taxClass->getCalc() + 1); + $this->assertSame( + $net, + $this->coupon->getNet() + ); + } + + /** + * @test + */ + public function getTaxClassInitiallyReturnsTaxClassSetDirectlyByConstructor() + { + $this->assertSame( + $this->taxClass, + $this->coupon->getTaxClass() + ); + } + + /** + * @test + */ + public function getTaxInitiallyReturnsTaxSetIndirectlyByConstructor() + { + $tax = $this->discount - ($this->discount / ($this->taxClass->getCalc() + 1)); + + $this->assertSame( + $tax, + $this->coupon->getTax() + ); + } + + /** + * @test + */ + public function getCartMinPriceInitiallyReturnsCartMinPriceSetDirectlyByConstructor() + { + $this->assertSame( + $this->cartMinPrice, + $this->coupon->getCartMinPrice() + ); + } + + /** + * @test + */ + public function IsUsableReturnsTrueIfCartMinPriceIsLessToGivenPrice() + { + $gross = 10.00; + $discount = 5.00; + $cartMinPrice = 9.99; + + $cart = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Cart\\Cart', + array('getGross'), + array(), + '', + false + ); + $cart->expects($this->any())->method('getGross')->will($this->returnValue($gross)); + + $coupon = new \Extcode\Cart\Domain\Model\Cart\Coupon( + $this->title, + $this->code, + $discount, + $this->taxClass, + $cartMinPrice, + true + ); + $coupon->setCart($cart); + + $this->assertTrue( + $coupon->getIsUseable() + ); + } + + /** + * @test + */ + public function IsUsableReturnsTrueIfCartMinPriceIsEqualToGivenPrice() + { + $gross = 10.00; + $discount = 5.00; + $cartMinPrice = 10.00; + + $cart = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Cart\\Cart', + array('getGross'), + array(), + '', + false + ); + $cart->expects($this->any())->method('getGross')->will($this->returnValue($gross)); + + $coupon = new \Extcode\Cart\Domain\Model\Cart\Coupon( + $this->title, + $this->code, + $discount, + $this->taxClass, + $cartMinPrice, + true + ); + $coupon->setCart($cart); + + $this->assertTrue( + $coupon->getIsUseable() + ); + } + + /** + * @test + */ + public function IsUsableReturnsFalseIfCartMinPriceIsGreaterToGivenPrice() + { + $gross = 10.00; + $discount = 5.00; + $cartMinPrice = 10.01; + + $cart = $this->getMock( + 'Extcode\\Cart\\Domain\\Model\\Cart\\Cart', + array('getGross'), + array(), + '', + false + ); + $cart->expects($this->any())->method('getGross')->will($this->returnValue($gross)); + + $coupon = new \Extcode\Cart\Domain\Model\Cart\Coupon( + $this->title, + $this->code, + $discount, + $this->taxClass, + $cartMinPrice, + true + ); + $coupon->setCart($cart); + + $this->assertFalse( + $coupon->getIsUseable() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Cart/PaymentTest.php b/Tests/Unit/Domain/Model/Cart/PaymentTest.php new file mode 100644 index 00000000..470b4d3e --- /dev/null +++ b/Tests/Unit/Domain/Model/Cart/PaymentTest.php @@ -0,0 +1,121 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Payment Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class PaymentTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * Id + * + * @var int + */ + protected $id; + + /** + * Name + * + * @var string + */ + protected $name; + + /** + * Status + * + * @var int + */ + protected $status; + + /** + * Note + * + * @var string + */ + protected $note; + + /** + * Is Net Price + * + * @var bool + */ + protected $isNetPrice; + + /** + * Tax Class + * + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass + */ + protected $taxClass; + + /** + * Payment + * + * @var \Extcode\Cart\Domain\Model\Cart\Payment $payment + */ + protected $payment; + + /** + * + */ + public function setUp() + { + $this->taxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(1, '19', 0.19, 'normal'); + + $this->id = 1; + $this->name = 'Service'; + $this->status = 0; + $this->note = 'note'; + $this->isNetPrice = 0; + + $this->payment = new \Extcode\Cart\Domain\Model\Cart\Payment( + $this->id, + $this->name, + $this->taxClass, + $this->status, + $this->note, + $this->isNetPrice + ); + } + + /** + * @test + */ + public function getCartProductIdReturnsProductIdSetByConstructor() + { + $this->assertSame( + $this->id, + $this->payment->getId() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Cart/ProductTest.php b/Tests/Unit/Domain/Model/Cart/ProductTest.php new file mode 100644 index 00000000..c8f9ab59 --- /dev/null +++ b/Tests/Unit/Domain/Model/Cart/ProductTest.php @@ -0,0 +1,1206 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Product Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class ProductTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + + /** + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + protected $taxClass = null; + + /** + * @var \Extcode\Cart\Domain\Model\Cart\Product + */ + protected $product = null; + + /** + * @var int + */ + protected $productId; + + /** + * @var int + */ + protected $tableId; + + /** + * @var int + */ + protected $contentId; + + /** + * @var string + */ + protected $title; + + /** + * @var string + */ + protected $sku; + + /** + * @var float + */ + protected $price; + + /** + * @var integer + */ + protected $quantity; + + /** + * + */ + public function setUp() + { + $this->taxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(1, '19', 0.19, 'normal'); + + $this->productId = 1001; + $this->tableId = 1002; + $this->contentId = 1003; + $this->title = 'Test Product'; + $this->sku = 'test-product-sku'; + $this->price = 10.00; + $this->quantity = 1; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $this->quantity + ); + } + + /** + * + */ + public function tearDown() + { + unset($this->product); + + unset($this->productId); + unset($this->tableId); + unset($this->contentId); + unset($this->title); + unset($this->sku); + unset($this->price); + unset($this->quantity); + + unset($this->taxClass); + } + + /** + * @test + */ + public function constructCartProductWithoutProductIdThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $productId for constructor.', + 1413999100 + ); + + new \Extcode\Cart\Domain\Model\Cart\Product( + null, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $this->quantity + ); + } + + /** + * @test + */ + public function constructCartProductWithoutSkuThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $sku for constructor.', + 1413999110 + ); + + new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + null, + $this->title, + $this->price, + $this->taxClass, + $this->quantity + ); + } + + /** + * @test + */ + public function constructCartProductWithoutTitleThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $title for constructor.', + 1413999120 + ); + + new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + null, + $this->price, + $this->taxClass, + $this->quantity + ); + } + + /** + * @test + */ + public function constructCartProductWithoutPriceThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $price for constructor.', + 1413999130 + ); + + new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + null, + $this->taxClass, + $this->quantity + ); + } + + /** + * @test + */ + public function constructCartProductWithoutTaxClassThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $taxClass for constructor.', + 1413999140 + ); + + new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + null, + $this->quantity + ); + } + + /** + * @test + */ + public function constructCartProductWithoutQuantityThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $quantity for constructor.', + 1413999150 + ); + + new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + null + ); + } + + /** + * @test + */ + public function getCartProductIdReturnsProductIdSetByConstructor() + { + $this->assertSame( + $this->productId, + $this->product->getProductId() + ); + } + + /** + * @test + */ + public function getTableIdReturnsTableIdSetByConstructor() + { + $this->assertSame( + $this->tableId, + $this->product->getTableId() + ); + } + + /** + * @test + */ + public function getIdForTableProductReturnsTableProductIdSetIndirectlyByConstructor() + { + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + null, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $this->quantity + ); + + $this->assertSame( + 't_' . $this->tableId . '_' . $this->productId, + $product->getId() + ); + } + + /** + * @test + */ + public function getIdForFlexformProductReturnsTableProductIdSetIndirectlyByConstructor() + { + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + null, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $this->quantity + ); + + $this->assertSame( + 'c_' . $this->contentId . '_' . $this->productId, + $product->getId() + ); + } + + /** + * @test + */ + public function getContentIdReturnsContentIdSetByConstructor() + { + $this->assertSame( + $this->contentId, + $this->product->getContentId() + ); + } + + /** + * @test + */ + public function getSkuReturnsSkuSetByConstructor() + { + $this->assertSame( + $this->sku, + $this->product->getSku() + ); + } + + /** + * @test + */ + public function getTitleReturnsTitleSetByConstructor() + { + $this->assertSame( + $this->title, + $this->product->getTitle() + ); + } + + /** + * @test + */ + public function getPriceReturnsPriceSetByConstructor() + { + $this->assertSame( + $this->price, + $this->product->getPrice() + ); + } + + /** + * @test + */ + public function getSpecialPriceInitiallyReturnsNull() + { + $this->assertSame( + null, + $this->product->getSpecialPrice() + ); + } + + /** + * @test + */ + public function setSpecialPriceSetsSpecialPrice() + { + $price = 10.00; + $specialPrice = 1.00; + + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + null, + $this->contentId, + $this->sku, + $this->title, + $price, + $this->taxClass, + $this->quantity + ); + $product->setSpecialPrice($specialPrice); + + $this->assertSame( + $specialPrice, + $product->getSpecialPrice() + ); + } + + /** + * @test + */ + public function getSpecialPriceDiscountForEmptySpecialPriceReturnsDiscount() + { + $price = 10.00; + + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + null, + $this->contentId, + $this->sku, + $this->title, + $price, + $this->taxClass, + $this->quantity + ); + + $this->assertSame( + 0.0, + $product->getSpecialPriceDiscount() + ); + } + + /** + * @test + */ + public function getSpecialPriceDiscountForZeroPriceReturnsZero() + { + $price = 0.0; + $specialPrice = 0.00; + + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + null, + $this->contentId, + $this->sku, + $this->title, + $price, + $this->taxClass, + $this->quantity + ); + $product->setSpecialPrice($specialPrice); + + $this->assertSame( + 0.0, + $product->getSpecialPriceDiscount() + ); + } + + /** + * @test + */ + public function getSpecialPriceDiscountForGivenSpecialPriceReturnsPercentageDiscount() + { + $price = 10.00; + $specialPrice = 9.00; + + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + null, + $this->contentId, + $this->sku, + $this->title, + $price, + $this->taxClass, + $this->quantity + ); + $product->setSpecialPrice($specialPrice); + + $this->assertSame( + 10.0, + $product->getSpecialPriceDiscount() + ); + } + + /** + * @test + */ + public function getBestPriceInitiallyReturnsPrice() + { + $price = 10.00; + + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + null, + $this->contentId, + $this->sku, + $this->title, + $price, + $this->taxClass, + $this->quantity + ); + + $this->assertSame( + 10.0, + $product->getBestPrice() + ); + } + + /** + * @test + */ + public function getBestPriceReturnsPriceWhenPriceIsLessThanSpecialPrice() + { + $price = 10.00; + $specialPrice = 11.00; + + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + null, + $this->contentId, + $this->sku, + $this->title, + $price, + $this->taxClass, + $this->quantity + ); + $product->setSpecialPrice($specialPrice); + + $this->assertSame( + 10.0, + $product->getBestPrice() + ); + } + + /** + * @test + */ + public function getBestPriceReturnsSpecialPriceWhenSpecialPriceIsLessThanPrice() + { + $price = 10.00; + $specialPrice = 5.00; + + $product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + null, + $this->contentId, + $this->sku, + $this->title, + $price, + $this->taxClass, + $this->quantity + ); + $product->setSpecialPrice($specialPrice); + + $this->assertSame( + 5.0, + $product->getBestPrice() + ); + } + + + /** + * @test + */ + public function getQuantityReturnsQuantitySetByConstructor() + { + $this->assertSame( + $this->quantity, + $this->product->getQuantity() + ); + } + + /** + * @test + */ + public function getIsNetPriceReturnsFalseSetByDefaultConstructor() + { + $this->assertSame( + false, + $this->product->getIsNetPrice() + ); + } + + /** + * @test + */ + public function getIsNetPriceReturnsTrueSetByDefaultConstructor() + { + $net_fixture = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $this->quantity, + true + ); + + $this->assertSame( + true, + $net_fixture->getIsNetPrice() + ); + } + + /** + * @test + */ + public function setTitleSetsTitle() + { + $sku = 'new-test-product-sku'; + + $this->product->setSku($sku); + + $this->assertSame( + $sku, + $this->product->getSku() + ); + } + + /** + * @test + */ + public function setSkuSetsSku() + { + $title = 'New Test Product'; + + $this->product->setTitle($title); + + $this->assertSame( + $title, + $this->product->getTitle() + ); + } + + /** + * @test + */ + public function getMinNumberInCartReturnsInitialValueMinNumber() + { + $this->assertSame( + 0, + $this->product->getMinNumberInCart() + ); + } + + /** + * @test + */ + public function setMinNumberInCartIfMinNumberIsEqualToMaxNumber() + { + $minNumber = 1; + $maxNumber = 1; + + $this->product->setMaxNumberInCart($maxNumber); + $this->product->setMinNumberInCart($minNumber); + + $this->assertEquals( + $minNumber, + $this->product->getMinNumberInCart() + ); + } + + /** + * @test + */ + public function setMinNumberInCartIfMinNumberIsLesserThanMax() + { + $minNumber = 1; + $maxNumber = 2; + + $this->product->setMaxNumberInCart($maxNumber); + $this->product->setMinNumberInCart($minNumber); + + $this->assertEquals( + $minNumber, + $this->product->getMinNumberInCart() + ); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function throwsInvalidArgumentExceptionIfMinNumberIsGreaterThanMaxNumber() + { + $minNumber = 2; + $maxNumber = 1; + + $this->product->setMaxNumberInCart($maxNumber); + $this->product->setMinNumberInCart($minNumber); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function throwsInvalidArgumentExceptionIfMinNumberIsNegativ() + { + $minNumber = -1; + $maxNumber = 1; + + $this->product->setMaxNumberInCart($maxNumber); + $this->product->setMinNumberInCart($minNumber); + } + + /** + * @test + */ + public function getMaxNumberInCartReturnsInitialValueMaxNumber() + { + $this->assertSame( + 0, + $this->product->getMaxNumberInCart() + ); + } + + /** + * @test + */ + public function setMaxNumberInCartIfMaxNumberIsEqualToMinNumber() + { + $minNumber = 1; + $maxNumber = 1; + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertEquals( + $maxNumber, + $this->product->getMaxNumberInCart() + ); + } + + /** + * @test + */ + public function setMaxNumberInCartIfMaxNumerIsGreaterThanMinNumber() + { + $minNumber = 1; + $maxNumber = 2; + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertEquals( + $maxNumber, + $this->product->getMaxNumberInCart() + ); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function throwsInvalidArgumentExceptionIfMaxNumberIsLesserThanMinNUmber() + { + $minNumber = 2; + $maxNumber = 1; + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + } + + /** + * @test + */ + public function getQuantityIsLeavingRangeReturnsZeroIfQuantityIsInRange() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 7; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertSame( + 0, + $this->product->getQuantityIsLeavingRange() + ); + } + + /** + * @test + */ + public function getQuantityIsLeavingRangeReturnsZeroIfQuantityIsEqualToMinimum() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 5; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertSame( + 0, + $this->product->getQuantityIsLeavingRange() + ); + } + + /** + * @test + */ + public function getQuantityIsLeavingRangeReturnsZeroIfQuantityIsEqualToMaximum() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 10; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertSame( + 0, + $this->product->getQuantityIsLeavingRange() + ); + } + + /** + * @test + */ + public function getQuantityIsLeavingRangeReturnsMinusOneIfQuantityIsLessThanMinimum() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 4; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertSame( + -1, + $this->product->getQuantityIsLeavingRange() + ); + } + + /** + * @test + */ + public function getQuantityIsLeavingRangeReturnsOneIfQuantityIsGreaterThanMaximum() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 11; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertSame( + 1, + $this->product->getQuantityIsLeavingRange() + ); + } + + /** + * @test + */ + public function getQuantityIsInRangeReturnsTrueIfQuantityIsInRange() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 7; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertTrue( + $this->product->getQuantityIsInRange() + ); + } + + /** + * @test + */ + public function getQuantityIsInRangeReturnsTrueIfQuantityIsEqualToMinimum() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 5; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertTrue( + $this->product->getQuantityIsInRange() + ); + } + + /** + * @test + */ + public function getQuantityIsInRangeReturnsTrueIfQuantityIsEqualToMaximum() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 10; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertTrue( + $this->product->getQuantityIsInRange() + ); + } + + /** + * @test + */ + public function getQuantityIsInRangeReturnsFalseIfQuantityIsLessThanMinimum() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 4; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertFalse( + $this->product->getQuantityIsInRange() + ); + } + + /** + * @test + */ + public function getQuantityIsInRangeReturnsFalseIfQuantityIsGreaterThanMaximum() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 11; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertFalse( + $this->product->getQuantityIsInRange() + ); + } + + /** + * @test + */ + public function getGrossReturnsZeroIfNumberIsOutOfRange() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 4; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertSame( + 0.0, + $this->product->getGross() + ); + + $quantity = 11; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertSame( + 0.0, + $this->product->getGross() + ); + } + + /** + * @test + */ + public function getNetReturnsZeroIfNumberIsOutOfRange() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 4; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertSame( + 0.0, + $this->product->getNet() + ); + + $quantity = 11; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertSame( + 0.0, + $this->product->getNet() + ); + } + + /** + * @test + */ + public function getTaxReturnsZeroIfNumberIsOutOfRange() + { + $minNumber = 5; + $maxNumber = 10; + $quantity = 4; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertSame( + 0.0, + $this->product->getTax() + ); + + $quantity = 11; + + $this->product = new \Extcode\Cart\Domain\Model\Cart\Product( + $this->productId, + $this->tableId, + $this->contentId, + $this->sku, + $this->title, + $this->price, + $this->taxClass, + $quantity + ); + + $this->product->setMinNumberInCart($minNumber); + $this->product->setMaxNumberInCart($maxNumber); + + $this->assertSame( + 0.0, + $this->product->getTax() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Cart/ShippingTest.php b/Tests/Unit/Domain/Model/Cart/ShippingTest.php new file mode 100644 index 00000000..4e07a3df --- /dev/null +++ b/Tests/Unit/Domain/Model/Cart/ShippingTest.php @@ -0,0 +1,121 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Shipping Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class ShippingTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * Id + * + * @var int + */ + protected $id; + + /** + * Name + * + * @var string + */ + protected $name; + + /** + * Status + * + * @var int + */ + protected $status; + + /** + * Note + * + * @var string + */ + protected $note; + + /** + * Is Net Price + * + * @var bool + */ + protected $isNetPrice; + + /** + * Tax Class + * + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass + */ + protected $taxClass; + + /** + * Shipping + * + * @var \Extcode\Cart\Domain\Model\Cart\Shipping $shipping + */ + protected $shipping; + + /** + * + */ + public function setUp() + { + $this->taxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(1, '19', 0.19, 'normal'); + + $this->id = 1; + $this->name = 'Service'; + $this->status = 0; + $this->note = 'note'; + $this->isNetPrice = 0; + + $this->shipping = new \Extcode\Cart\Domain\Model\Cart\Shipping( + $this->id, + $this->name, + $this->taxClass, + $this->status, + $this->note, + $this->isNetPrice + ); + } + + /** + * @test + */ + public function getCartProductIdReturnsProductIdSetByConstructor() + { + $this->assertSame( + $this->id, + $this->shipping->getId() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Cart/SpecialTest.php b/Tests/Unit/Domain/Model/Cart/SpecialTest.php new file mode 100644 index 00000000..acafb8c1 --- /dev/null +++ b/Tests/Unit/Domain/Model/Cart/SpecialTest.php @@ -0,0 +1,121 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Special Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class SpecialTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * Id + * + * @var int + */ + protected $id; + + /** + * Name + * + * @var string + */ + protected $name; + + /** + * Status + * + * @var int + */ + protected $status; + + /** + * Note + * + * @var string + */ + protected $note; + + /** + * Is Net Price + * + * @var bool + */ + protected $isNetPrice; + + /** + * Tax Class + * + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass $taxClass + */ + protected $taxClass; + + /** + * Special + * + * @var \Extcode\Cart\Domain\Model\Cart\Special $special + */ + protected $special; + + /** + * + */ + public function setUp() + { + $this->taxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(1, '19', 0.19, 'normal'); + + $this->id = 1; + $this->name = 'Service'; + $this->status = 0; + $this->note = 'note'; + $this->isNetPrice = 0; + + $this->special = new \Extcode\Cart\Domain\Model\Cart\Special( + $this->id, + $this->name, + $this->taxClass, + $this->status, + $this->note, + $this->isNetPrice + ); + } + + /** + * @test + */ + public function getCartProductIdReturnsProductIdSetByConstructor() + { + $this->assertSame( + $this->id, + $this->special->getId() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Cart/TaxClassTest.php b/Tests/Unit/Domain/Model/Cart/TaxClassTest.php new file mode 100644 index 00000000..2777cf55 --- /dev/null +++ b/Tests/Unit/Domain/Model/Cart/TaxClassTest.php @@ -0,0 +1,228 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Tax Class Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class TaxClassTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * Tax Class + * + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + protected $fixture = null; + + /** + * Id + * + * @var int + */ + private $id; + + /** + * Value + * + * @var string + */ + private $value; + + /** + * Calc + * + * @var int + */ + private $calc; + + /** + * Title + * + * @var string + */ + private $title; + + /** + * Set Up + * + * @return void + */ + public function setUp() + { + $this->id = 1; + $this->value = '19'; + $this->calc = 0.19; + $this->title = 'normal Tax'; + + $this->fixture = new \Extcode\Cart\Domain\Model\Cart\TaxClass( + $this->id, + $this->value, + $this->calc, + $this->title + ); + } + + /** + * Tear Down + * + * @return void + */ + public function tearDown() + { + unset($this->id); + unset($this->value); + unset($this->calc); + unset($this->title); + + unset($this->fixture); + } + + /** + * @test + */ + public function constructTaxClassWithoutIdThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $id for constructor.', + 1413981328 + ); + + new \Extcode\Cart\Domain\Model\Cart\TaxClass( + null, + $this->value, + $this->calc, + $this->title + ); + } + + /** + * @test + */ + public function constructTaxClassWithoutValueThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $value for constructor.', + 1413981329 + ); + + new \Extcode\Cart\Domain\Model\Cart\TaxClass( + $this->id, + null, + $this->calc, + $this->title + ); + } + + /** + * @test + */ + public function constructTaxClassWithoutCalcThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $calc for constructor.', + 1413981330 + ); + + new \Extcode\Cart\Domain\Model\Cart\TaxClass( + $this->id, + $this->value, + null, + $this->title + ); + } + + /** + * @test + */ + public function constructTaxClassWithoutTitleThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $title for constructor.', + 1413981331 + ); + + new \Extcode\Cart\Domain\Model\Cart\TaxClass( + $this->id, + $this->value, + $this->calc, + null + ); + } + + /** + * @test + */ + public function getIdReturnsIdSetByConstructor() + { + $this->assertSame( + $this->id, + $this->fixture->getId() + ); + } + + /** + * @test + */ + public function getValueReturnsValueSetByConstructor() + { + $this->assertSame( + $this->value, + $this->fixture->getValue() + ); + } + + /** + * @test + */ + public function getCalcReturnsCalcSetByConstructor() + { + $this->assertSame( + $this->calc, + $this->fixture->getCalc() + ); + } + + /** + * @test + */ + public function getTitleReturnsNameSetByConstructor() + { + $this->assertSame( + $this->title, + $this->fixture->getTitle() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Order/AbstractServiceTest.php b/Tests/Unit/Domain/Model/Order/AbstractServiceTest.php new file mode 100644 index 00000000..e404f647 --- /dev/null +++ b/Tests/Unit/Domain/Model/Order/AbstractServiceTest.php @@ -0,0 +1,257 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + + +class AbstractServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $service = null; + + public function setUp() + { + $this->service = $this->getMockForAbstractClass('\Extcode\Cart\Domain\Model\Order\AbstractService'); + } + + /** + * @test + */ + public function toArrayReturnsArray() + { + $name = 'name'; + $note = 'note'; + $status = 'status'; + $gross = 10.00; + $net = 8.40; + $taxClass = new \Extcode\Cart\Domain\Model\Order\TaxClass('normal', '19', 0.19); + $tax = 1.60; + + $this->service->setName($name); + $this->service->setStatus($status); + $this->service->setNote($note); + $this->service->setGross($gross); + $this->service->setNet($net); + $this->service->setTax($tax); + + $serviceArr = [ + 'name' => $name, + 'status' => $status, + 'net' => $net, + 'gross' => $gross, + 'tax' => $tax, + 'taxClass' => null, + 'note' => $note + ]; + + $this->assertEquals( + $serviceArr, + $this->service->toArray() + ); + + //with taxClass + $this->service->setTaxClass($taxClass); + + $serviceArr['taxClass'] = $taxClass->toArray(); + + $this->assertEquals( + $serviceArr, + $this->service->toArray() + ); + } + + /** + * @test + */ + public function getNameInitiallyReturnsEmptyString() + { + $this->assertSame( + '', + $this->service->getName() + ); + } + + /** + * @test + */ + public function setNameSetsName() + { + $this->service->setName('foo bar'); + + $this->assertSame( + 'foo bar', + $this->service->getName() + ); + } + + /** + * @test + */ + public function getStatusInitiallyReturnsEmptyString() + { + $this->assertSame( + 'open', + $this->service->getStatus() + ); + } + + /** + * @test + */ + public function setStatusSetsStatus() + { + $this->service->setStatus('paid'); + + $this->assertSame( + 'paid', + $this->service->getStatus() + ); + } + + /** + * @test + */ + public function getNoteInitiallyReturnsEmptyString() + { + $this->assertSame( + '', + $this->service->getNote() + ); + } + + /** + * @test + */ + public function setNoteSetsNote() + { + $note = 'note'; + $this->service->setNote($note); + + $this->assertSame( + $note, + $this->service->getNote() + ); + } + + /** + * @test + */ + public function getGrossInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->service->getGross() + ); + } + + /** + * @test + */ + public function setGrossSetsGross() + { + $this->service->setGross(1234.56); + + $this->assertSame( + 1234.56, + $this->service->getGross() + ); + } + + /** + * @test + */ + public function getNetInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->service->getNet() + ); + } + + /** + * @test + */ + public function setNetSetsNet() + { + $this->service->setNet(1234.56); + + $this->assertSame( + 1234.56, + $this->service->getNet() + ); + } + + /** + * @test + */ + public function getTaxClassInitiallyReturnsNull() + { + $this->assertNull( + $this->service->getTaxClass() + ); + } + + /** + * @test + */ + public function setTaxClassSetsTaxClass() + { + $taxClass = new \Extcode\Cart\Domain\Model\Order\TaxClass('normal', '19', 0.19); + + $this->service->setTaxClass($taxClass); + + $this->assertSame( + $taxClass, + $this->service->getTaxClass() + ); + } + + /** + * @test + */ + public function getTaxInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->service->getTax() + ); + } + + /** + * @test + */ + public function setTaxSetsTax() + { + $this->service->setTax(1234.56); + + $this->assertSame( + 1234.56, + $this->service->getTax() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Order/AddressTest.php b/Tests/Unit/Domain/Model/Order/AddressTest.php new file mode 100644 index 00000000..7f4f679f --- /dev/null +++ b/Tests/Unit/Domain/Model/Order/AddressTest.php @@ -0,0 +1,396 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Address Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class AddressTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Order\Address + */ + protected $address; + + /** + * + */ + public function setUp() + { + $this->address = new \Extcode\Cart\Domain\Model\Order\Address(); + } + + /** + * @test + */ + public function toArrayReturnsArray() + { + $salutation = 'salutation'; + $title = 'title'; + $firstName = 'first name'; + $lastName = 'last name'; + $company = 'company'; + $street = 'street'; + $zip = 'zip'; + $city = 'city'; + $country = 'country'; + $email = 'email'; + $phone = 'phone'; + $fax = 'fax'; + + $address = new \Extcode\Cart\Domain\Model\Order\Address(); + $address->setSalutation($salutation); + $address->setTitle($title); + $address->setFirstName($firstName); + $address->setLastName($lastName); + $address->setCompany($company); + $address->setStreet($street); + $address->setZip($zip); + $address->setCity($city); + $address->setCountry($country); + $address->setEmail($email); + $address->setPhone($phone); + $address->setFax($fax); + + $addressArray = array( + 'salutation' => $salutation, + 'title' => $title, + 'firstName' => $firstName, + 'lastName' => $lastName, + 'company' => $company, + 'street' => $street, + 'zip' => $zip, + 'city' => $city, + 'country' => $country, + 'email' => $email, + 'phone' => $phone, + 'fax' => $fax + ); + + $this->assertSame( + $addressArray, + $address->toArray() + ); + } + + /** + * @test + */ + public function getTitleInitiallyReturnsEmptyString() + { + $this->assertSame( + '', + $this->address->getTitle() + ); + } + + /** + * @test + */ + public function setTitleSetsTitle() + { + $title = 'title'; + $this->address->setTitle($title); + + $this->assertSame( + $title, + $this->address->getTitle() + ); + } + + /** + * @test + */ + public function getSalutationInitiallyReturnsEmptyString() + { + $this->assertNull( + $this->address->getSalutation() + ); + } + + /** + * @test + */ + public function setSalutationSetsSalutation() + { + $salutation = 'salutation'; + $this->address->setSalutation($salutation); + + $this->assertSame( + $salutation, + $this->address->getSalutation() + ); + } + + /** + * @test + */ + public function getFirstNameInitiallyReturnsEmptyString() + { + $this->assertNull( + $this->address->getFirstName() + ); + } + + /** + * @test + */ + public function setFirstNameSetsFirstName() + { + $firstName = 'first name'; + $this->address->setFirstName($firstName); + + $this->assertSame( + $firstName, + $this->address->getFirstName() + ); + } + + /** + * @test + */ + public function getLastNameInitiallyReturnsEmptyString() + { + $this->assertNull( + $this->address->getLastName() + ); + } + + /** + * @test + */ + public function setLastNameSetsLastName() + { + $lastName = 'last name'; + $this->address->setLastName($lastName); + + $this->assertSame( + $lastName, + $this->address->getLastName() + ); + } + + /** + * @test + */ + public function getCompanyInitiallyReturnsEmptyString() + { + $this->assertSame( + '', + $this->address->getCompany() + ); + } + + /** + * @test + */ + public function setCompanySetsCompany() + { + $company = 'company'; + $this->address->setCompany($company); + + $this->assertSame( + $company, + $this->address->getCompany() + ); + } + + /** + * @test + */ + public function getStreetInitiallyReturnsEmptyString() + { + $this->assertNull( + $this->address->getStreet() + ); + } + + /** + * @test + */ + public function setStreetSetsStreet() + { + $street = 'street'; + $this->address->setStreet($street); + + $this->assertSame( + $street, + $this->address->getStreet() + ); + } + + /** + * @test + */ + public function getZipInitiallyReturnsEmptyString() + { + $this->assertNull( + $this->address->getZip() + ); + } + + /** + * @test + */ + public function setZipSetsZip() + { + $zip = 'zip'; + $this->address->setZip($zip); + + $this->assertSame( + $zip, + $this->address->getZip() + ); + } + + /** + * @test + */ + public function getCityInitiallyReturnsEmptyString() + { + $this->assertNull( + $this->address->getCity() + ); + } + + /** + * @test + */ + public function setCitySetsCity() + { + $city = 'city'; + $this->address->setCity($city); + + $this->assertSame( + $city, + $this->address->getCity() + ); + } + + /** + * @test + */ + public function getCountryInitiallyReturnsEmptyString() + { + $this->assertNull( + $this->address->getCountry() + ); + } + + /** + * @test + */ + public function setCountrySetsCountry() + { + $country = 'country'; + $this->address->setCountry($country); + + $this->assertSame( + $country, + $this->address->getCountry() + ); + } + + /** + * @test + */ + public function getEmailInitiallyReturnsEmptyString() + { + $this->assertNull( + $this->address->getEmail() + ); + } + + /** + * @test + */ + public function setEmailSetsEmail() + { + $email = 'email'; + $this->address->setEmail($email); + + $this->assertSame( + $email, + $this->address->getEmail() + ); + } + + /** + * @test + */ + public function getPhoneInitiallyReturnsEmptyString() + { + $this->assertSame( + '', + $this->address->getPhone() + ); + } + + /** + * @test + */ + public function setPhoneSetsPhone() + { + $phone = 'phone'; + $this->address->setPhone($phone); + + $this->assertSame( + $phone, + $this->address->getPhone() + ); + } + + /** + * @test + */ + public function getFaxInitiallyReturnsEmptyString() + { + $this->assertSame( + '', + $this->address->getFax() + ); + } + + /** + * @test + */ + public function setFaxSetsFax() + { + $fax = 'fax'; + $this->address->setFax($fax); + + $this->assertSame( + $fax, + $this->address->getFax() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Order/CouponTest.php b/Tests/Unit/Domain/Model/Order/CouponTest.php new file mode 100644 index 00000000..fb175b2c --- /dev/null +++ b/Tests/Unit/Domain/Model/Order/CouponTest.php @@ -0,0 +1,247 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + + +class CouponTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Order\Coupon + */ + protected $coupon = null; + + /** + * Title + * + * @var string + */ + protected $title = ''; + + /** + * Code + * + * @var string + */ + protected $code = ''; + + /** + * Discount + * + * @var float + */ + protected $discount = 0.0; + + /** + * TaxClass + * + * @var \Extcode\Cart\Domain\Model\Cart\TaxClass + */ + protected $taxClass = null; + + /** + * Tax + * + * @var float + */ + protected $tax = 0.0; + + /** + * + */ + public function setUp() + { + $this->taxClass = new \Extcode\Cart\Domain\Model\Cart\TaxClass(1, '19', 0.19, 'normal'); + + $this->title = 'Coupon'; + $this->code = 'coupon'; + $this->discount = 10.00; + $this->tax = 1.60; + + $this->coupon = new \Extcode\Cart\Domain\Model\Order\Coupon( + $this->title, + $this->code, + $this->discount, + $this->taxClass, + $this->tax + ); + } + + /** + * @test + */ + public function constructCouponWithoutTitleThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $title for constructor.', + 1455452810 + ); + + new \Extcode\Cart\Domain\Model\Order\Coupon( + null, + $this->code, + $this->discount, + $this->taxClass, + $this->tax + ); + } + + /** + * @test + */ + public function constructCouponWithoutCodeThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $code for constructor.', + 1455452820 + ); + + new \Extcode\Cart\Domain\Model\Order\Coupon( + $this->title, + null, + $this->discount, + $this->taxClass, + $this->tax + ); + } + + /** + * @test + */ + public function constructCouponWithoutDiscountThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $discount for constructor.', + 1455452830 + ); + + new \Extcode\Cart\Domain\Model\Order\Coupon( + $this->title, + $this->code, + null, + $this->taxClass, + $this->tax + ); + } + + /** + * @test + */ + public function constructCouponWithoutTaxClassThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $taxClass for constructor.', + 1455452840 + ); + + new \Extcode\Cart\Domain\Model\Order\Coupon( + $this->title, + $this->code, + $this->discount, + null, + $this->tax + ); + } + + /** + * @test + */ + public function constructCouponWithoutTaxThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $tax for constructor.', + 1455452850 + ); + + new \Extcode\Cart\Domain\Model\Order\Coupon( + $this->title, + $this->code, + $this->discount, + $this->taxClass, + null + ); + } + + /** + * @test + */ + public function getTitleInitiallyReturnsTitleSetDirectlyByConstructor() + { + $this->assertSame( + $this->title, + $this->coupon->getTitle() + ); + } + + /** + * @test + */ + public function getCodeInitiallyReturnsCodeSetDirectlyByConstructor() + { + $this->assertSame( + $this->code, + $this->coupon->getCode() + ); + } + + /** + * @test + */ + public function getDiscountInitiallyReturnsDiscountSetDirectlyByConstructor() + { + $this->assertSame( + $this->discount, + $this->coupon->getDiscount() + ); + } + + /** + * @test + */ + public function getTaxClassInitiallyReturnsTaxClassSetDirectlyByConstructor() + { + $this->assertSame( + $this->taxClass, + $this->coupon->getTaxClass() + ); + } + + /** + * @test + */ + public function getTaxInitiallyReturnsTaxSetDirectlyByConstructor() + { + $this->assertSame( + $this->tax, + $this->coupon->getTax() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Order/ItemTest.php b/Tests/Unit/Domain/Model/Order/ItemTest.php new file mode 100644 index 00000000..ac58092e --- /dev/null +++ b/Tests/Unit/Domain/Model/Order/ItemTest.php @@ -0,0 +1,76 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Item Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class ItemTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Order\Item + */ + protected $item; + + /** + * + */ + public function setUp() + { + + $this->item = new \Extcode\Cart\Domain\Model\Order\Item(); + } + + /** + * @test + */ + public function getCurrencyInitiallyReturnsEmptyString() + { + $this->assertSame( + '€', + $this->item->getCurrency() + ); + } + + /** + * @test + */ + public function setCurrencySetsCurrency() + { + $this->item->setCurrency('$'); + + $this->assertSame( + '$', + $this->item->getCurrency() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Order/PaymentTest.php b/Tests/Unit/Domain/Model/Order/PaymentTest.php new file mode 100644 index 00000000..9808ef38 --- /dev/null +++ b/Tests/Unit/Domain/Model/Order/PaymentTest.php @@ -0,0 +1,155 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Payment Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class PaymentTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Order\Payment + */ + protected $payment; + + /** + * + */ + public function setUp() + { + $this->payment = new \Extcode\Cart\Domain\Model\Order\Payment(); + } + + /** + * @test + */ + public function toArrayReturnsArray() + { + $provider = 'provider'; + + $this->payment->setProvider($provider); + + $this->assertArraySubset( + ['provider' => $provider], + $this->payment->toArray() + ); + } + + /** + * @test + */ + public function getProviderInitiallyReturnsEmptyString() + { + $this->assertSame( + '', + $this->payment->getProvider() + ); + } + + /** + * @test + */ + public function setProviderSetsProvider() + { + $provider = 'provider'; + $this->payment->setProvider($provider); + + $this->assertSame( + $provider, + $this->payment->getProvider() + ); + } + + /** + * @test + */ + public function getTransactionsInitiallyIsEmpty() + { + $this->assertEmpty( + $this->payment->getTransactions() + ); + } + + /** + * @test + */ + public function setTransactionsSetsTransactions() + { + $transaction1 = new \Extcode\Cart\Domain\Model\Order\Transaction(); + $transaction2 = new \Extcode\Cart\Domain\Model\Order\Transaction(); + + $objectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $objectStorage->attach($transaction1); + $objectStorage->attach($transaction2); + + $this->payment->setTransactions($objectStorage); + + $this->assertContains( + $transaction1, + $this->payment->getTransactions() + ); + $this->assertContains( + $transaction2, + $this->payment->getTransactions() + ); + } + + /** + * @test + */ + public function addTransactionAddsTransaction() + { + $transaction = new \Extcode\Cart\Domain\Model\Order\Transaction(); + + $this->payment->addTransaction($transaction); + + $this->assertContains( + $transaction, + $this->payment->getTransactions() + ); + } + + /** + * @test + */ + public function removeTransactionRemovesTransaction() + { + $transaction = new \Extcode\Cart\Domain\Model\Order\Transaction(); + + $this->payment->addTransaction($transaction); + $this->payment->removeTransaction($transaction); + + $this->assertEmpty( + $this->payment->getTransactions() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Order/ProductAdditionalTest.php b/Tests/Unit/Domain/Model/Order/ProductAdditionalTest.php new file mode 100644 index 00000000..5843cfe4 --- /dev/null +++ b/Tests/Unit/Domain/Model/Order/ProductAdditionalTest.php @@ -0,0 +1,206 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + + +class ProductAdditionalTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * Additional Type + * + * @var string + */ + protected $additionalType = ''; + + /** + * Additional Key + * + * @var string + */ + protected $additionalKey = ''; + + /** + * Additional Value + * + * @var string + */ + protected $additionalValue = ''; + + /** + * @var \Extcode\Cart\Domain\Model\Order\ProductAdditional + */ + protected $productAdditional = null; + + /** + * + */ + public function setUp() + { + $this->additionalType = 'additional-type'; + $this->additionalKey = 'additional-key'; + $this->additionalValue = 'additional-value'; + + $this->productAdditional = new \Extcode\Cart\Domain\Model\Order\ProductAdditional( + $this->additionalType, + $this->additionalKey, + $this->additionalValue + ); + } + + /** + * @test + */ + public function constructProductAdditionalWithoutAdditionalTypeThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $additionalType for constructor.', + 1456828210 + ); + + $this->productAdditional = new \Extcode\Cart\Domain\Model\Order\ProductAdditional( + null, + $this->additionalKey, + $this->additionalValue + ); + } + + /** + * @test + */ + public function constructProductAdditionalWithoutAdditionalKeyThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $additionalKey for constructor.', + 1456828220 + ); + + $this->productAdditional = new \Extcode\Cart\Domain\Model\Order\ProductAdditional( + $this->additionalType, + null, + $this->additionalValue + ); + } + + /** + * @test + */ + public function constructProductAdditionalWithoutAdditionalValueThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $additionalValue for constructor.', + 1456828230 + ); + + $this->productAdditional = new \Extcode\Cart\Domain\Model\Order\ProductAdditional( + $this->additionalType, + $this->additionalKey, + null + ); + } + + /** + * @test + */ + public function getAdditionalTypeInitiallyReturnsAdditionalTypeSetDirectlyByConstructor() + { + $this->assertSame( + $this->additionalType, + $this->productAdditional->getAdditionalType() + ); + } + + /** + * @test + */ + public function getAdditionalKeyInitiallyReturnsAdditionalKeySetDirectlyByConstructor() + { + $this->assertSame( + $this->additionalKey, + $this->productAdditional->getAdditionalKey() + ); + } + + /** + * @test + */ + public function getAdditionalValueInitiallyReturnsAdditionalValueSetDirectlyByConstructor() + { + $this->assertSame( + $this->additionalValue, + $this->productAdditional->getAdditionalValue() + ); + } + + /** + * @test + */ + public function getAdditionalDataInitiallyReturnsAdditionalDataSetDirectlyByConstructor() + { + $additionalData = 'additional-data'; + + $productAdditional = new \Extcode\Cart\Domain\Model\Order\ProductAdditional( + $this->additionalType, + $this->additionalKey, + $this->additionalValue, + $additionalData + ); + + $this->assertSame( + $additionalData, + $productAdditional->getAdditionalData() + ); + } + + /** + * @test + */ + public function getAdditionalDataInitiallyReturnsEmptyString() + { + $this->assertSame( + '', + $this->productAdditional->getAdditionalData() + ); + } + + /** + * @test + */ + public function setAdditionalDataSetsAdditionalData() + { + $additionalData = 'additional-data'; + + $this->productAdditional->setAdditionalData($additionalData); + + $this->assertSame( + $additionalData, + $this->productAdditional->getAdditionalData() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Order/ProductTest.php b/Tests/Unit/Domain/Model/Order/ProductTest.php new file mode 100644 index 00000000..9597639d --- /dev/null +++ b/Tests/Unit/Domain/Model/Order/ProductTest.php @@ -0,0 +1,160 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + + +class ProductTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Order\Product + */ + protected $product = null; + + /** + * Sku + * + * @var string + */ + protected $sku; + + /** + * Title + * + * @var string + */ + protected $title; + + /** + * Count + * + * @var int + */ + protected $count = 0; + + /** + * + */ + public function setUp() + { + $this->sku = 'sku'; + $this->title = 'title'; + $this->count = 1; + + $this->product = new \Extcode\Cart\Domain\Model\Order\Product( + $this->sku, + $this->title, + $this->count + ); + } + + /** + * @test + */ + public function constructProductWithoutSkuThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $sku for constructor.', + 1456830010 + ); + + $this->product = new \Extcode\Cart\Domain\Model\Order\Product( + null, + $this->title, + $this->count + ); + } + + /** + * @test + */ + public function constructProductWithoutTitleThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $title for constructor.', + 1456830020 + ); + + $this->product = new \Extcode\Cart\Domain\Model\Order\Product( + $this->sku, + null, + $this->count + ); + } + + /** + * @test + */ + public function constructProductWithoutCountThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $count for constructor.', + 1456830030 + ); + + $this->product = new \Extcode\Cart\Domain\Model\Order\Product( + $this->sku, + $this->title, + null + ); + } + + /** + * @test + */ + public function getSkuInitiallyReturnsSkuSetDirectlyByConstructor() + { + $this->assertSame( + $this->sku, + $this->product->getSku() + ); + } + + /** + * @test + */ + public function getTitleInitiallyReturnsTitleSetDirectlyByConstructor() + { + $this->assertSame( + $this->title, + $this->product->getTitle() + ); + } + + /** + * @test + */ + public function getCountInitiallyReturnsCountSetDirectlyByConstructor() + { + $this->assertSame( + $this->count, + $this->product->getCount() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Order/ShippingTest.php b/Tests/Unit/Domain/Model/Order/ShippingTest.php new file mode 100644 index 00000000..07de14b3 --- /dev/null +++ b/Tests/Unit/Domain/Model/Order/ShippingTest.php @@ -0,0 +1,195 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +/** + * Shipping Test + * + * @package cart + * @author Daniel Lorenz + * @license http://www.gnu.org/licenses/lgpl.html + * GNU Lesser General Public License, version 3 or later + */ +class ShippingTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Order\Shipping + */ + protected $shipping; + + /** + * + */ + public function setUp() + { + $this->shipping = new \Extcode\Cart\Domain\Model\Order\Shipping(); + } + + /** + * @test + */ + public function getNameInitiallyReturnsEmptyString() + { + $this->assertSame( + '', + $this->shipping->getName() + ); + } + + /** + * @test + */ + public function setNameSetsName() + { + $this->shipping->setName('foo bar'); + + $this->assertSame( + 'foo bar', + $this->shipping->getName() + ); + } + + /** + * @test + */ + public function getStatusInitiallyReturnsEmptyString() + { + $this->assertSame( + 'open', + $this->shipping->getStatus() + ); + } + + /** + * @test + */ + public function setStatusSetsStatus() + { + $this->shipping->setStatus('shipped'); + + $this->assertSame( + 'shipped', + $this->shipping->getStatus() + ); + } + + /** + * @test + */ + public function getNetInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->shipping->getNet() + ); + } + + /** + * @test + */ + public function setNetSetsNet() + { + $this->shipping->setNet(1234.56); + + $this->assertSame( + 1234.56, + $this->shipping->getNet() + ); + } + + /** + * @test + */ + public function getGrossInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->shipping->getGross() + ); + } + + /** + * @test + */ + public function setGrossSetsGross() + { + $this->shipping->setGross(1234.56); + + $this->assertSame( + 1234.56, + $this->shipping->getGross() + ); + } + + /** + * @test + */ + public function getTaxInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->shipping->getTax() + ); + } + + /** + * @test + */ + public function setTaxSetsTax() + { + $this->shipping->setTax(1234.56); + + $this->assertSame( + 1234.56, + $this->shipping->getTax() + ); + } + + /** + * @test + */ + public function getNoteInitiallyReturnsEmptyString() + { + $this->assertSame( + '', + $this->shipping->getNote() + ); + } + + /** + * @test + */ + public function setNoteSetsNote() + { + $this->shipping->setNote('foo bar'); + + $this->assertSame( + 'foo bar', + $this->shipping->getNote() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Order/TaxClassTest.php b/Tests/Unit/Domain/Model/Order/TaxClassTest.php new file mode 100644 index 00000000..3d9b0d2c --- /dev/null +++ b/Tests/Unit/Domain/Model/Order/TaxClassTest.php @@ -0,0 +1,177 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + + +class TaxClassTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Order\TaxClass + */ + protected $taxClass = null; + + /** + * Title + * + * @var string + */ + protected $title; + + /** + * Value + * + * @var string + */ + protected $value; + + /** + * Calc + * + * @var float + */ + protected $calc = 0.0; + + /** + * + */ + public function setUp() + { + $this->title = 'normal'; + $this->value = '19'; + $this->count = 0.19; + + $this->taxClass = new \Extcode\Cart\Domain\Model\Order\TaxClass( + $this->title, + $this->value, + $this->calc + ); + } + + /** + * @test + */ + public function constructTaxClassWithoutTitleThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $title for constructor.', + 1456830910 + ); + + new \Extcode\Cart\Domain\Model\Order\TaxClass( + null, + $this->value, + $this->calc + ); + } + + /** + * @test + */ + public function constructTaxClassWithoutValueThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $value for constructor.', + 1456830920 + ); + + new \Extcode\Cart\Domain\Model\Order\TaxClass( + $this->title, + null, + $this->calc + ); + } + + /** + * @test + */ + public function constructTaxClassWithoutCalcThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $calc for constructor.', + 1456830930 + ); + + new \Extcode\Cart\Domain\Model\Order\TaxClass( + $this->title, + $this->value, + null + ); + } + + /** + * @test + */ + public function getTitleInitiallyReturnsTitleSetDirectlyByConstructor() + { + $this->assertSame( + $this->title, + $this->taxClass->getTitle() + ); + } + + /** + * @test + */ + public function getValueInitiallyReturnsValueSetDirectlyByConstructor() + { + $this->assertSame( + $this->value, + $this->taxClass->getValue() + ); + } + + /** + * @test + */ + public function getCalcInitiallyReturnsCalcSetDirectlyByConstructor() + { + $this->assertSame( + $this->calc, + $this->taxClass->getCalc() + ); + } + + /** + * @test + */ + public function toArrayReturnsArray() + { + $taxClassArray = [ + 'title' => $this->title, + 'value' => $this->value, + 'calc' => $this->calc + ]; + + $this->assertEquals( + $taxClassArray, + $this->taxClass->toArray() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Order/TaxTest.php b/Tests/Unit/Domain/Model/Order/TaxTest.php new file mode 100644 index 00000000..d593938d --- /dev/null +++ b/Tests/Unit/Domain/Model/Order/TaxTest.php @@ -0,0 +1,121 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + + +class TaxTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Order\Tax + */ + protected $orderTax = null; + + /** + * Tax + * + * @var float + */ + protected $tax; + + /** + * TaxClass + * + * @var \Extcode\Cart\Domain\Model\Order\TaxClass + */ + protected $taxClass; + + /** + * + */ + public function setUp() + { + $this->taxClass = new \Extcode\Cart\Domain\Model\Order\TaxClass('normal', '19', 0.19); + + $this->tax = 10.00; + + $this->orderTax = new \Extcode\Cart\Domain\Model\Order\Tax( + $this->tax, + $this->taxClass + ); + } + + /** + * @test + */ + public function constructTaxWithoutTaxThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $tax for constructor.', + 1456836510 + ); + + new \Extcode\Cart\Domain\Model\Order\Tax( + null, + $this->taxClass + ); + } + + /** + * @test + */ + public function constructTaxWithoutTaxClassThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $taxClass for constructor.', + 1456836520 + ); + + new \Extcode\Cart\Domain\Model\Order\Tax( + $this->tax, + null + ); + } + + /** + * @test + */ + public function getTaxInitiallyReturnsTaxSetDirectlyByConstructor() + { + $this->assertSame( + $this->tax, + $this->orderTax->getTax() + ); + } + + /** + * @test + */ + public function getTaxClassInitiallyReturnsTaxClassSetDirectlyByConstructor() + { + $this->assertSame( + $this->taxClass, + $this->orderTax->getTaxClass() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Order/TransactionTest.php b/Tests/Unit/Domain/Model/Order/TransactionTest.php new file mode 100644 index 00000000..76c1b19b --- /dev/null +++ b/Tests/Unit/Domain/Model/Order/TransactionTest.php @@ -0,0 +1,70 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + + +class TransactionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Order\Transaction + */ + protected $transaction = null; + + /** + * + */ + public function setUp() + { + $this->transaction = new \Extcode\Cart\Domain\Model\Order\Transaction(); + } + + /** + * @test + */ + public function getTxnIdInitiallyReturnsEmptyString() + { + $this->assertSame( + '', + $this->transaction->getTxnId() + ); + } + + /** + * @test + */ + public function setTxnIdSetsTnxId() + { + $transactionId = 'transaction-id'; + + $this->transaction->setTxnId($transactionId); + + $this->assertSame( + $transactionId, + $this->transaction->getTxnId() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Product/AbstractProductTest.php b/Tests/Unit/Domain/Model/Product/AbstractProductTest.php new file mode 100644 index 00000000..feb00109 --- /dev/null +++ b/Tests/Unit/Domain/Model/Product/AbstractProductTest.php @@ -0,0 +1,116 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + + +class AbstractProductTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $product = null; + + public function setUp() + { + $this->product = $this->getMockForAbstractClass('\Extcode\Cart\Domain\Model\Product\AbstractProduct'); + } + + /** + * @test + */ + public function getSkuReturnsInitialValueForString() + { + $this->assertSame( + '', + $this->product->getSku() + ); + } + + /** + * @test + */ + public function setSkuForStringSetsSku() + { + $this->product->setSku('Conceived at T3CON10'); + + $this->assertAttributeEquals( + 'Conceived at T3CON10', + 'sku', + $this->product + ); + } + + /** + * @test + */ + public function getTitleReturnsInitialValueForString() + { + $this->assertSame( + '', + $this->product->getTitle() + ); + } + + /** + * @test + */ + public function setTitleForStringSetsTitle() + { + $this->product->setTitle('Conceived at T3CON10'); + + $this->assertAttributeEquals( + 'Conceived at T3CON10', + 'title', + $this->product + ); + } + + /** + * @test + */ + public function getDescriptionReturnsInitialValueForString() + { + $this->assertSame( + '', + $this->product->getDescription() + ); + } + + /** + * @test + */ + public function setDescriptionForStringSetsDescription() + { + $this->product->setDescription('Conceived at T3CON10'); + + $this->assertAttributeEquals( + 'Conceived at T3CON10', + 'description', + $this->product + ); + } +} diff --git a/Tests/Unit/Domain/Model/Product/BeVariantAttributeTest.php b/Tests/Unit/Domain/Model/Product/BeVariantAttributeTest.php new file mode 100644 index 00000000..4ecd411d --- /dev/null +++ b/Tests/Unit/Domain/Model/Product/BeVariantAttributeTest.php @@ -0,0 +1,121 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + + +class BeVariantAttributeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Product\BeVariantAttribute + */ + protected $beVariantAttribute = null; + + /** + * + */ + public function setUp() + { + $this->beVariantAttribute = new \Extcode\Cart\Domain\Model\Product\BeVariantAttribute(); + } + + /** + * @test + */ + public function getBeVariantAttributeOptionsInitiallyIsEmpty() + { + $this->assertEmpty( + $this->beVariantAttribute->getBeVariantAttributeOptions() + ); + } + + /** + * @test + */ + public function setTransactionsSetsTransactions() + { + $beVariantAttributeOption1 = new \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption(); + $beVariantAttributeOption2 = new \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption(); + + $objectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $objectStorage->attach($beVariantAttributeOption1); + $objectStorage->attach($beVariantAttributeOption2); + + $this->beVariantAttribute->setBeVariantAttributeOptions($objectStorage); + + $this->assertContains( + $beVariantAttributeOption1, + $this->beVariantAttribute->getBeVariantAttributeOptions() + ); + $this->assertContains( + $beVariantAttributeOption2, + $this->beVariantAttribute->getBeVariantAttributeOptions() + ); + } + + /** + * @test + */ + public function addTransactionAddsTransaction() + { + $beVariantAttributeOption1 = new \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption(); + $beVariantAttributeOption2 = new \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption(); + + $this->beVariantAttribute->addBeVariantAttributeOption($beVariantAttributeOption1); + $this->beVariantAttribute->addBeVariantAttributeOption($beVariantAttributeOption2); + + $this->assertContains( + $beVariantAttributeOption1, + $this->beVariantAttribute->getBeVariantAttributeOptions() + ); + $this->assertContains( + $beVariantAttributeOption2, + $this->beVariantAttribute->getBeVariantAttributeOptions() + ); + } + + /** + * @test + */ + public function removeTransactionRemovesTransaction() + { + $beVariantAttributeOption1 = new \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption(); + $beVariantAttributeOption2 = new \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption(); + + $this->beVariantAttribute->addBeVariantAttributeOption($beVariantAttributeOption1); + $this->beVariantAttribute->addBeVariantAttributeOption($beVariantAttributeOption2); + $this->beVariantAttribute->removeBeVariantAttributeOption($beVariantAttributeOption1); + + $this->assertNotContains( + $beVariantAttributeOption1, + $this->beVariantAttribute->getBeVariantAttributeOptions() + ); + $this->assertContains( + $beVariantAttributeOption2, + $this->beVariantAttribute->getBeVariantAttributeOptions() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Product/BeVariantTest.php b/Tests/Unit/Domain/Model/Product/BeVariantTest.php new file mode 100644 index 00000000..86f8b6eb --- /dev/null +++ b/Tests/Unit/Domain/Model/Product/BeVariantTest.php @@ -0,0 +1,119 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + + +class BeVariantTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Product\BeVariant + */ + protected $beVariant = null; + + /** + * + */ + public function setUp() + { + $this->beVariant = new \Extcode\Cart\Domain\Model\Product\BeVariant(); + } + + /** + * @test + */ + public function getBeVariantAttributeOption1InitiallyIsNull() + { + $this->assertNull( + $this->beVariant->getBeVariantAttributeOption1() + ); + } + + /** + * @test + */ + public function setBeVariantAttributeOption1SetsBeVariantAttributeOption1() + { + $beVariantAttributeOption = new \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption(); + + $this->beVariant->setBeVariantAttributeOption1($beVariantAttributeOption); + + $this->assertSame( + $beVariantAttributeOption, + $this->beVariant->getBeVariantAttributeOption1() + ); + } + + /** + * @test + */ + public function getBeVariantAttributeOption2InitiallyIsNull() + { + $this->assertNull( + $this->beVariant->getBeVariantAttributeOption2() + ); + } + + /** + * @test + */ + public function setBeVariantAttributeOption2SetsBeVariantAttributeOption2() + { + $beVariantAttributeOption = new \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption(); + + $this->beVariant->setBeVariantAttributeOption2($beVariantAttributeOption); + + $this->assertSame( + $beVariantAttributeOption, + $this->beVariant->getBeVariantAttributeOption2() + ); + } + + /** + * @test + */ + public function getBeVariantAttributeOption3InitiallyIsNull() + { + $this->assertNull( + $this->beVariant->getBeVariantAttributeOption3() + ); + } + + /** + * @test + */ + public function setBeVariantAttributeOption3SetsBeVariantAttributeOption3() + { + $beVariantAttributeOption = new \Extcode\Cart\Domain\Model\Product\BeVariantAttributeOption(); + + $this->beVariant->setBeVariantAttributeOption3($beVariantAttributeOption); + + $this->assertSame( + $beVariantAttributeOption, + $this->beVariant->getBeVariantAttributeOption3() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Product/CouponTest.php b/Tests/Unit/Domain/Model/Product/CouponTest.php new file mode 100644 index 00000000..ff052ed3 --- /dev/null +++ b/Tests/Unit/Domain/Model/Product/CouponTest.php @@ -0,0 +1,318 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +class CouponTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * @var \Extcode\Cart\Domain\Model\Product\Coupon + */ + protected $coupon = null; + + /** + * Title + * + * @var string + */ + protected $title = ''; + + /** + * Code + * + * @var string + */ + protected $code = ''; + + /** + * Discount + * + * @var float + */ + protected $discount = 0.0; + + /** + * TaxClass + * + * @var int + */ + protected $taxClassId = 0; + + /** + * + */ + public function setUp() + { + $this->title = 'Coupon'; + $this->code = 'coupon'; + $this->discount = 10.00; + $this->taxClassId = 1; + + $this->coupon = new \Extcode\Cart\Domain\Model\Product\Coupon( + $this->title, + $this->code, + $this->discount, + $this->taxClassId + ); + } + + /** + * @test + */ + public function constructCouponWithoutTitleThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $title for constructor.', + 1456840910 + ); + + $this->coupon = new \Extcode\Cart\Domain\Model\Product\Coupon( + null, + $this->code, + $this->discount, + $this->taxClassId + ); + } + + /** + * @test + */ + public function constructCouponWithoutCodeThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $code for constructor.', + 1456840920 + ); + + $this->coupon = new \Extcode\Cart\Domain\Model\Product\Coupon( + $this->title, + null, + $this->discount, + $this->taxClassId + ); + } + + /** + * @test + */ + public function constructCouponWithoutDiscountThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $discount for constructor.', + 1456840930 + ); + + $this->coupon = new \Extcode\Cart\Domain\Model\Product\Coupon( + $this->title, + $this->code, + null, + $this->taxClassId + ); + } + + /** + * @test + */ + public function constructCouponWithoutTaxClassIdThrowsException() + { + $this->setExpectedException( + 'InvalidArgumentException', + 'You have to specify a valid $taxClassId for constructor.', + 1456840940 + ); + + $this->coupon = new \Extcode\Cart\Domain\Model\Product\Coupon( + $this->title, + $this->code, + $this->discount, + null + ); + } + + /** + * @test + */ + public function getTitleInitiallyReturnsTitleSetDirectlyByConstructor() + { + $this->assertSame( + $this->title, + $this->coupon->getTitle() + ); + } + + /** + * @test + */ + public function getCodeInitiallyReturnsCodeSetDirectlyByConstructor() + { + $this->assertSame( + $this->code, + $this->coupon->getCode() + ); + } + + /** + * @test + */ + public function getDiscountInitiallyReturnsDiscountSetDirectlyByConstructor() + { + $this->assertSame( + $this->discount, + $this->coupon->getDiscount() + ); + } + + /** + * @test + */ + public function getTaxClassIdReturnsTaxClassIdSetDirectlyByConstructor() + { + $this->assertSame( + $this->taxClassId, + $this->coupon->getTaxClassId() + ); + } + + /** + * @test + */ + public function isRelativeDiscountInitiallyReturnsFalse() + { + $this->assertFalse( + $this->coupon->isRelativeDiscount() + ); + } + + /** + * @test + */ + public function getNumberAvailableInitiallyReturnsZero() + { + $this->assertSame( + 0, + $this->coupon->getNumberAvailable() + ); + } + + /** + * @test + */ + public function getNumberUsedInitiallyReturnsZero() + { + $this->assertSame( + 0, + $this->coupon->getNumberUsed() + ); + } + + /** + * @test + */ + public function getIsAvailableReturnsTrueIfNumberAvailableGreaterThanNumberUsed() + { + $this->coupon->setNumberAvailable(10); + $this->coupon->setNumberUsed(1); + $this->assertTrue( + $this->coupon->getIsAvailable() + ); + } + + /** + * @test + */ + public function getIsAvailableReturnsFalseIfNumberAvailableEqualsToNumberUsed() + { + $this->coupon->setNumberAvailable(10); + $this->coupon->setNumberUsed(10); + $this->assertFalse( + $this->coupon->getIsAvailable() + ); + } + + /** + * @test + */ + public function getIsAvailableReturnsFalseIfNumberAvailableLessThanNumberUsed() + { + $this->coupon->setNumberAvailable(10); + $this->coupon->setNumberUsed(11); + $this->assertFalse( + $this->coupon->getIsAvailable() + ); + } + + /** + * @test + */ + public function getCartMinPriceInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->coupon->getCartMinPrice() + ); + } + + /** + * @test + */ + public function setCartMinPriceSetsMinPrice() + { + $cartMinPrice = 10.0; + + $this->coupon->setCartMinPrice($cartMinPrice); + + $this->assertSame( + $cartMinPrice, + $this->coupon->getCartMinPrice() + ); + } + + /** + * @test + */ + public function getIsCombinableInitiallyReturnsFalse() + { + $this->assertFalse( + $this->coupon->getIsCombinable() + ); + } + + /** + * @test + */ + public function setIsCombinableSetsIsCombinable() { + $isCombinable = true; + + $this->coupon->setIsCombinable($isCombinable); + + $this->assertTrue( + $this->coupon->getIsCombinable() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Product/ProductTest.php b/Tests/Unit/Domain/Model/Product/ProductTest.php new file mode 100644 index 00000000..2019970c --- /dev/null +++ b/Tests/Unit/Domain/Model/Product/ProductTest.php @@ -0,0 +1,846 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + + +class ProductTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + + /** + * @var \Extcode\Cart\Domain\Model\Product\Product + */ + protected $product = null; + + protected function setUp() + { + $this->product = new \Extcode\Cart\Domain\Model\Product\Product(); + } + + protected function tearDown() + { + unset($this->product); + } + + /** + * DataProvider for best Special Price calculation + * + * @return array + */ + public function bestSpecialPriceProvider() + { + return [ + [100.0, 80.0, 75.0, 90.0, 75.0], + [100.0, 75.0, 90.0, 50.0, 50.0], + [100.0, 80.0, 60.0, 80.0, 60.0], + ]; + } + + /** + * DataProvider for best Special Price Discount calculation + * + * @return array + */ + public function bestSpecialPriceDiscountProvider() + { + return [ + [100.0, 80.0, 75.0, 90.0, 25.0], + [100.0, 75.0, 90.0, 50.0, 50.0], + [100.0, 80.0, 60.0, 80.0, 40.0], + ]; + } + + /** + * @test + */ + public function getTeaserReturnsInitialValueForString() + { + $this->assertSame( + '', + $this->product->getTeaser() + ); + } + + /** + * @test + */ + public function setTeaserForStringSetsTeaser() + { + $this->product->setTeaser('Conceived at T3CON10'); + + $this->assertAttributeEquals( + 'Conceived at T3CON10', + 'teaser', + $this->product + ); + } + + /** + * @test + */ + public function getMinNumberInOrderInitiallyReturnsMinNumberInOrder() + { + $this->assertSame( + 0, + $this->product->getMinNumberInOrder() + ); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function setNegativeMinNumberThrowsException() + { + $minNumber = -10; + + $this->product->setMinNumberInOrder($minNumber); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function setMinNumberGreaterThanMaxNumberThrowsException() + { + $minNumber = 10; + + $this->product->setMinNumberInOrder($minNumber); + } + + /** + * @test + */ + public function setMinNumberInOrderSetsMinNumberInOrder() + { + $minNumber = 10; + + $this->product->setMaxNumberInOrder($minNumber); + $this->product->setMinNumberInOrder($minNumber); + + $this->assertSame( + $minNumber, + $this->product->getMinNumberInOrder() + ); + } + + /** + * @test + */ + public function getMaxNumberInOrderInitiallyReturnsMaxNumberInOrder() + { + $this->assertSame( + 0, + $this->product->getMaxNumberInOrder() + ); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function setNegativeMaxNumberThrowsException() + { + $maxNumber = -10; + + $this->product->setMaxNumberInOrder($maxNumber); + } + + /** + * @test + */ + public function setMaxNumberInOrderSetsMaxNumberInOrder() + { + $maxNumber = 10; + + $this->product->setMaxNumberInOrder($maxNumber); + + $this->assertSame( + $maxNumber, + $this->product->getMaxNumberInOrder() + ); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function setMaxNumberLesserThanMinNumberThrowsException() + { + $minNumber = 10; + $maxNumber = 1; + + $this->product->setMaxNumberInOrder($minNumber); + $this->product->setMinNumberInOrder($minNumber); + + $this->product->setMaxNumberInOrder($maxNumber); + } + + /** + * @test + */ + public function getPriceReturnsInitialValueForFloat() + { + $this->assertSame( + 0.0, + $this->product->getPrice() + ); + } + + /** + * @test + */ + public function setPriceSetsPrice() + { + $this->product->setPrice(3.14159265); + + $this->assertSame( + 3.14159265, + $this->product->getPrice() + ); + } + + /** + * @test + */ + public function getSpecialPricesInitiallyIsEmpty() + { + $this->assertEmpty( + $this->product->getSpecialPrices() + ); + } + + /** + * @test + */ + public function setSpecialPricesSetsSpecialPrices() + { + $price = 10.00; + + $specialPrice = new \Extcode\Cart\Domain\Model\Product\SpecialPrice(); + $specialPrice->setPrice($price); + + $objectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $objectStorage->attach($specialPrice); + + $this->product->setSpecialPrices($objectStorage); + + $this->assertContains( + $specialPrice, + $this->product->getSpecialPrices() + ); + } + + /** + * @test + */ + public function addSpecialPriceAddsSpecialPrice() + { + $price = 10.00; + + $specialPrice = new \Extcode\Cart\Domain\Model\Product\SpecialPrice(); + $specialPrice->setPrice($price); + + $this->product->addSpecialPrice($specialPrice); + + $this->assertContains( + $specialPrice, + $this->product->getSpecialPrices() + ); + } + + /** + * @test + */ + public function removeSpecialPriceRemovesSpecialPrice() + { + $price = 10.00; + + $specialPrice = new \Extcode\Cart\Domain\Model\Product\SpecialPrice(); + $specialPrice->setPrice($price); + + $this->product->addSpecialPrice($specialPrice); + $this->product->removeSpecialPrice($specialPrice); + + $this->assertEmpty( + $this->product->getSpecialPrices() + ); + } + + /** + * @test + */ + public function getBestSpecialPriceDiscountForEmptySpecialPriceReturnsDiscount() + { + $price = 10.00; + + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setPrice($price); + + $this->assertSame( + 0.0, + $product->getBestSpecialPriceDiscount() + ); + } + + /** + * @test + * @dataProvider bestSpecialPriceProvider + */ + public function getBestSpecialPriceForGivenSpecialPricesReturnsBestSpecialPrice( + $price, + $special1, + $special2, + $special3, + $expectedBestSpecialPrice + ) { + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setPrice($price); + + $specialPrice1 = new \Extcode\Cart\Domain\Model\Product\SpecialPrice(); + $specialPrice1->setPrice($special1); + $product->addSpecialPrice($specialPrice1); + + $specialPrice2 = new \Extcode\Cart\Domain\Model\Product\SpecialPrice(); + $specialPrice2->setPrice($special2); + $product->addSpecialPrice($specialPrice2); + + $specialPrice3 = new \Extcode\Cart\Domain\Model\Product\SpecialPrice(); + $specialPrice3->setPrice($special3); + $product->addSpecialPrice($specialPrice3); + + $this->assertSame( + $expectedBestSpecialPrice, + $product->getBestSpecialPrice() + ); + } + + /** + * @test + */ + public function getBestSpecialPriceDiscountForGivenSpecialPriceReturnsPercentageDiscount() + { + $price = 10.0; + $porductSpecialPrice = 9.0; + + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setPrice($price); + + $specialPrice = new \Extcode\Cart\Domain\Model\Product\SpecialPrice(); + $specialPrice->setPrice($porductSpecialPrice); + + $product->addSpecialPrice($specialPrice); + + $this->assertSame( + 10.0, + $product->getBestSpecialPricePercentageDiscount() + ); + } + + /** + * @test + * @dataProvider bestSpecialPriceDiscountProvider + */ + public function getBestSpecialPriceDiscountForGivenSpecialPricesReturnsBestPercentageDiscount( + $price, + $special1, + $special2, + $special3, + $expectedBestSpecialPriceDiscount + ) { + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setPrice($price); + + $specialPrice1 = new \Extcode\Cart\Domain\Model\Product\SpecialPrice(); + $specialPrice1->setPrice($special1); + $product->addSpecialPrice($specialPrice1); + + $specialPrice2 = new \Extcode\Cart\Domain\Model\Product\SpecialPrice(); + $specialPrice2->setPrice($special2); + $product->addSpecialPrice($specialPrice2); + + $specialPrice3 = new \Extcode\Cart\Domain\Model\Product\SpecialPrice(); + $specialPrice3->setPrice($special3); + $product->addSpecialPrice($specialPrice3); + + $this->assertSame( + $expectedBestSpecialPriceDiscount, + $product->getBestSpecialPriceDiscount() + ); + } + + /** + * @test + */ + public function getStockInitiallyReturnsZero() + { + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + + $this->assertSame( + 0, + $product->getStock() + ); + } + + /** + * @test + */ + public function setStockSetsStock() + { + $stock = 10; + + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setStock($stock); + + $this->assertSame( + $stock, + $product->getStock() + ); + } + + /** + * @test + */ + public function addToStockAddsANumberOfProductsToStock() + { + $numberOfProducts = 10; + + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setHandleStock(true); + $product->addToStock($numberOfProducts); + + $this->assertSame( + $numberOfProducts, + $product->getStock() + ); + } + + /** + * @test + */ + public function removeFromStockAddsRemovesANumberOfProductsFromStock() + { + $stock = 100; + $numberOfProducts = 10; + + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setHandleStock(true); + $product->setStock($stock); + $product->removeFromStock($numberOfProducts); + + $this->assertSame( + ($stock - $numberOfProducts), + $product->getStock() + ); + } + + /** + * @test + */ + public function handleStockInitiallyReturnsFalse() + { + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + + $this->assertFalse( + $product->handleStock() + ); + } + + /** + * @test + */ + public function setHandleStockSetsHandleStock() + { + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setHandleStock(true); + + $this->assertTrue( + $product->handleStock() + ); + } + + /** + * @test + */ + public function getPriceMeasure() + { + $this->assertSame( + 0.0, + $this->product->getPriceMeasure() + ); + } + + /** + * @test + */ + public function setPriceMeasureSetsPriceMeasure() + { + $priceMeasure = 10.99; + + $this->product->setPriceMeasure($priceMeasure); + + $this->assertSame( + $priceMeasure, + $this->product->getPriceMeasure() + ); + } + + /** + * @test + */ + public function getPriceMeasureUnit() + { + $this->assertSame( + '', + $this->product->getPriceMeasureUnit() + ); + } + + /** + * @test + */ + public function setPriceMeasureUnitSetsPriceMeasureUnit() + { + $priceMeasureUnit = 'l'; + + $this->product->setPriceMeasureUnit($priceMeasureUnit); + + $this->assertSame( + $priceMeasureUnit, + $this->product->getPriceMeasureUnit() + ); + } + + /** + * @test + */ + public function getBasePriceMeasureUnit() + { + $this->assertSame( + '', + $this->product->getBasePriceMeasureUnit() + ); + } + + /** + * @test + */ + public function setBasePriceMeasureUnitSetsBasePriceMeasureUnit() + { + $priceBaseMeasureUnit = 'l'; + + $this->product->setBasePriceMeasureUnit($priceBaseMeasureUnit); + + $this->assertSame( + $priceBaseMeasureUnit, + $this->product->getBasePriceMeasureUnit() + ); + } + + /** + * @test + */ + public function getIsMeasureUnitCompatibilityInitiallyRetrunsFalse() + { + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + + $this->assertFalse( + $product->getIsMeasureUnitCompatibility() + ); + } + + /** + * @test + */ + public function getIsMeasureUnitCompatibilityAndNotSetPriceMeasureUnitsRetrunsFalse() + { + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setBasePriceMeasureUnit('l'); + + $this->assertFalse( + $product->getIsMeasureUnitCompatibility() + ); + } + + /** + * @test + */ + public function getIsMeasureUnitCompatibilityAndNotSetBasePriceMeasureUnitsRetrunsFalse() + { + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setPriceMeasureUnit('l'); + + $this->assertFalse( + $product->getIsMeasureUnitCompatibility() + ); + } + + /** + * Measurement Units Provider + * + * @return array + */ + public function measureUnitsProvider() + { + return [ + ['mg', 'kg', 1000000.0, 1000.0, 1000.0], + ['g', 'kg', 1000.0, 1000.0, 1.0], + ['kg', 'kg', 1.0, 1000.0, 0.001], + ['ml', 'l', 1000.0, 1000.0, 1.0], + ['cl', 'l', 100.0, 1000.0, 0.1], + ['l', 'l', 1.0, 1000.0, 0.001], + ['cbm', 'l', 0.001, 1.0, 0.001], + ['mm', 'm', 1000.0, 1000.0, 1.0], + ['cm', 'm', 100.0, 1000.0, 0.1], + ['m', 'm', 1.0, 2.0, 0.5], + ['km', 'm', 0.001, 2.0, 0.0005], + ['m2', 'm2', 1.0, 20.0, 0.05], + ]; + } + + /** + * @test + * @dataProvider measureUnitsProvider + */ + public function getIsMeasureUnitCompatibilityRetrunsTrueOnSameTypeOfMeasureUnit( + $sourceMeasureUnit, + $targetMeasureUnit, + $factor, + $priceMeasure, + $calculatedBasePrice + ) { + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setPriceMeasureUnit($sourceMeasureUnit); + $product->setBasePriceMeasureUnit($targetMeasureUnit); + + $this->assertTrue( + $product->getIsMeasureUnitCompatibility() + ); + } + + /** + * @test + * @dataProvider measureUnitsProvider + */ + public function getMeasureUnitFactorForGivenPriceMeasureUnitAndBasePriceMeasureUnitRetrunsFactor( + $sourceMeasureUnit, + $targetMeasureUnit, + $factor, + $priceMeasure, + $calculatedBasePrice + ) { + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setPriceMeasureUnit($sourceMeasureUnit); + $product->setBasePriceMeasureUnit($targetMeasureUnit); + $product->setPriceMeasure(1); + + $this->assertSame( + $factor, + $product->getMeasureUnitFactor() + ); + } + + /** + * @test + * @dataProvider measureUnitsProvider + */ + public function getCalculatedBasePriceForGivenPriceMeasureUnitAndBasePriceMeasureUnitRetrunsPrice( + $sourceMeasureUnit, + $targetMeasureUnit, + $factor, + $priceMeasure, + $calculatedBasePrice + ) { + $product = new \Extcode\Cart\Domain\Model\Product\Product(); + $product->setPriceMeasureUnit($sourceMeasureUnit); + $product->setBasePriceMeasureUnit($targetMeasureUnit); + $product->setPriceMeasure($priceMeasure); + + $this->assertSame( + $calculatedBasePrice, + $product->getMeasureUnitFactor() + ); + } + + /** + * @test + */ + public function getTaxClassIdInitiallyReturnsTaxClassId() + { + $this->assertSame( + 1, + $this->product->getTaxClassId() + ); + } + + /** + * @test + */ + public function setTaxClassIdSetsTaxClassId() + { + $taxClassId = 2; + + $this->product->setTaxClassId($taxClassId); + + $this->assertSame( + $taxClassId, + $this->product->getTaxClassId() + ); + } + + /** + * @test + */ + public function getBeVariantAttribute1InitiallyIsNull() + { + $this->assertNull( + $this->product->getBeVariantAttribute1() + ); + } + + /** + * @test + */ + public function setBeVariantAttribute1SetsBeVariantAttribute1() + { + $beVariantAttribute = new \Extcode\Cart\Domain\Model\Product\BeVariantAttribute(); + + $this->product->setBeVariantAttribute1($beVariantAttribute); + + $this->assertSame( + $beVariantAttribute, + $this->product->getBeVariantAttribute1() + ); + } + + /** + * @test + */ + public function getBeVariantAttribute2InitiallyIsNull() + { + $this->assertNull( + $this->product->getBeVariantAttribute2() + ); + } + + /** + * @test + */ + public function setBeVariantAttribute2SetsBeVariantAttribute2() + { + $beVariantAttribute = new \Extcode\Cart\Domain\Model\Product\BeVariantAttribute(); + + $this->product->setBeVariantAttribute2($beVariantAttribute); + + $this->assertSame( + $beVariantAttribute, + $this->product->getBeVariantAttribute2() + ); + } + + /** + * @test + */ + public function getBeVariantAttribute3InitiallyIsNull() + { + $this->assertNull( + $this->product->getBeVariantAttribute3() + ); + } + + /** + * @test + */ + public function setBeVariantAttribute3SetsBeVariantAttribute3() + { + $beVariantAttribute = new \Extcode\Cart\Domain\Model\Product\BeVariantAttribute(); + + $this->product->setBeVariantAttribute3($beVariantAttribute); + + $this->assertSame( + $beVariantAttribute, + $this->product->getBeVariantAttribute3() + ); + } + + /** + * @test + */ + public function getVariantsInitiallyIsEmpty() + { + $this->assertEmpty( + $this->product->getBeVariants() + ); + } + + /** + * @test + */ + public function setVariantsSetsVariants() + { + $variant = new \Extcode\Cart\Domain\Model\Product\BeVariant(); + + $objectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); + $objectStorage->attach($variant); + + $this->product->setBeVariants($objectStorage); + + $this->assertContains( + $variant, + $this->product->getBeVariants() + ); + } + + /** + * @test + */ + public function addVariantAddsVariant() + { + $variant = new \Extcode\Cart\Domain\Model\Product\BeVariant(); + + $this->product->addBeVariant($variant); + + $this->assertContains( + $variant, + $this->product->getBeVariants() + ); + } + + /** + * @test + */ + public function removeVariantRemovesVariant() + { + $variant = new \Extcode\Cart\Domain\Model\Product\BeVariant(); + + $this->product->addBeVariant($variant); + $this->product->removeBeVariant($variant); + + $this->assertEmpty( + $this->product->getBeVariants() + ); + } +} diff --git a/Tests/Unit/Domain/Model/Product/SpecialPriceTest.php b/Tests/Unit/Domain/Model/Product/SpecialPriceTest.php new file mode 100644 index 00000000..bb0eb864 --- /dev/null +++ b/Tests/Unit/Domain/Model/Product/SpecialPriceTest.php @@ -0,0 +1,73 @@ +, extco.de + * + * All rights reserved + * + * This script is part of the TYPO3 project. The TYPO3 project is + * free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * The GNU General Public License can be found at + * http://www.gnu.org/copyleft/gpl.html. + * + * This script is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * This copyright notice MUST APPEAR in all copies of the script! + ***************************************************************/ + +class SpecialPriceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase +{ + /** + * Product Tax Class + * + * @var \Extcode\Cart\Domain\Model\Product\SpecialPrice + */ + protected $fixture = null; + + /** + * Set Up + * + * @return void + */ + public function setUp() + { + $this->fixture = new \Extcode\Cart\Domain\Model\Product\SpecialPrice(); + } + + /** + * @test + */ + public function getPriceInitiallyReturnsZero() + { + $this->assertSame( + 0.0, + $this->fixture->getPrice() + ); + } + + /** + * @test + */ + public function setPriceSetThePrice() + { + $price = 1.00; + + $this->fixture->setPrice($price); + + $this->assertSame( + $price, + $this->fixture->getPrice() + ); + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..f72baa25 --- /dev/null +++ b/composer.json @@ -0,0 +1,29 @@ +{ + "name": "extcode/cart", + "type": "typo3-cms-extension", + "description": "Shopping Cart", + "homepage": "http://cart.extco.de", + "license": [ + "GPL-2.0+" + ], + "keywords": [ + "TYPO3 CMS", + "Shopping Cart", + "cart" + ], + "support": { + "issues": "https://forge.typo3.org/projects/extension-cart" + }, + "version": "0.2.0", + "require": { + "typo3/cms-core": ">=6.2.0,<8.0" + }, + "replace": { + "cart": "*" + }, + "autoload": { + "psr-4": { + "Extcode\\Cart\\": "Classes/" + } + } +} \ No newline at end of file diff --git a/ext_emconf.php b/ext_emconf.php new file mode 100644 index 00000000..2f840b5e --- /dev/null +++ b/ext_emconf.php @@ -0,0 +1,32 @@ + 'Cart', + 'description' => 'Adds shopping cart(s) to your TYPO3 installation', + 'category' => 'plugin', + 'shy' => false, + 'version' => '0.5.0', + 'dependencies' => '', + 'conflicts' => '', + 'priority' => '', + 'loadOrder' => '', + 'module' => '', + 'state' => 'beta', + 'uploadfolder' => false, + 'createDirs' => '', + 'modify_tables' => '', + 'clearcacheonload' => true, + 'lockType' => '', + 'author' => 'Daniel Lorenz', + 'author_email' => 'ext.cart@extco.de', + 'author_company' => 'extco.de UG (haftungsbeschränkt)', + 'CGLcompliance' => null, + 'CGLcompliance_note' => null, + 'constraints' => array( + 'depends' => array( + 'typo3' => '6.2.0-7.99.99', + ), + 'conflicts' => array(), + 'suggests' => array(), + ), +); diff --git a/ext_icon.gif b/ext_icon.gif new file mode 100644 index 00000000..55213703 Binary files /dev/null and b/ext_icon.gif differ diff --git a/ext_localconf.php b/ext_localconf.php new file mode 100644 index 00000000..bf49b862 --- /dev/null +++ b/ext_localconf.php @@ -0,0 +1,53 @@ + 'showMini', + ], + // non-cacheable actions + [ + 'Cart' => 'showMini', + ] +); + +\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'Extcode.' . $_EXTKEY, + 'Cart', + [ + 'Cart' => 'showCart, clearCart, addProduct, removeProduct, addCoupon, setShipping, setPayment, updateCart, orderCart', + ], + // non-cacheable actions + [ + 'Cart' => 'showCart, clearCart, addProduct, removeProduct, addCoupon, setShipping, setPayment, updateCart, orderCart', + ] +); + +\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'Extcode.' . $_EXTKEY, + 'Product', + [ + 'Product' => 'show, list, teaser, flexform', + ], + // non-cacheable actions + [ + 'Product' => 'show', + ] +); + +\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( + 'Extcode.' . $_EXTKEY, + 'Order', + [ + 'Order' => 'list, show', + ], + // non-cacheable actions + [ + 'Order' => 'list, show', + ] +); + +$TYPO3_CONF_VARS['FE']['eID_include']['addProduct'] = 'EXT:cart/eid/addProduct.php'; diff --git a/ext_tables.php b/ext_tables.php new file mode 100644 index 00000000..a7d298de --- /dev/null +++ b/ext_tables.php @@ -0,0 +1,197 @@ + $val) { + if ($key == 'web') { + $temp_TBE_MODULES[$key] = $val; + $temp_TBE_MODULES['Cart'] = ''; + } else { + $temp_TBE_MODULES[$key] = $val; + } + } + + $TBE_MODULES = $temp_TBE_MODULES; + } + + // add Main Module + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( + 'Extcode.' . $_EXTKEY, + 'Cart', + '', + '', + [], + [ + 'access' => 'user, group', + 'icon' => $iconPath . 'module.' . (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('7.0') ? 'svg' : 'gif'), + 'labels' => $_LLL . ':tx_cart.module.main', + 'navigationComponentId' => 'typo3-pagetree', + ] + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( + 'Extcode.' . $_EXTKEY, + 'Cart', + 'Orders', + '', + [ + 'Order' => 'list, export, show, edit, update, generateInvoiceNumber, generateInvoiceDocument, downloadInvoiceDocument', + ], + [ + 'access' => 'user, group', + 'icon' => $iconPath . 'module_orders.' . (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('7.0') ? 'svg' : 'png'), + 'labels' => $_LLL . ':tx_cart.module.orders', + 'navigationComponentId' => 'typo3-pagetree', + ] + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( + 'Extcode.' . $_EXTKEY, + 'Cart', + 'OrderStatistics', + '', + [ + 'Order' => 'statistic', + ], + [ + 'access' => 'user, group', + 'icon' => $iconPath . 'module_order_statistics.' . (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('7.0') ? 'svg' : 'png'), + 'labels' => $_LLL . ':tx_cart.module.order_statistics', + 'navigationComponentId' => 'typo3-pagetree', + ] + ); + + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( + 'Extcode.' . $_EXTKEY, + 'Cart', + 'Products', + '', + [ + 'Product' => 'list, show,', + 'Variant' => 'list, show, edit, update', + ], + [ + 'access' => 'user, group', + 'icon' => $iconPath . 'module_products.' . (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('7.0') ? 'svg' : 'png'), + 'labels' => $_LLL . ':tx_cart.module.products', + 'navigationComponentId' => 'typo3-pagetree', + ] + ); +} + +$TCA['pages']['columns']['module']['config']['items'][] = [ + 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_db.xlf:tx_cart.module.orders', + 'orders', + $iconPath . 'pages_orders_icon.png' +]; + +\TYPO3\CMS\Backend\Sprite\SpriteManager::addTcaTypeIcon( + 'pages', + 'contains-orders', + $iconPath . 'pages_orders_icon.png' +); + +$TCA['pages']['columns']['module']['config']['items'][] = [ + 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_db.xlf:tx_cart.module.products', + 'products', + $iconPath . 'pages_products_icon.png' +]; + +\TYPO3\CMS\Backend\Sprite\SpriteManager::addTcaTypeIcon( + 'pages', + 'contains-products', + $iconPath . 'pages_products_icon.png' +); + +$tables = [ + 'order_item', + 'order_address', + 'order_taxclass', + 'order_tax', + 'order_product', + 'order_productadditional', + 'order_shipping', + 'order_payment', + 'order_transaction', + 'product_coupon', + 'product_product', + 'product_specialprice', + 'product_taxclass', + 'product_fevariant', + 'product_bevariant', + 'product_bevariantattribute', + 'product_bevariantattributeoption', +]; + +foreach ($tables as $table) { + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr( + 'tx_cart_domain_model_' . $table, + 'EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_csh_tx_cart_domain_model_' . $table . '.xlf' + ); +} + +\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::makeCategorizable( + $_EXTKEY, + 'tx_cart_domain_model_product_product', + 'product_categories', + [] +); diff --git a/ext_tables.sql b/ext_tables.sql new file mode 100644 index 00000000..85a193c3 --- /dev/null +++ b/ext_tables.sql @@ -0,0 +1,781 @@ +# +# Table structure for table 'tx_cart_domain_model_product_product' +# +CREATE TABLE tx_cart_domain_model_product_product ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + sku varchar(255) DEFAULT '' NOT NULL, + title varchar(255) DEFAULT '' NOT NULL, + teaser text NOT NULL, + description text NOT NULL, + + min_number_in_order int(11) unsigned DEFAULT '0' NOT NULL, + max_number_in_order int(11) unsigned DEFAULT '0' NOT NULL, + + price double(11,2) DEFAULT '0.00' NOT NULL, + special_prices int(11) unsigned DEFAULT '0' NOT NULL, + price_measure double(11,2) DEFAULT '0.00' NOT NULL, + price_measure_unit varchar(8) DEFAULT '' NOT NULL, + base_price_measure double(11,2) DEFAULT '0.00' NOT NULL, + base_price_measure_unit varchar(8) DEFAULT '' NOT NULL, + + stock int(11) unsigned DEFAULT '0' NOT NULL, + handle_stock tinyint(4) unsigned DEFAULT '0' NOT NULL, + + tax_class_id int(11) unsigned DEFAULT '1' NOT NULL, + + product_content int(11) DEFAULT '0' NOT NULL, + + images varchar(255) DEFAULT '' NOT NULL, + files varchar(255) DEFAULT '' NOT NULL, + + be_variant_attribute1 int(11) unsigned DEFAULT '0' NOT NULL, + be_variant_attribute2 int(11) unsigned DEFAULT '0' NOT NULL, + be_variant_attribute3 int(11) unsigned DEFAULT '0' NOT NULL, + + fe_variants int(11) unsigned DEFAULT '0' NOT NULL, + be_variants int(11) unsigned DEFAULT '0' NOT NULL, + + related_products int(11) DEFAULT '0' NOT NULL, + related_products_from int(11) DEFAULT '0' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, + starttime int(11) unsigned DEFAULT '0' NOT NULL, + endtime int(11) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + sys_language_uid int(11) DEFAULT '0' NOT NULL, + l10n_parent int(11) DEFAULT '0' NOT NULL, + l10n_diffsource mediumblob, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid), + KEY language (l10n_parent,sys_language_uid) + +); + +# +# Table structure for table 'tx_cart_domain_model_product_specialprice' +# +CREATE TABLE tx_cart_domain_model_product_specialprice ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + product int(11) unsigned DEFAULT '0' NOT NULL, + + price double(11,2) DEFAULT '0.00' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, + starttime int(11) unsigned DEFAULT '0' NOT NULL, + endtime int(11) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + sys_language_uid int(11) DEFAULT '0' NOT NULL, + l10n_parent int(11) DEFAULT '0' NOT NULL, + l10n_diffsource mediumblob, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid), + KEY language (l10n_parent,sys_language_uid) + +); + +# +# Table structure for table 'tx_cart_domain_model_product_bevariantattribute' +# +CREATE TABLE tx_cart_domain_model_product_bevariantattribute ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + product int(11) unsigned DEFAULT '0' NOT NULL, + be_variant_attribute_options int(11) unsigned DEFAULT '0' NOT NULL, + + sku varchar(255) DEFAULT '' NOT NULL, + title varchar(255) DEFAULT '' NOT NULL, + description text NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, + starttime int(11) unsigned DEFAULT '0' NOT NULL, + endtime int(11) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + sys_language_uid int(11) DEFAULT '0' NOT NULL, + l10n_parent int(11) DEFAULT '0' NOT NULL, + l10n_diffsource mediumblob, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid), + KEY language (l10n_parent,sys_language_uid) + +); + +# +# Table structure for table 'tx_cart_domain_model_product_bevariantattributeoption' +# +CREATE TABLE tx_cart_domain_model_product_bevariantattributeoption ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + be_variant_attribute int(11) unsigned DEFAULT '0' NOT NULL, + + sku varchar(255) DEFAULT '' NOT NULL, + title varchar(255) DEFAULT '' NOT NULL, + description text NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, + starttime int(11) unsigned DEFAULT '0' NOT NULL, + endtime int(11) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + sys_language_uid int(11) DEFAULT '0' NOT NULL, + l10n_parent int(11) DEFAULT '0' NOT NULL, + l10n_diffsource mediumblob, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid), + KEY language (l10n_parent,sys_language_uid) + +); + +# +# Table structure for table 'tx_cart_domain_model_product_fevariant' +# +CREATE TABLE tx_cart_domain_model_product_fevariant ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + product int(11) unsigned DEFAULT '0' NOT NULL, + + sku varchar(255) DEFAULT '' NOT NULL, + title varchar(255) DEFAULT '' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, + starttime int(11) unsigned DEFAULT '0' NOT NULL, + endtime int(11) unsigned DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + +); + +# +# Table structure for table 'tx_cart_domain_model_product_bevariant' +# +CREATE TABLE tx_cart_domain_model_product_bevariant ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + product int(11) unsigned DEFAULT '0' NOT NULL, + + be_variant_attribute_option1 int(11) unsigned DEFAULT '0' NOT NULL, + be_variant_attribute_option2 int(11) unsigned DEFAULT '0' NOT NULL, + be_variant_attribute_option3 int(11) unsigned DEFAULT '0' NOT NULL, + + price double(11,2) DEFAULT '0.00' NOT NULL, + price_calc_method int(11) unsigned DEFAULT '0' NOT NULL, + price_measure double(11,2) DEFAULT '0.00' NOT NULL, + price_measure_unit varchar(8) DEFAULT '' NOT NULL, + + stock int(11) unsigned DEFAULT '0' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + hidden tinyint(4) unsigned DEFAULT '0' NOT NULL, + starttime int(11) unsigned DEFAULT '0' NOT NULL, + endtime int(11) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + sys_language_uid int(11) DEFAULT '0' NOT NULL, + l10n_parent int(11) DEFAULT '0' NOT NULL, + l10n_diffsource mediumblob, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid), + KEY language (l10n_parent,sys_language_uid) + +); + +# +# Extend table structure of table 'tt_content' +# +CREATE TABLE tt_content ( + tx_cart_domain_model_product_product int(11) unsigned DEFAULT '0' NOT NULL, +); + +# +# Table structure for table 'tx_cart_domain_model_order_item' +# +CREATE TABLE tx_cart_domain_model_order_item ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + fe_user int(11) unsigned DEFAULT '0', + + billing_address int(11) unsigned DEFAULT '0' NOT NULL, + shipping_address int(11) unsigned DEFAULT '0' NOT NULL, + + order_number varchar(255) DEFAULT '' NOT NULL, + order_date int(11) unsigned DEFAULT '0' NOT NULL, + invoice_number varchar(255) DEFAULT '' NOT NULL, + invoice_date int(11) unsigned DEFAULT '0' NOT NULL, + currency varchar(255) DEFAULT '' NOT NULL, + gross double(11,2) DEFAULT '0.00' NOT NULL, + net double(11,2) DEFAULT '0.00' NOT NULL, + total_gross double(11,2) DEFAULT '0.00' NOT NULL, + total_net double(11,2) DEFAULT '0.00' NOT NULL, + order_pdf text NOT NULL, + invoice_pdf text NOT NULL, + + tax int(11) unsigned DEFAULT '0' NOT NULL, + total_tax int(11) unsigned DEFAULT '0' NOT NULL, + tax_class int(11) unsigned DEFAULT '0' NOT NULL, + products int(11) unsigned DEFAULT '0' NOT NULL, + coupons int(11) unsigned DEFAULT '0' NOT NULL, + shipping int(11) unsigned DEFAULT '0', + payment int(11) unsigned DEFAULT '0', + + additional_data text NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid) + +); + +# +# Table structure for table 'tx_cart_domain_model_order_address' +# +CREATE TABLE tx_cart_domain_model_order_address ( + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAU + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + title varchar(255) DEFAULT '' NOT NULL, + salutation varchar(255) DEFAULT '' NOT NULL, + first_name varchar(255) DEFAULT '' NOT NULL, + last_name varchar(255) DEFAULT '' NOT NULL, + email varchar(255) DEFAULT '' NOT NULL, + company varchar(255) DEFAULT '' NOT NULL, + street varchar(255) DEFAULT '' NOT NULL, + streetNumber varchar(255) DEFAULT '' NOT NULL, + zip varchar(255) DEFAULT '' NOT NULL, + city varchar(255) DEFAULT '' NOT NULL, + country varchar(255) DEFAULT '' NOT NULL, + phone varchar(255) DEFAULT '' NOT NULL, + fax varchar(255) DEFAULT '' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid) + +); + +# +# Table structure for table 'tx_cart_domain_model_order_taxclass' +# +CREATE TABLE tx_cart_domain_model_order_taxclass ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + item int(11) unsigned DEFAULT '0' NOT NULL, + + title varchar(255) DEFAULT '' NOT NULL, + value varchar(255) DEFAULT '' NOT NULL, + calc double(11,2) DEFAULT '0.00' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid) + +); + +# +# Table structure for table 'tx_cart_domain_model_order_tax' +# +CREATE TABLE tx_cart_domain_model_order_tax ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + tax double(11,2) DEFAULT '0.00' NOT NULL, + tax_class int(11) unsigned DEFAULT '0' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid) + +); + +# +# Table structure for table 'tx_cart_domain_model_order_product' +# +CREATE TABLE tx_cart_domain_model_order_product ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + item int(11) unsigned DEFAULT '0' NOT NULL, + + sku varchar(255) DEFAULT '' NOT NULL, + title varchar(255) DEFAULT '' NOT NULL, + count int(11) DEFAULT '0' NOT NULL, + price double(11,2) DEFAULT '0.00' NOT NULL, + discount double(11,2) DEFAULT '0.00' NOT NULL, + gross double(11,2) DEFAULT '0.00' NOT NULL, + net double(11,2) DEFAULT '0.00' NOT NULL, + tax double(11,2) DEFAULT '0.00' NOT NULL, + tax_class int(11) unsigned DEFAULT '0' NOT NULL, + + additional_data text NOT NULL, + + product_additional int(11) unsigned DEFAULT '0' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid) + +); + +# +# Table structure for table 'tx_cart_domain_model_order_coupon' +# +CREATE TABLE tx_cart_domain_model_order_coupon ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + item int(11) unsigned DEFAULT '0' NOT NULL, + + title varchar(255) DEFAULT '' NOT NULL, + code varchar(255) DEFAULT '' NOT NULL, + discount double(11,2) DEFAULT '0.00' NOT NULL, + tax_class_id int(11) unsigned DEFAULT '1' NOT NULL, + tax double(11,2) DEFAULT '0.00' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid) + +); + +# +# Table structure for table 'tx_cart_domain_model_order_productadditional' +# +CREATE TABLE tx_cart_domain_model_order_productadditional ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + product int(11) unsigned DEFAULT '0' NOT NULL, + + additional_type varchar(255) DEFAULT '' NOT NULL, + additional_key varchar(255) DEFAULT '' NOT NULL, + additional_value varchar(255) DEFAULT '' NOT NULL, + additional_data varchar(255) DEFAULT '' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid) + +); + + +# +# Table structure for table 'tx_cart_domain_model_order_shipping' +# +CREATE TABLE tx_cart_domain_model_order_shipping ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + name varchar(255) DEFAULT '' NOT NULL, + status varchar(255) DEFAULT '0' NOT NULL, + gross double(11,2) DEFAULT '0.00' NOT NULL, + net double(11,2) DEFAULT '0.00' NOT NULL, + tax double(11,2) DEFAULT '0.00' NOT NULL, + tax_class int(11) unsigned DEFAULT '0' NOT NULL, + + note text NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid) + +); + +# +# Table structure for table 'tx_cart_domain_model_order_payment' +# +CREATE TABLE tx_cart_domain_model_order_payment ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + name varchar(255) DEFAULT '' NOT NULL, + provider varchar(255) DEFAULT '' NOT NULL, + status varchar(255) DEFAULT '0' NOT NULL, + gross double(11,2) DEFAULT '0.00' NOT NULL, + net double(11,2) DEFAULT '0.00' NOT NULL, + tax double(11,2) DEFAULT '0.00' NOT NULL, + tax_class int(11) unsigned DEFAULT '0' NOT NULL, + + note text NOT NULL, + + transactions int(11) unsigned DEFAULT '0' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid) + +); + +# +# Table structure for table 'tx_cart_domain_model_order_transaction' +# +CREATE TABLE tx_cart_domain_model_order_transaction ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + payment int(11) unsigned DEFAULT '0' NOT NULL, + + provider varchar(20) DEFAULT '' NOT NULL, + txn_id varchar(20) DEFAULT '' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + +); + +# +# Table structure for table 'tx_cart_domain_model_product_coupon' +# +CREATE TABLE tx_cart_domain_model_product_coupon ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + title varchar(255) DEFAULT '' NOT NULL, + code varchar(255) DEFAULT '' NOT NULL, + discount double(11,2) DEFAULT '0.00' NOT NULL, + tax_class_id int(11) unsigned DEFAULT '1' NOT NULL, + cart_min_price double(11,2) DEFAULT '0.00' NOT NULL, + is_combinable tinyint(4) unsigned DEFAULT '0' NOT NULL, + is_relative_discount tinyint(4) unsigned DEFAULT '0' NOT NULL, + number_available int(11) DEFAULT '0' NOT NULL, + number_used int(11) DEFAULT '0' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + t3ver_oid int(11) DEFAULT '0' NOT NULL, + t3ver_id int(11) DEFAULT '0' NOT NULL, + t3ver_wsid int(11) DEFAULT '0' NOT NULL, + t3ver_label varchar(255) DEFAULT '' NOT NULL, + t3ver_state tinyint(4) DEFAULT '0' NOT NULL, + t3ver_stage int(11) DEFAULT '0' NOT NULL, + t3ver_count int(11) DEFAULT '0' NOT NULL, + t3ver_tstamp int(11) DEFAULT '0' NOT NULL, + t3ver_move_id int(11) DEFAULT '0' NOT NULL, + + t3_origuid int(11) DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + KEY t3ver_oid (t3ver_oid,t3ver_wsid) + +); + +# +# Table structure for table 'tx_cart_domain_model_cart' +# +CREATE TABLE tx_cart_domain_model_cart ( + + uid int(11) NOT NULL auto_increment, + pid int(11) DEFAULT '0' NOT NULL, + + fe_user int(11) DEFAULT '0' NOT NULL, + + order_item int(11) unsigned DEFAULT '0' NOT NULL, + + cart text NOT NULL, + + was_ordered tinyint(4) unsigned DEFAULT '0' NOT NULL, + + tstamp int(11) unsigned DEFAULT '0' NOT NULL, + crdate int(11) unsigned DEFAULT '0' NOT NULL, + cruser_id int(11) unsigned DEFAULT '0' NOT NULL, + deleted tinyint(4) unsigned DEFAULT '0' NOT NULL, + + PRIMARY KEY (uid), + KEY parent (pid), + +); + +# +# Table structure for table 'tx_cart_domain_model_product_product_related_mm' +# +CREATE TABLE tx_cart_domain_model_product_product_related_mm ( + uid_local int(11) DEFAULT '0' NOT NULL, + uid_foreign int(11) DEFAULT '0' NOT NULL, + sorting int(11) DEFAULT '0' NOT NULL, + sorting_foreign int(11) DEFAULT '0' NOT NULL, + KEY uid_local (uid_local), + KEY uid_foreign (uid_foreign) +); \ No newline at end of file diff --git a/ext_typoscript_constants.txt b/ext_typoscript_constants.txt new file mode 100644 index 00000000..de84e603 --- /dev/null +++ b/ext_typoscript_constants.txt @@ -0,0 +1,21 @@ +plugin.tx_cart { + settings { + cart { + pid = 0 + isNetCart = 0 + } + + order { + pid = 0 + } + + format.currency { + currencySign = € + decimalSeparator = , + thousandsSeparator = . + prependCurrency = 0 + separateCurrency =   + decimals = 2 + } + } +} \ No newline at end of file diff --git a/ext_typoscript_setup.txt b/ext_typoscript_setup.txt new file mode 100644 index 00000000..bce83e83 --- /dev/null +++ b/ext_typoscript_setup.txt @@ -0,0 +1,122 @@ +module.tx_cart { + + view { + templateRootPaths { + 0 = EXT:cart/Resources/Private/Backend/Templates/ + } + partialRootPaths { + 0 = EXT:cart/Resources/Private/Backend/Partials/ + } + layoutRootPaths { + 0 = EXT:cart/Resources/Private/Backend/Layouts/ + } + } + + persistence { + storagePid = {$module.tx_cart.persistence.storagePid} + + classes { + TYPO3\CMS\Extbase\Domain\Model\FrontendUser { + mapping { + tableName = fe_users + recordType = TYPO3\CMS\Extbase\Domain\Model\FrontendUser + columns { + lockToDomain.mapOnProperty = lockToDomain + } + } + } + } + } + + settings { + format.currency { + currencySign = {$plugin.tx_cart.settings.format.currency.currencySign} + decimalSeparator = {$plugin.tx_cart.settings.format.currency.decimalSeparator} + thousandsSeparator = {$plugin.tx_cart.settings.format.currency.thousandsSeparator} + prependCurrency = {$plugin.tx_cart.settings.format.currency.prependCurrency} + separateCurrency = {$plugin.tx_cart.settings.format.currency.separateCurrency} + decimals = {$plugin.tx_cart.settings.format.currency.decimals} + } + } +} + +config.tx_extbase { + persistence { + classes { + Extcode\Cart\Domain\Model\TtContent { + mapping { + tableName = tt_content + columns { + crdate.mapOnProperty = crdate + tstamp.mapOnProperty = tstamp + CType.mapOnProperty = contentType + header.mapOnProperty = header + header_position.mapOnProperty = headerPosition + bodytext.mapOnProperty = bodytext + image.mapOnProperty = image + imagewidth.mapOnProperty = imagewidth + imageorient.mapOnProperty = imageorient + imagecaption.mapOnProperty = imagecaption + imagecols.mapOnProperty = imagecols + imageborder.mapOnProperty = imageborder + media.mapOnProperty = media + layout.mapOnProperty = layout + cols.mapOnProperty = cols + records.mapOnProperty = records + pages.mapOnProperty = pages + starttime.mapOnProperty = starttime + endtime.mapOnProperty = endtime + colPos.mapOnProperty = colPos + subheader.mapOnProperty = subheader + spaceBefore.mapOnProperty = spaceBefore + spaceAfter.mapOnProperty = spaceAfter + fe_group.mapOnProperty = feGroup + header_link.mapOnProperty = headerLink + imagecaption_position.mapOnProperty = imagecaptionPosition + image_link.mapOnProperty = imageLink + image_zoom.mapOnProperty = imageZoom + image_noRows.mapOnProperty = imageNoRows + image_effects.mapOnProperty = imageEffects + image_compression.mapOnProperty = imageCompression + altText.mapOnProperty = altText + titleText.mapOnProperty = titleText + longdescURL.mapOnProperty = longdescUrl + header_layout.mapOnProperty = headerLayout + menu_type.mapOnProperty = menuType + list_type.mapOnProperty = listType + table_border.mapOnProperty = tableBorder + table_cellspacing.mapOnProperty = tableCellspacing + table_cellpadding.mapOnProperty = tableCellpadding + table_bgColor.mapOnProperty = tableBgColor + select_key.mapOnProperty = selectKey + sectionIndex.mapOnProperty = sectionIndex + linkToTop.mapOnProperty = linkToTop + file_collections.mapOnProperty = fileCollections + filelink_size.mapOnProperty = filelinkSize + filelink_sorting.mapOnProperty = filelinkSorting + target.mapOnProperty = target + section_frame.mapOnProperty = sectionFrame + date.mapOnProperty = date + multimedia.mapOnProperty = multimedia + image_frames.mapOnProperty = imageFrames + recursive.mapOnProperty = recursive + imageheight.mapOnProperty = imageheight + rte_enabled.mapOnProperty = rteEnabled + sys_language_uid.mapOnProperty = sysLanguageUid + tx_impexp_origuid.mapOnProperty = txImpexpOriguid + pi_flexform.mapOnProperty = piFlexform + accessibility_title.mapOnProperty = accessibilityTitle + accessibility_bypass.mapOnProperty = accessibilityBypass + accessibility_bypass_text.mapOnProperty = accessibilityBypassText + selected_categories.mapOnProperty = selectedCategories + category_field.mapOnProperty = categoryField + tx_gridelements_backend_layout.mapOnProperty = txGridelementsBackendLayout + tx_gridelements_children.mapOnProperty = txGridelementsChildren + tx_gridelements_container.mapOnProperty = txGridelementsContainer + tx_gridelements_columns.mapOnProperty = txGridelementsColumns + } + } + } + } + } +} \ No newline at end of file