提交 facd559d 编写于 作者: R root

新订单(游客和登录用户两种)发送邮件部分

上级 af30ab60
......@@ -54,11 +54,11 @@ return [
*/
//'authTimeout' => 56666,
],
# 404页面对应的链接。
'errorHandler' => [
'errorAction' => 'site/helper/error',
],
# 首页对应的url
'urlManager' => [
'rules' => [
'' => 'cms/home/index',
......
......@@ -48,6 +48,11 @@ class Placeorder{
# 将购物车数据,生成订单。
$genarateStatus = Yii::$service->order->generateOrderByCart($this->_billing,$this->_shipping_method,$this->_payment_method);
if($genarateStatus){
# 得到当前的订单信息
$orderInfo = Yii::$service->order->getCurrentOrderInfo();
# 发送新订单邮件
Yii::$service->email->order->sendCreateEmail($orderInfo);
# 得到支付跳转前的准备页面。
$startUrl = Yii::$service->payment->getStandardStartUrl();
Yii::$service->url->redirect($startUrl);
exit;
......
......@@ -10,18 +10,16 @@ return [
'class' => 'fecshop\services\Email',
/*
/**
* 下面为配置邮箱的smtp部分,你可以配置多个smtp,
* 在具体的邮件使用中,选择下面的数组的相应的key即可。
'mailerConfig' => [
# 默认通用配置
'default' => [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.qq.com',
//'username' => '2358269014@qq.com',
//'password' => 'bjxpkyzfwkxnebai',
'username' => '372716335@qq.com',
'password' => 'wffmbummgnhhcbbj',
......@@ -36,49 +34,49 @@ return [
'login' => [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.qq.com',
//'username' => '2358269014@qq.com',
//'password' => 'bjxpkyzfwkxnebai',
'username' => '372716335@qq.com',
'password' => 'wffmbummgnhhcbbj',
'port' => '587',
'encryption' => 'tls',
],
'messageConfig'=>[
'charset'=>'UTF-8',
],
],
],
*/
# 公用配置
'mailerInfo' => [
#在邮件中显示的Store的名字
'storeName' => 'FecShop',
# 在邮件中显示的电话
'phone' => 'xxxxxxxxxx',
# 在邮件中显示的联系邮箱地址。
'contacts' => [
'emailAddress' => '2358269014@qq.com',
],
],
'childService' => [
/**
* 用户中心部分的邮件的设置。
*/
'customer' => [
'class' => 'fecshop\services\email\Customer',
# 公用配置
'mailer' => [
#在邮件中显示的Store的名字
'storeName' => 'FecShop',
# 在邮件中显示的电话
'phone' => 'xxxxxxxxxx',
# 在邮件中显示的联系邮箱地址。
'contacts' => [
'emailAddress' => '2358269014@qq.com',
],
# 通过邮箱找回密码,发送的resetToken过期的秒数
'user.passwordResetTokenExpire' => 3600*24*1, # 一天
],
# 各个邮件的模板部分:
'emailTheme' => [
# 注册账户发送的邮件的模板配置
'register' => [
'enable' => true,
# 邮件内容的动态数据提供部分
......@@ -107,7 +105,7 @@ return [
*/
'mailerConfig' => 'default',
],
# 登录用户发送邮件的模板的设置。
'login' => [
'enable' => true,
# 邮件内容的动态数据提供部分
......@@ -117,17 +115,19 @@ return [
# 如果不定义 mailerConfig,则会使用email service里面的默认配置
'mailerConfig' => 'default',
],
# 忘记密码发送邮件的模板的设置
'forgotPassword' => [
'enable' => true,
'widget' => 'fecshop\services\email\widgets\customer\account\forgotpassword\Body',
# 邮件内容的view部分
'viewPath' => '@fecshop/services/email/views/customer/account/forgotpassword',
#忘记密码邮件发送后的超时时间。
'passwordResetTokenExpire' => 86400, # 3600*24*1, # 一天
# 如果不定义 mailerConfig,则会使用email service里面的默认配置
# 通过邮箱找回密码,发送的resetToken过期的秒数
'mailerConfig' => 'default',
],
# 联系我们发送的邮件模板
'contacts' => [
'enable' => true,
# 联系我们的邮箱地址
......@@ -140,8 +140,7 @@ return [
# 如果不定义 mailerConfig,则会使用email service里面的默认配置
//'mailerConfig' => 'default',
],
# 订阅newsletter后发送的邮件模板。
'newsletter' => [
# 订阅邮件成功后,是否发送邮件给用户
'enable' => true,
......@@ -154,6 +153,53 @@ return [
],
],
],
'order' => [
'class' => 'fecshop\services\email\Order',
# 各个邮件的模板部分:
'emailTheme' => [
# 游客发送的邮件的模板配置
'guestCreate' => [
'enable' => true,
# 邮件内容的动态数据提供部分
'widget' => 'fecshop\services\email\widgets\order\create\Body',
# 邮件内容的view部分
'viewPath' => '@fecshop/services/email/views/order/create/guest',
/**
* 1.默认是default,譬如下面的 'mailerConfig' => 'default',你可以不填写,因为默认就是default
* 2.您可以使用上面email服务的配置项mailerConfig中的设置的各个项,譬如填写default 或者 login等。
* 3.您还可以直接填写数组的配置(完整配置),譬如:
* 'register' => [
* 'class' => 'yii\swiftmailer\Mailer',
* 'transport' => [
* 'class' => 'Swift_SmtpTransport',
* 'host' => 'smtp.qq.com',
* 'username' => '372716335@qq.com',
* 'password' => 'wffmbummgnhhcbbj',
* 'port' => '587',
* 'encryption' => 'tls',
* ],
* 'messageConfig'=>[
* 'charset'=>'UTF-8',
* ],
*
* ],
*/
'mailerConfig' => 'default',
],
# 登录用户发送邮件的模板的设置。
'loginedCreate' => [
'enable' => true,
# 邮件内容的动态数据提供部分
'widget' => 'fecshop\services\email\widgets\order\create\Body',
# 邮件内容的view部分
'viewPath' => '@fecshop/services/email/views/order/create/logined',
# 如果不定义 mailerConfig,则会使用email service里面的默认配置
'mailerConfig' => 'default',
],
],
],
],
],
......
......@@ -50,7 +50,7 @@ class Customer extends ActiveRecord implements IdentityInterface
/**
* @inheritdoc
*/
# 通过id 找到identity
# 通过id 找到identity
public static function findIdentity($id)
{
return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]);
......@@ -59,12 +59,12 @@ class Customer extends ActiveRecord implements IdentityInterface
/**
* @inheritdoc
*/
# 通过access_token 找到identity
# 通过access_token 找到identity
public static function findIdentityByAccessToken($token, $type = null)
{
return static::findOne(['access_token' => $token, 'status' => self::STATUS_ACTIVE]);
}
# 生成access_token
# 生成access_token
public function generateAccessToken()
{
$this->access_token = Yii::$app->security->generateRandomString();
......@@ -87,7 +87,7 @@ class Customer extends ActiveRecord implements IdentityInterface
* @param string $token password reset token
* @return static|null
*/
# 此处是忘记密码所使用的
# 此处是忘记密码所使用的
public static function findByPasswordResetToken($token)
{
if (!static::isPasswordResetTokenValid($token)) {
......@@ -111,10 +111,10 @@ class Customer extends ActiveRecord implements IdentityInterface
if (empty($token)) {
return false;
}
$timestamp = (int) substr($token, strrpos($token, '_') + 1);
$expire = Yii::$app->params['user.passwordResetTokenExpire'];
return $timestamp + $expire >= time();
//$expire = Yii::$app->params['user.passwordResetTokenExpire'];
$expire = Yii::$service->email->customer->getPasswordResetTokenExpire();
return $timestamp + $expire >= time();
}
/**
......
......@@ -19,6 +19,7 @@ class Email extends Service
{
public $mailerConfig;
public $defaultForm;
public $mailerInfo;
/**
* 邮件模板部分动态数据提供类的返回数据的函数名字,使用默认值即可。
*/
......@@ -29,19 +30,37 @@ class Email extends Service
protected $_from;
/**
* @property $email_address | String 邮箱地址字符串
* @return boolean 如果格式正确,返回true
* 在邮箱中显示的 邮箱地址
*/
protected function actionValidateFormat($email_address){
if(preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^",$email_address)){
return true;
}else{
return false;
public function contactsEmailAddress(){
$mailerInfo = $this->mailerInfo;
if(isset($mailerInfo['contacts']['emailAddress'])){
return $mailerInfo['contacts']['emailAddress'];
}
}
/**
* 在邮箱中显示的 商城名字(Store Name)
*/
public function storeName(){
$mailerInfo = $this->mailerInfo;
if(isset($mailerInfo['storeName'])){
return $mailerInfo['storeName'];
}
}
/**
* 在邮件中显示的 联系手机号
* Yii::$service->email->customer->contactsPhone();
*/
public function contactsPhone(){
$mailerInfo = $this->mailerInfo;
if(isset($mailerInfo['phone'])){
return $mailerInfo['phone'];
}
}
/**
* 得到MailConfig
*/
......@@ -63,7 +82,6 @@ class Email extends Service
if(!empty($mailerConfig['transport']['username'])){
return $mailerConfig['transport']['username'];
}
}
return ;
}
......@@ -276,4 +294,17 @@ class Email extends Service
}
}
/**
* @property $email_address | String 邮箱地址字符串
* @return boolean 如果格式正确,返回true
*/
protected function actionValidateFormat($email_address){
if(preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$^",$email_address)){
return true;
}else{
return false;
}
}
}
......@@ -36,6 +36,7 @@ class Order extends Service
public $orderCountThatReturnPendingStock = 30;
protected $checkout_type;
protected $_currentOrderInfo;
const CHECKOUT_TYPE_STANDARD = 'standard';
const CHECKOUT_TYPE_EXPRESS = 'express';
const CURRENT_ORDER_CREAMENT_ID = 'current_order_creament_id';
......@@ -87,7 +88,49 @@ class Order extends Service
return new MyOrder;
}
}
/**
* 通过从session中取出来订单的increment_id
* 在通过increment_id(订单编号)取出来订单信息。
*/
protected function actionGetCurrentOrderInfo(){
if(!$this->_currentOrderInfo){
$increment_id = Yii::$service->order->getSessionIncrementId();
$this->_currentOrderInfo = Yii::$service->order->getOrderInfoByIncrementId($increment_id);
}
return $this->_currentOrderInfo;
}
/**
* @property $increment_id | String 订单编号
* @return Array
* 通过order_id 从数据库中取出来订单数据,然后在进行了二次处理后的订单数据。
*/
protected function actionGetOrderInfoByIncrementId($increment_id){
$one = $this->getByIncrementId($increment_id);
if(!$one){
return ;
}
$primaryKey = $this->getPrimaryKey();
if(!isset($one[$primaryKey]) || empty($one[$primaryKey])){
return ;
}
$order_info = [];
foreach($one as $k=>$v){
$order_info[$k] = $v;
}
$order_info['customer_address_state_name'] =Yii::$service->helper->country->getStateByContryCode($order_info['customer_address_country'],$order_info['customer_address_state']);
$order_info['customer_address_country_name'] = Yii::$service->helper->country->getCountryNameByKey($order_info['customer_address_country']);
$order_info['currency_symbol'] = Yii::$service->page->currency->getSymbol($order_info['order_currency_code']);
$order_info['products'] = Yii::$service->order->item->getByOrderId($one[$primaryKey]);
return $order_info;
}
/**
* @property $order_id | Int
* @return Array
* 通过order_id 从数据库中取出来订单数据,然后在进行了二次处理后的订单数据。
*/
protected function actionGetOrderInfoById($order_id){
if(!$order_id){
return ;
......@@ -272,6 +315,11 @@ class Order extends Service
$state = $address['state'];
//echo "$shipping_method,$country,$state";exit;
$cartInfo = Yii::$service->cart->getCartInfo($shipping_method,$country,$state);
# 检查cartInfo中是否存在产品
if(!is_array($cartInfo) && empty($cartInfo)){
Yii::$service->helper->errors->add('current cart product is empty');
return false;
}
# 检查产品是否有库存,如果没有库存则返回false
$deductStatus = Yii::$service->product->stock->checkItemsStock($cartInfo['products']);
if(!$deductStatus){
......
......@@ -17,43 +17,13 @@ use yii\base\InvalidValueException;
*/
class Customer
{
/**
* 公用配置部分配置
*/
public $mailer;
/**
* 邮件模板部分配置
*/
public $emailTheme;
/**
* 得到联系我们的邮箱地址
*/
public function contactsEmailAddress(){
$mailerConfig = $this->mailer;
if(isset($mailerConfig['contacts']['emailAddress'])){
return $mailerConfig['contacts']['emailAddress'];
}
}
/**
* 得到Store Name
*/
public function storeName(){
$mailerConfig = $this->mailer;
if(isset($mailerConfig['storeName'])){
return $mailerConfig['storeName'];
}
}
/**
* 得到联系的手机
* Yii::$service->email->customer->contactsPhone();
*/
public function contactsPhone(){
$mailerConfig = $this->mailer;
if(isset($mailerConfig['phone'])){
return $mailerConfig['phone'];
}
}
/**
* @property $toEmail | String send to email address.
......@@ -152,6 +122,15 @@ class Customer
}
}
}
/**
* 超时时间:忘记密码发送邮件,内容中的修改密码链接的超时时间。
*/
public function getPasswordResetTokenExpire(){
$forgotPasswordInfo = $this->emailTheme['forgotPassword'];
if(isset($forgotPasswordInfo['passwordResetTokenExpire']) && $forgotPasswordInfo['passwordResetTokenExpire']){
return $forgotPasswordInfo['passwordResetTokenExpire'];
}
}
/**
* @property $emailInfo | Array , 数组
......
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\services\email;
use Yii;
use fec\helpers\CConfig;
use fec\controllers\FecController;
use yii\base\InvalidValueException;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Order
{
/**
* 邮件模板部分配置
*/
public $emailTheme;
/**
* @property $toEmail | String send to email address.
* 新订单邮件
*
*/
public function sendCreateEmail($orderInfo){
$toEmail = $orderInfo['customer_email'];
if(Yii::$app->user->isGuest){
$emailThemeInfo = $this->emailTheme['guestCreate'];
}else{
$emailThemeInfo = $this->emailTheme['loginedCreate'];
}
if(isset($emailThemeInfo['enable']) && $emailThemeInfo['enable']){
$mailerConfigParam = '';
if(isset($emailThemeInfo['mailerConfig']) && $emailThemeInfo['mailerConfig']){
$mailerConfigParam = $emailThemeInfo['mailerConfig'];
}
if(isset($emailThemeInfo['widget']) && $emailThemeInfo['widget']){
$widget = $emailThemeInfo['widget'];
}
if(isset($emailThemeInfo['viewPath']) && $emailThemeInfo['viewPath']){
$viewPath = $emailThemeInfo['viewPath'];
}
if($widget && $viewPath){
list($subject,$htmlBody) = Yii::$service->email->getSubjectAndBody($widget,$viewPath,'',$orderInfo);
$sendInfo = [
'to' => $toEmail,
'subject' => $subject,
'htmlBody' => $htmlBody,
'senderName'=> Yii::$service->store->currentStore,
];
//var_dump($sendInfo);exit;
Yii::$service->email->send($sendInfo,$mailerConfigParam);
return true;
}
}
}
}
<?php
use fecshop\app\appfront\helper\Format;
?>
<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td align="center" valign="top" style="padding:20px 0 20px 0">
<table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
<!-- [ header starts here] -->
<tr>
<td valign="top">
<a href="<?= $homeUrl; ?>">
<img src="<?= $logoImg; ?>" alt="" style="margin:10px 0 ;" border="0"/>
</a>
</td>
</tr>
<!-- [ middle starts here] -->
<tr>
<td valign="top">
<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;">
Hello, <?= $name; ?></h1>
<p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
Thank you for your order from <?= $storeName; ?>.
Once your package ships we will send an email with a link to track your order.
If you have any questions about your order please contact us at <a href="mailto:<?= $contactsEmailAddress ?>" style="color:#1E7EC8;"><?= $contactsEmailAddress ?></a> or call us at <span class="nobr"><?= $contactsPhone; ?></span> Monday - Friday, 8am - 5pm PST.
</p>
<p style="font-size:12px; line-height:16px; margin:0;">Your order confirmation is below. Thank you again for your business.</p>
</td>
</tr>
<tr>
<td>
<h2 style="font-size:18px; font-weight:normal; margin:0;">Your Order #<?= $order['increment_id'] ?> <small>(placed on <?= $order['created_at'] ?>)</small></h2>
</td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="0" border="0" width="650">
<thead>
<tr>
<th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Billing Information:</th>
<th width="10"></th>
<th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Payment Method:</th>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" style="padding:7px 9px 9px;font-size:12px;border-right-color:rgb(234,234,234);border-bottom-color:rgb(234,234,234);border-left-color:rgb(234,234,234);border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-style:solid;border-bottom-style:solid;border-left-style:solid">
<?= $name ?><br>
<?= $order['customer_address_street1']." ".$order['customer_address_street2']?><br>
<?= $order['customer_address_city']; ?>, <?= $stateName; ?>, <span data="36137" onclick="return false;" t="7" style="border-bottom:1px dashed #ccc;z-index:1"><?= $order['customer_address_zip']; ?></span><br>
<?= $countryName; ?><br>
T: <span data="<?= $order['customer_telephone']; ?>" onclick="return false;" t="7" style="border-bottom:1px dashed #ccc;z-index:1"><?= $order['customer_telephone']; ?></span>
</td>
<td>&nbsp;</td>
<td valign="top" style="padding:7px 9px 9px;font-size:12px;border-right-color:rgb(234,234,234);border-bottom-color:rgb(234,234,234);border-left-color:rgb(234,234,234);border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-style:solid;border-bottom-style:solid;border-left-style:solid">
<p><b>PayPal - <?= $order['payment_method']; ?></b></p>
</td>
</tr>
</tbody>
</table>
<br/>
<table cellspacing="0" cellpadding="0" border="0" width="650">
<thead>
<tr>
<th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Shipping Information:</th>
<th width="10"></th>
<th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Shipping Method:</th>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
<?= $name ?><br>
<?= $order['customer_address_street1']." ".$order['customer_address_street2']?><br>
<?= $order['customer_address_city']; ?>, <?= $stateName; ?>, <span data="36137" onclick="return false;" t="7" style="border-bottom:1px dashed #ccc;z-index:1"><?= $order['customer_address_zip']; ?></span><br>
<?= $countryName; ?><br>
T: <span data="<?= $order['customer_telephone']; ?>" onclick="return false;" t="7" style="border-bottom:1px dashed #ccc;z-index:1"><?= $order['customer_telephone']; ?></span>
</td>
<td>&nbsp;</td>
<td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
<?= $order['shipping_method']; ?>
&nbsp;
</td>
</tr>
</tbody>
</table>
<br/>
<table width="650" cellspacing="0" cellpadding="0" border="0" style="border:1px solid rgb(234,234,234)">
<thead>
<tr>
<th bgcolor="#eaeaea" align="left" style="padding:3px 9px;font-size:13px">Image</th>
<th bgcolor="#eaeaea" align="left" style="padding:3px 9px;font-size:13px">Name</th>
<th bgcolor="#eaeaea" align="left" style="padding:3px 9px;font-size:13px">Sku</th>
<th bgcolor="#eaeaea" align="center" style="padding:3px 9px;font-size:13px">Qty</th>
<th bgcolor="#eaeaea" align="right" style="padding:3px 9px;font-size:13px">SubTotal</th>
</tr>
</thead>
<?php if(is_array($order['products']) && !empty($order['products'])){ ?>
<?php foreach($order['products'] as $product){ ?>
<tbody>
<tr>
<td valign="top" align="left" style="padding:3px 9px;font-size:11px;border-bottom-color:rgb(204,204,204);border-bottom-width:1px;border-bottom-style:dotted">
<a href="<?= Yii::$service->url->getUrl($product['redirect_url']) ; ?>">
<img src="<?= Yii::$service->product->image->getResize($product['image'],[100,100],false) ?>" alt="<?= $product['name'] ?>" width="75" height="75">
</a>
</td>
<td valign="top" align="left" style="padding:3px 9px;font-size:11px;border-bottom-color:rgb(204,204,204);border-bottom-width:1px;border-bottom-style:dotted">
<b style="font-size:11px">
<?= $product['name'] ?></b>
<?php if(is_array($product['custom_option_info'])){ ?>
<ul>
<?php foreach($product['custom_option_info'] as $label => $val){ ?>
<li><?= Yii::$service->page->translate->__($label.':') ?><?= Yii::$service->page->translate->__($val) ?> </li>
<?php } ?>
</ul>
<?php } ?>
</td>
<td valign="top" align="left" style="padding:3px 9px;font-size:11px;border-bottom-color:rgb(204,204,204);border-bottom-width:1px;border-bottom-style:dotted"><?= $product['sku'] ?></td>
<td valign="top" align="center" style="padding:3px 9px;font-size:11px;border-bottom-color:rgb(204,204,204);border-bottom-width:1px;border-bottom-style:dotted"><?= $product['qty'] ?></td>
<td valign="top" align="right" style="padding:3px 9px;font-size:11px;border-bottom-color:rgb(204,204,204);border-bottom-width:1px;border-bottom-style:dotted"><span><?= $order['currency_symbol'] ?><?= Format::price($product['row_total']); ?></span></td>
</tr>
</tbody>
<?php } } ?>
<tbody>
<tr>
<td align="right" style="padding:3px 9px" colspan="4">Subtotal</td>
<td align="right" style="padding:3px 9px"><span><?= $order['currency_symbol'] ?><?= Format::price($order['subtotal']); ?></span></td>
</tr>
<tr>
<td align="right" style="padding:3px 9px" colspan="4">Shipping &amp; handling </td>
<td align="right" style="padding:3px 9px"><span><?= $order['currency_symbol'] ?><?= Format::price($order['shipping_total']); ?></span></td>
</tr>
<tr>
<td align="right" style="padding:3px 9px" colspan="4">Discount </td>
<td align="right" style="padding:3px 9px"><span><?= $order['currency_symbol'] ?><?= Format::price($order['subtotal_with_discount']); ?></span></td>
</tr>
<tr>
<td align="right" style="padding:3px 9px" colspan="4"><b>Total</b></td>
<td align="right" style="padding:3px 9px"><b><span><?= $order['currency_symbol'] ?><?= Format::price($order['grand_total']); ?></span></b></td>
</tr>
</tbody>
</table>
<p style="font-size:12px; margin:0 0 10px 0"></p>
</td>
</tr>
<tr>
<td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you, <strong><?= $storeName; ?></strong></p></center></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
<?= $storeName ?> New Order # <?= $order['increment_id'] ?>
\ No newline at end of file
<?php
use fecshop\app\appfront\helper\Format;
?>
<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td align="center" valign="top" style="padding:20px 0 20px 0">
<table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
<!-- [ header starts here] -->
<tr>
<td valign="top">
<a href="<?= $homeUrl; ?>">
<img src="<?= $logoImg; ?>" alt="" style="margin:10px 0 ;" border="0"/>
</a>
</td>
</tr>
<!-- [ middle starts here] -->
<tr>
<td valign="top">
<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Hello, <?= $name; ?></h1>
<p style="font-size:12px; line-height:16px; margin:0;">
Thank you for your order from <?= $storeName; ?>.
Once your package ships we will send an email with a link to track your order.
You can check the status of your order by <a href="<?= Yii::$service->url->getUrl("customer/account"); ?>" style="color:#1E7EC8;">logging into your account</a>.
If you have any questions about your order please contact us at <a href="mailto:<?= $contactsEmailAddress ?>" style="color:#1E7EC8;"><?= $contactsEmailAddress ?></a> or call us at <span class="nobr"><?= $contactsPhone; ?></span> Monday - Friday, 8am - 5pm PST.
</p>
<p style="font-size:12px; line-height:16px; margin:0;">Your order confirmation is below. Thank you again for your business.</p>
</td>
</tr>
<tr>
<td>
<h2 style="font-size:18px; font-weight:normal; margin:0;">Your Order #<?= $order['increment_id'] ?> <small>(placed on <?= $order['created_at'] ?>)</small></h2>
</td>
</tr>
<tr>
<td>
<table cellspacing="0" cellpadding="0" border="0" width="650">
<thead>
<tr>
<th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Billing Information:</th>
<th width="10"></th>
<th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Payment Method:</th>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" style="padding:7px 9px 9px;font-size:12px;border-right-color:rgb(234,234,234);border-bottom-color:rgb(234,234,234);border-left-color:rgb(234,234,234);border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-style:solid;border-bottom-style:solid;border-left-style:solid">
<?= $name ?><br>
<?= $order['customer_address_street1']." ".$order['customer_address_street2']?><br>
<?= $order['customer_address_city']; ?>, <?= $stateName; ?>, <span data="36137" onclick="return false;" t="7" style="border-bottom:1px dashed #ccc;z-index:1"><?= $order['customer_address_zip']; ?></span><br>
<?= $countryName; ?><br>
T: <span data="<?= $order['customer_telephone']; ?>" onclick="return false;" t="7" style="border-bottom:1px dashed #ccc;z-index:1"><?= $order['customer_telephone']; ?></span>
</td>
<td>&nbsp;</td>
<td valign="top" style="padding:7px 9px 9px;font-size:12px;border-right-color:rgb(234,234,234);border-bottom-color:rgb(234,234,234);border-left-color:rgb(234,234,234);border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-style:solid;border-bottom-style:solid;border-left-style:solid">
<p><b>PayPal - <?= $order['payment_method']; ?></b></p>
</td>
</tr>
</tbody>
</table>
<br/>
<table cellspacing="0" cellpadding="0" border="0" width="650">
<thead>
<tr>
<th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Shipping Information:</th>
<th width="10"></th>
<th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Shipping Method:</th>
</tr>
</thead>
<tbody>
<tr>
<td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
<?= $name ?><br>
<?= $order['customer_address_street1']." ".$order['customer_address_street2']?><br>
<?= $order['customer_address_city']; ?>, <?= $stateName; ?>, <span data="36137" onclick="return false;" t="7" style="border-bottom:1px dashed #ccc;z-index:1"><?= $order['customer_address_zip']; ?></span><br>
<?= $countryName; ?><br>
T: <span data="<?= $order['customer_telephone']; ?>" onclick="return false;" t="7" style="border-bottom:1px dashed #ccc;z-index:1"><?= $order['customer_telephone']; ?></span>
</td>
<td>&nbsp;</td>
<td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
<?= $order['shipping_method']; ?>
&nbsp;
</td>
</tr>
</tbody>
</table>
<br/>
<table width="650" cellspacing="0" cellpadding="0" border="0" style="border:1px solid rgb(234,234,234)">
<thead>
<tr>
<th bgcolor="#eaeaea" align="left" style="padding:3px 9px;font-size:13px">Image</th>
<th bgcolor="#eaeaea" align="left" style="padding:3px 9px;font-size:13px">Name</th>
<th bgcolor="#eaeaea" align="left" style="padding:3px 9px;font-size:13px">Sku</th>
<th bgcolor="#eaeaea" align="center" style="padding:3px 9px;font-size:13px">Qty</th>
<th bgcolor="#eaeaea" align="right" style="padding:3px 9px;font-size:13px">SubTotal</th>
</tr>
</thead>
<?php if(is_array($order['products']) && !empty($order['products'])){ ?>
<?php foreach($order['products'] as $product){ ?>
<tbody>
<tr>
<td valign="top" align="left" style="padding:3px 9px;font-size:11px;border-bottom-color:rgb(204,204,204);border-bottom-width:1px;border-bottom-style:dotted">
<a href="<?= Yii::$service->url->getUrl($product['redirect_url']) ; ?>">
<img src="<?= Yii::$service->product->image->getResize($product['image'],[100,100],false) ?>" alt="<?= $product['name'] ?>" width="75" height="75">
</a>
</td>
<td valign="top" align="left" style="padding:3px 9px;font-size:11px;border-bottom-color:rgb(204,204,204);border-bottom-width:1px;border-bottom-style:dotted">
<b style="font-size:11px">
<?= $product['name'] ?></b>
<?php if(is_array($product['custom_option_info'])){ ?>
<ul>
<?php foreach($product['custom_option_info'] as $label => $val){ ?>
<li><?= Yii::$service->page->translate->__($label.':') ?><?= Yii::$service->page->translate->__($val) ?> </li>
<?php } ?>
</ul>
<?php } ?>
</td>
<td valign="top" align="left" style="padding:3px 9px;font-size:11px;border-bottom-color:rgb(204,204,204);border-bottom-width:1px;border-bottom-style:dotted"><?= $product['sku'] ?></td>
<td valign="top" align="center" style="padding:3px 9px;font-size:11px;border-bottom-color:rgb(204,204,204);border-bottom-width:1px;border-bottom-style:dotted"><?= $product['qty'] ?></td>
<td valign="top" align="right" style="padding:3px 9px;font-size:11px;border-bottom-color:rgb(204,204,204);border-bottom-width:1px;border-bottom-style:dotted"><span><?= $order['currency_symbol'] ?><?= Format::price($product['row_total']); ?></span></td>
</tr>
</tbody>
<?php } } ?>
<tbody>
<tr>
<td align="right" style="padding:3px 9px" colspan="4">Subtotal</td>
<td align="right" style="padding:3px 9px"><span><?= $order['currency_symbol'] ?><?= Format::price($order['subtotal']); ?></span></td>
</tr>
<tr>
<td align="right" style="padding:3px 9px" colspan="4">Shipping &amp; handling </td>
<td align="right" style="padding:3px 9px"><span><?= $order['currency_symbol'] ?><?= Format::price($order['shipping_total']); ?></span></td>
</tr>
<tr>
<td align="right" style="padding:3px 9px" colspan="4">Discount </td>
<td align="right" style="padding:3px 9px"><span><?= $order['currency_symbol'] ?><?= Format::price($order['subtotal_with_discount']); ?></span></td>
</tr>
<tr>
<td align="right" style="padding:3px 9px" colspan="4"><b>Total</b></td>
<td align="right" style="padding:3px 9px"><b><span><?= $order['currency_symbol'] ?><?= Format::price($order['grand_total']); ?></span></b></td>
</tr>
</tbody>
</table>
<p style="font-size:12px; margin:0 0 10px 0"></p>
</td>
</tr>
<tr>
<td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you, <strong><?= $storeName; ?></strong></p></center></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
<?= $storeName ?> New Order # <?= $order['increment_id'] ?>
\ No newline at end of file
......@@ -29,9 +29,9 @@ class Body extends BodyBase
'name' => $identity['firstname'].' '. $identity['lastname'],
'email' => $identity['email'],
'resetUrl' => $resetUrl,
'storeName' => Yii::$service->email->customer->storeName(),
'contactsEmailAddress' => Yii::$service->email->customer->contactsEmailAddress(),
'contactsPhone' => Yii::$service->email->customer->contactsPhone(),
'storeName' => Yii::$service->email->storeName(),
'contactsEmailAddress' => Yii::$service->email->contactsEmailAddress(),
'contactsPhone' => Yii::$service->email->contactsPhone(),
'homeUrl' => Yii::$service->url->homeUrl(),
'logoImg' => Yii::$service->image->getImgUrl('mail/logo.png','appfront'),
......
......@@ -26,9 +26,9 @@ class Body extends BodyBase
'name' => $identity['firstname'].' '. $identity['lastname'],
'email' => $identity['email'],
'password' => 'xxx',
'storeName' => Yii::$service->email->customer->storeName(),
'contactsEmailAddress' => Yii::$service->email->customer->contactsEmailAddress(),
'contactsPhone' => Yii::$service->email->customer->contactsPhone(),
'storeName' => Yii::$service->email->storeName(),
'contactsEmailAddress' => Yii::$service->email->contactsEmailAddress(),
'contactsPhone' => Yii::$service->email->contactsPhone(),
'homeUrl' => Yii::$service->url->homeUrl(),
'logoImg' => Yii::$service->image->getImgUrl('mail/logo.png','appfront'),
......
......@@ -26,9 +26,9 @@ class Body extends BodyBase
'name' => $identity['firstname'].' '. $identity['lastname'],
'email' => $identity['email'],
'password' => $identity['password'],
'storeName' => Yii::$service->email->customer->storeName(),
'contactsEmailAddress' => Yii::$service->email->customer->contactsEmailAddress(),
'contactsPhone' => Yii::$service->email->customer->contactsPhone(),
'storeName' => Yii::$service->email->storeName(),
'contactsEmailAddress' => Yii::$service->email->contactsEmailAddress(),
'contactsPhone' => Yii::$service->email->contactsPhone(),
'homeUrl' => Yii::$service->url->homeUrl(),
'logoImg' => Yii::$service->image->getImgUrl('mail/logo.png','appfront'),
......
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\services\email\widgets\order\create;
use Yii;
use fec\helpers\CModule;
use fec\helpers\CRequest;
use yii\base\InvalidValueException;
use fecshop\app\appfront\helper\mailer\Email;
use fecshop\services\email\widgets\BodyBase;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Body extends BodyBase
{
public function getLastData(){
$order = $this->params;
//echo Yii::$service->image->getImgUrl('mail/logo.png','appfront');exit;
$countryCode = $order['customer_address_country'];
$stateCode = $order['customer_address_state'];
$countryName = Yii::$service->helper->country->getCountryNameByKey($countryCode);
$stateName = Yii::$service->helper->country->getStateByContryCode($countryCode,$stateCode);
return [
'name' => $order['customer_firstname'].' '. $order['customer_lastname'],
'customer_email' => $order['customer_email'],
'increment_id' => $order['increment_id'],
'storeName' => Yii::$service->email->storeName(),
'contactsEmailAddress' => Yii::$service->email->contactsEmailAddress(),
'contactsPhone' => Yii::$service->email->contactsPhone(),
'homeUrl' => Yii::$service->url->homeUrl(),
'logoImg' => Yii::$service->image->getImgUrl('mail/logo.png','appfront'),
'countryName' => $countryName,
'stateName' => $stateName,
'order' => $order,
];
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册