Exemple #1
0
 /**
  * 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 = [];
     $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);
 }
Exemple #2
0
 /**
  * @test
  */
 public function setCurrencySetsCurrency()
 {
     $this->item->setCurrency('$');
     $this->assertSame('$', $this->item->getCurrency());
 }
Exemple #3
0
 /**
  * Add Shipping
  *
  * @return void
  */
 protected function addShipping()
 {
     $shipping = $this->cart->getShipping();
     /**
      * Order Shipping
      * @var $orderShipping \Extcode\Cart\Domain\Model\Order\Shipping
      */
     $orderShipping = $this->objectManager->get('Extcode\\Cart\\Domain\\Model\\Order\\Shipping');
     $orderShipping->setPid($this->storagePid);
     $orderShipping->setServiceId($shipping->getId());
     $orderShipping->setName($shipping->getName());
     $orderShipping->setStatus($shipping->getStatus());
     $orderShipping->setGross($shipping->getGross());
     $orderShipping->setNet($shipping->getNet());
     $orderShipping->setTaxClass($this->taxClasses[$shipping->getTaxClass()->getId()]);
     $orderShipping->setTax($shipping->getTax());
     $orderShipping->setNote($shipping->getNote());
     $this->shippingRepository->add($orderShipping);
     $this->orderItem->setShipping($orderShipping);
 }
Exemple #4
0
 /**
  * Action order Cart
  *
  * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem
  * @param \Extcode\Cart\Domain\Model\Order\Address $billingAddress
  * @param \Extcode\Cart\Domain\Model\Order\Address $shippingAddress
  *
  * @ignorevalidation $shippingAddress
  *
  * @return void
  */
 public function orderCartAction(\Extcode\Cart\Domain\Model\Order\Item $orderItem = null, \Extcode\Cart\Domain\Model\Order\Address $billingAddress = null, \Extcode\Cart\Domain\Model\Order\Address $shippingAddress = null)
 {
     if ($orderItem == null || $billingAddress == null) {
         $this->redirect('showCart');
     }
     $this->cart = $this->cartUtility->getCartFromSession($this->settings['cart'], $this->pluginSettings);
     if ($this->cart->getCount() == 0) {
         $this->redirect('showCart');
     }
     $this->parseData();
     $this->orderUtility->checkStock($this->cart);
     $orderItem->setCartPid(intval($GLOBALS['TSFE']->id));
     if ($this->request->hasArgument('shipping_same_as_billing')) {
         $isShippingAddressSameAsBilling = $this->request->getArgument('shipping_same_as_billing');
         if ($isShippingAddressSameAsBilling == 'true') {
             $shippingAddress = null;
             $orderItem->removeShippingAddress();
         }
     }
     $this->orderUtility->saveOrderItem($this->pluginSettings, $this->cart, $orderItem, $billingAddress, $shippingAddress);
     $this->orderUtility->handleStock($this->cart);
     $this->orderUtility->handlePayment($orderItem, $this->cart);
     $this->orderUtility->autoGenerateDocuments($orderItem, $this->pluginSettings);
     $this->sendMails($orderItem, $billingAddress, $shippingAddress);
     $this->view->assign('cart', $this->cart);
     $this->view->assign('orderItem', $orderItem);
     $paymentId = $this->cart->getPayment()->getId();
     if (intval($this->pluginSettings['payments']['options'][$paymentId]['preventClearCart']) != 1) {
         $this->cart = $this->cartUtility->getNewCart($this->settings['cart'], $this->pluginSettings);
     }
     $this->sessionHandler->writeToSession($this->cart, $this->settings['cart']['pid']);
 }
Exemple #5
0
 /**
  * Send Mails
  *
  * @param \Extcode\Cart\Domain\Model\Order\Item $orderItem
  * @paran string $type
  * @param string $class
  * @param string $function
  *
  * @return void
  */
 protected function sendMails(\Extcode\Cart\Domain\Model\Order\Item $orderItem, $type, $class, $function)
 {
     $billingAddress = $orderItem->getBillingAddress()->_loadRealInstance();
     $shippingAddress = null;
     if ($orderItem->getShippingAddress()) {
         $shippingAddress = $orderItem->getShippingAddress()->_loadRealInstance();
     }
     $data = ['orderItem' => $orderItem, 'cart' => $this->cart, 'billingAddress' => $billingAddress, 'shippingAddress' => $shippingAddress];
     $signalSlotDispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
     $signalSlotDispatcher->dispatch($class, $function . 'AfterUpdatePaymentAndBefore' . ucfirst($type) . 'Mail', $data);
     $paymentId = $orderItem->getPayment()->getServiceId();
     $paymentStatus = $orderItem->getPayment()->getStatus();
     if (intval($this->pluginSettings['payments']['options'][$paymentId]['sendBuyerEmail'][$paymentStatus]) == 1) {
         $this->sendBuyerMail($orderItem, $billingAddress, $shippingAddress);
     }
     if (intval($this->pluginSettings['payments']['options'][$paymentId]['sendSellerEmail'][$paymentStatus]) == 1) {
         $this->sendSellerMail($orderItem, $billingAddress, $shippingAddress);
     }
     $signalSlotDispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
     $signalSlotDispatcher->dispatch($class, $function . 'AfterUpdatePaymentAndAfter' . ucfirst($type) . 'Mail', $data);
 }
Exemple #6
0
 /**
  * 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;
     }
     $status = $orderItem->getPayment()->getStatus();
     $view = $this->getEmailStandaloneView('/Mail/' . ucfirst($status) . '/', 'Seller', 'html');
     if ($view->getTemplatePathAndFilename()) {
         $view->assign('settings', $this->pluginSettings['settings']);
         $view->assign('cart', $this->cart);
         $view->assign('orderItem', $orderItem);
         $view->assign('billingAddress', $billingAddress);
         $view->assign('shippingAddress', $shippingAddress);
         $mailToAddresses = explode(',', $this->sellerEmailTo);
         $mailBody = $view->render();
         $mail = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
         $mail->setFrom($this->sellerEmailFrom);
         $mail->setTo($mailToAddresses);
         $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');
         // get and add attachments
         $attachments = $this->getAttachments($orderItem, 'seller');
         foreach ($attachments as $attachment) {
             $attachmentFile = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($attachment);
             if (file_exists($attachmentFile)) {
                 $mail->attach(\Swift_Attachment::fromPath($attachmentFile));
             }
         }
         $mail->send();
     }
 }