[Updated: Shop & admin email setting added in configuration.]

This commit is contained in:
Vivek 2020-03-17 16:10:47 +05:30
parent 659745ee70
commit ad76426fb5
20 changed files with 148 additions and 46 deletions

View File

@ -30,6 +30,37 @@ return [
'channel_based' => true,
],
],
], [
'key' => 'general.general.email_settings',
'name' => 'admin::app.admin.system.email-settings',
'sort' => 1,
'fields' => [
[
'name' => 'sender_name',
'title' => 'admin::app.admin.system.email-sender-name',
'type' => 'text',
'validation' => 'required|max:50',
'channel_based' => true,
], [
'name' => 'shop_email_from',
'title' => 'admin::app.admin.system.shop-email-from',
'type' => 'text',
'validation' => 'required|email',
'channel_based' => true,
], [
'name' => 'admin_name',
'title' => 'admin::app.admin.system.admin-name',
'type' => 'text',
'validation' => 'required|max:50',
'channel_based' => true,
], [
'name' => 'admin_email',
'title' => 'admin::app.admin.system.admin-email',
'type' => 'text',
'validation' => 'required|email',
'channel_based' => true,
],
],
], [
'key' => 'general.content',
'name' => 'admin::app.admin.system.content',

View File

@ -27,8 +27,9 @@ class CancelOrderNotification extends Mailable
public function build()
{
return $this->to($this->order->customer_email, $this->order->customer_full_name)
->subject(trans('shop::app.mail.order.cancel.subject'))
->view('shop::emails.sales.order-cancel');
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->order->customer_email, $this->order->customer_full_name)
->subject(trans('shop::app.mail.order.cancel.subject'))
->view('shop::emails.sales.order-cancel');
}
}

View File

@ -36,8 +36,9 @@ class NewAdminNotification extends Mailable
*/
public function build()
{
return $this->to(config('mail.admin.address'))
->subject(trans('shop::app.mail.order.subject'))
->view('shop::emails.sales.new-admin-order');
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to(core()->getAdminEmailDetails()['email'])
->subject(trans('shop::app.mail.order.subject'))
->view('shop::emails.sales.new-admin-order');
}
}

View File

@ -49,8 +49,9 @@ class NewCustomerNotification extends Mailable
*/
public function build()
{
return $this->to($this->customer->email)
->subject(trans('shop::app.mail.customer.new.subject'))
->view('shop::emails.customer.new-customer')->with(['customer' => $this->customer, 'password' => $this->password]);
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->customer->email)
->subject(trans('shop::app.mail.customer.new.subject'))
->view('shop::emails.customer.new-customer')->with(['customer' => $this->customer, 'password' => $this->password]);
}
}

View File

@ -40,8 +40,9 @@ class NewInventorySourceNotification extends Mailable
$inventory = $this->shipment->inventory_source;
return $this->to($inventory->contact_email, $inventory->name)
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-inventorysource-shipment');
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($inventory->contact_email, $inventory->name)
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-inventorysource-shipment');
}
}

View File

@ -38,8 +38,9 @@ class NewInvoiceNotification extends Mailable
{
$order = $this->invoice->order;
return $this->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.invoice.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-invoice');
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.invoice.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-invoice');
}
}

View File

@ -36,8 +36,9 @@ class NewOrderNotification extends Mailable
*/
public function build()
{
return $this->to($this->order->customer_email, $this->order->customer_full_name)
->subject(trans('shop::app.mail.order.subject'))
->view('shop::emails.sales.new-order');
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->order->customer_email, $this->order->customer_full_name)
->subject(trans('shop::app.mail.order.subject'))
->view('shop::emails.sales.new-order');
}
}

View File

@ -38,8 +38,9 @@ class NewRefundNotification extends Mailable
{
$order = $this->refund->order;
return $this->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.refund.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-refund');
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.refund.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-refund');
}
}

View File

@ -38,8 +38,9 @@ class NewShipmentNotification extends Mailable
{
$order = $this->shipment->order;
return $this->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-shipment');
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($order->customer_email, $order->customer_full_name)
->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id]))
->view('shop::emails.sales.new-shipment');
}
}

View File

