Example #1
0
 /**
  * @param Order $order
  * @return void
  */
 protected function prepareTemplate(Order $order)
 {
     $this->templateContainer->setTemplateOptions($this->getTemplateOptions());
     if ($order->getCustomerIsGuest()) {
         $templateId = $this->identityContainer->getGuestTemplateId();
         $customerName = $order->getBillingAddress()->getName();
     } else {
         $templateId = $this->identityContainer->getTemplateId();
         $customerName = $order->getCustomerName();
     }
     $this->identityContainer->setCustomerName($customerName);
     $this->identityContainer->setCustomerEmail($order->getCustomerEmail());
     $this->templateContainer->setTemplateId($templateId);
 }
Example #2
0
 public function informCustomer(\Magento\Sales\Model\Order $order, $amount, $currency)
 {
     try {
         if (!($order_increment_id = $order->getRealOrderId()) or !($method_config = $this->_s2pModel->getFullConfigArray())) {
             return false;
         }
         $siteUrl = $order->getStore()->getBaseUrl();
         $siteName = $this->_helper->getStoreName();
         $supportEmail = $this->_helper->getStoreConfig('trans_email/ident_support/email');
         $supportName = $this->_helper->getStoreConfig('trans_email/ident_support/name');
         $payment_details_arr['site_url'] = $siteUrl;
         $payment_details_arr['order_increment_id'] = $order_increment_id;
         $payment_details_arr['site_name'] = $siteName;
         $payment_details_arr['customer_name'] = $order->getCustomerName();
         $payment_details_arr['order_date'] = $order->getCreatedAtFormatted(\IntlDateFormatter::LONG);
         $payment_details_arr['support_email'] = $supportEmail;
         $payment_details_arr['total_paid'] = number_format($amount / 100, 2);
         $payment_details_arr['currency'] = $currency;
         $transport = $this->_transportBuilder->setTemplateIdentifier($method_config['smart2pay_email_payment_confirmation'])->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_ADMINHTML, 'store' => $order->getStore()->getId()])->setTemplateVars($payment_details_arr)->setFrom(['name' => $supportName, 'email' => $supportEmail])->addTo($order->getCustomerEmail())->getTransport();
         $transport->sendMessage();
     } catch (\Magento\Framework\Exception\MailException $e) {
         $this->_s2pLogger->write('Error sending customer informational email to [' . $order->getCustomerEmail() . ']', 'email_template');
         $this->_s2pLogger->write($e->getMessage(), 'email_exception');
     } catch (\Exception $e) {
         $this->_s2pLogger->write($e->getMessage(), 'exception');
     }
     return true;
 }