Order comment email sent to customer

This commit is contained in:
Pranshu Tomar 2020-05-07 13:58:14 +05:30
parent 2a9c3de89a
commit 0893513b60
5 changed files with 108 additions and 0 deletions

View File

@ -10,6 +10,7 @@ use Webkul\Admin\Mail\NewShipmentNotification;
use Webkul\Admin\Mail\NewInventorySourceNotification;
use Webkul\Admin\Mail\CancelOrderNotification;
use Webkul\Admin\Mail\NewRefundNotification;
use Webkul\Admin\Mail\OrderCommentNotification;
class Order
{
@ -124,4 +125,21 @@ class Order
report($e);
}
}
/**
* @param \Webkul\Sales\Contracts\OrderComment $comment
* @return void
*/
public function sendOrderCommentMail($comment)
{
if (! $comment->customer_notified) {
return;
}
try {
Mail::queue(new OrderCommentNotification($comment));
} catch (\Exception $e) {
report($e);
}
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace Webkul\Admin\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class OrderCommentNotification extends Mailable
{
use Queueable, SerializesModels;
/**
* The order comment instance.
*
* @var \Webkul\Sales\Contracts\OrderComment $comment
*/
public $comment;
/**
* Create a new message instance.
*
* @param \Webkul\Sales\Contracts\OrderComment $comment
* @return void
*/
public function __construct($comment)
{
$this->comment = $comment;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
->to($this->comment->order->customer_email, $this->comment->order->customer_full_name)
->subject(trans('shop::app.mail.order.comment.subject'))
->view('shop::emails.sales.new-order-comment');
}
}

View File

@ -23,5 +23,7 @@ class EventServiceProvider extends ServiceProvider
Event::listen('sales.order.cancel.after','Webkul\Admin\Listeners\Order@sendCancelOrderMail');
Event::listen('sales.refund.save.after','Webkul\Admin\Listeners\Order@sendNewRefundMail');
Event::listen('sales.order.comment.create.after','Webkul\Admin\Listeners\Order@sendOrderCommentMail');
}
}

View File

@ -571,6 +571,15 @@ return [
'final-summary' => 'Thanks for showing your interest in our store we will send you tracking number once it shipped',
'help' => 'If you need any kind of help please contact us at :support_email',
'thanks' => 'Thanks!',
'comment' => [
'subject' => 'New comment added to your order',
'dear' => 'Dear :customer_name',
'final-summary' => 'Thanks for showing your interest in our store',
'help' => 'If you need any kind of help please contact us at :support_email',
'thanks' => 'Thanks!',
],
'cancel' => [
'subject' => 'Order Cancel Confirmation',
'heading' => 'Order Cancelled',

View File

@ -0,0 +1,35 @@
@component('shop::emails.layouts.master')
<div style="text-align: center;">
<a href="{{ config('app.url') }}">
@include ('shop::emails.layouts.logo')
</a>
</div>
<div style="padding: 30px;">
<div style="font-size: 20px;color: #242424;line-height: 30px;margin-bottom: 34px;">
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
{{ __('shop::app.mail.order.comment.dear', ['customer_name' => $comment->order->customer_full_name]) }},
</p>
</div>
<div style="line-height: 30px;margin-bottom: 20px !important;">
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;font-style: italic;">
{{ $comment->comment }}
</p>
</div>
<div style="margin-top: 20px;font-size: 16px;color: #5E5E5E;line-height: 24px;display: inline-block">
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
{!!
__('shop::app.mail.order.comment.help', [
'support_email' => '<a style="color:#0041FF" href="mailto:' . config('mail.from.address') . '">' . config('mail.from.address'). '</a>'
])
!!}
</p>
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
{{ __('shop::app.mail.order.comment.thanks') }}
</p>
</div>
</div>
@endcomponent