Example #1
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);
 }
Example #2
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();
     }
 }