Skip to content

Commit

Permalink
Merge pull request #3017 from jitendra-webkul/1.0
Browse files Browse the repository at this point in the history
Order comment email sent to customer
  • Loading branch information
jitendra-webkul committed May 7, 2020
2 parents 4b31626 + 0893513 commit ad306f7
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/Webkul/Admin/src/Listeners/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Webkul\Admin\Mail\NewInventorySourceNotification;
use Webkul\Admin\Mail\CancelOrderNotification;
use Webkul\Admin\Mail\NewRefundNotification;
use Webkul\Admin\Mail\OrderCommentNotification;

class Order
{
Expand Down Expand Up @@ -124,4 +125,21 @@ public function sendCancelOrderMail($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);
}
}
}
44 changes: 44 additions & 0 deletions packages/Webkul/Admin/src/Mail/OrderCommentNotification.php
Original file line number Diff line number Diff line change
@@ -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');
}
}
2 changes: 2 additions & 0 deletions packages/Webkul/Admin/src/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ public function boot()
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');
}
}
9 changes: 9 additions & 0 deletions packages/Webkul/Shop/src/Resources/lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,15 @@
'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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ad306f7

Please sign in to comment.