@ -936,6 +936,11 @@ return [
'footer-content' => 'Footer Text',
'locale-options' => 'Unit Options',
'weight-unit' => 'Weight Unit',
'email-settings' => 'Email Settings',
'email-sender-name' => 'Email Sender Name',
'shop-email-from' => 'Shop Email Address [For sending emails]',
'admin-name' => 'Admin Name',
'admin-email' => 'Admin Email',
'admin-page-limit' => 'العناصر الافتراضية لكل صفحة (المشرف)',
'design' => 'Design',
'admin-logo' => 'Admin Logo',

View File

@ -1286,6 +1286,11 @@ return [
'footer-toggle' => 'Toggle footer',
'locale-options' => 'Unit Options',
'weight-unit' => 'Weight Unit',
'email-settings' => 'Email Settings',
'email-sender-name' => 'Email Sender Name',
'shop-email-from' => 'Shop Email Address [For sending emails]',
'admin-name' => 'Admin Name',
'admin-email' => 'Admin Email',
'admin-page-limit' => 'Default Items Per Page (Admin)',
'design' => 'Design',
'admin-logo' => 'Admin Logo',

View File

@ -1064,6 +1064,11 @@ return [
'footer-content' => 'متن فوتر',
'locale-options' => 'گزینه های واحد',
'weight-unit' => 'واحد وزن',
'email-settings' => 'Email Settings',
'email-sender-name' => 'Email Sender Name',
'shop-email-from' => 'Shop Email Address [For sending emails]',
'admin-name' => 'Admin Name',
'admin-email' => 'Admin Email',
'design' => 'طراحی',
'admin-logo' => 'لوگو مدیر',
'logo-image' => 'تصویر لوگو',

View File

@ -1283,6 +1283,11 @@ return [
'footer-toggle' => 'Toggle footer',
'locale-options' => 'Eenheid opties',
'weight-unit' => 'Gewichtseenheid',
'email-settings' => 'Email Settings',
'email-sender-name' => 'Email Sender Name',
'shop-email-from' => 'Shop Email Address [For sending emails]',
'admin-name' => 'Admin Name',
'admin-email' => 'Admin Email',
'admin-page-limit' => 'Standaarditems per pagina (Admin)',
'design' => 'Ontwerp',
'admin-logo' => 'Admin Logo',

View File

@ -1047,6 +1047,11 @@ return [
'footer-content' => 'Texto de rodapé',
'locale-options' => 'Opções de unidade',
'weight-unit' => 'Unidade de peso',
'email-settings' => 'Email Settings',
'email-sender-name' => 'Email Sender Name',
'shop-email-from' => 'Shop Email Address [For sending emails]',
'admin-name' => 'Admin Name',
'admin-email' => 'Admin Email',
'design' => 'Design',
'admin-logo' => 'Admin Logo',
'logo-image' => 'Logo Imagem',

View File

@ -1047,4 +1047,38 @@ class Core
{
return str_replace('.', '_', (string)$taxRate);
}
/**
* Get Shop email sender details
*
* @return array
*/
public function getSenderEmailDetails()
{
$sender_name = core()->getConfigData('general.general.email_settings.sender_name') ? core()->getConfigData('general.general.email_settings.sender_name') : config('mail.from.name');
$sender_email = core()->getConfigData('general.general.email_settings.shop_email_from') ? core()->getConfigData('general.general.email_settings.shop_email_from') : config('mail.from.address');
return [
'name' => $sender_name,
'email' => $sender_email,
];
}
/**
* Get Admin email details
*
* @return array
*/
public function getAdminEmailDetails()
{
$admin_name = core()->getConfigData('general.general.email_settings.admin_name') ? core()->getConfigData('general.general.email_settings.admin_name') : config('mail.admin.name');
$admin_email = core()->getConfigData('general.general.email_settings.admin_email') ? core()->getConfigData('general.general.email_settings.admin_email') : config('mail.admin.address');
return [
'name' => $admin_name,
'email' => $admin_email,
];
}
}

View File

@ -34,8 +34,9 @@ class RegistrationEmail extends Mailable
*/
public function build()
{
return $this->to($this->data['email'])
->subject(trans('shop::app.mail.customer.registration.customer-registration'))
->view('shop::emails.customer.registration')->with('data', $this->data);
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->data['email'])
->subject(trans('shop::app.mail.customer.registration.customer-registration'))
->view('shop::emails.customer.registration')->with('data', $this->data);
}
}

View File

@ -34,13 +34,14 @@ class VerificationEmail extends Mailable
*/
public function build()
{
return $this->to($this->verificationData['email'])
->subject(trans('shop::app.mail.customer.verification.subject'))
->view('shop::emails.customer.verification-email')
->with('data', [
'email' => $this->verificationData['email'],
'token' => $this->verificationData['token'],
]
);
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->verificationData['email'])
->subject(trans('shop::app.mail.customer.verification.subject'))
->view('shop::emails.customer.verification-email')
->with('data', [
'email' => $this->verificationData['email'],
'token' => $this->verificationData['token'],
]
);
}
}

View File

@ -21,10 +21,11 @@ class CustomerResetPassword extends ResetPassword
}
return (new MailMessage)
->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->subject(__('shop::app.mail.forget-password.subject') )
->view('shop::emails.customer.forget-password', [
'user_name' => $notifiable->name,
'token' => $this->token,
'user_name' => $notifiable->name,
'token' => $this->token,
]
);
}

View File

@ -30,14 +30,14 @@ class SubscriptionEmail extends Mailable
*/
public function build()
{
return $this->to($this->subscriptionData['email'])
->subject(trans('shop::app.mail.customer.subscription.subject'))
->view('shop::emails.customer.subscription-email')
->with('data', [
'content' => 'You Are Subscribed',
'token' => $this->subscriptionData['token'],
]
);
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->subscriptionData['email'])
->subject(trans('shop::app.mail.customer.subscription.subject'))
->view('shop::emails.customer.subscription-email')
->with('data', [
'content' => 'You Are Subscribed',
'token' => $this->subscriptionData['token'],
]
);
}
}

View File

@ -20,6 +20,7 @@ class AdminResetPassword extends ResetPassword
}
return (new MailMessage)
->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->view('shop::emails.admin.forget-password', [
'user_name' => $notifiable->name,
'token' => $this->token,