Merge pull request #3619 from devansh-webkul/mail_issue_on_cancel_order
Fixed admin is not getting mail when customer cancels order #3522
This commit is contained in:
commit
72ce4eea7e
|
|
@ -3,14 +3,15 @@
|
|||
namespace Webkul\Admin\Listeners;
|
||||
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Webkul\Admin\Mail\NewOrderNotification;
|
||||
use Webkul\Admin\Mail\NewAdminNotification;
|
||||
use Webkul\Admin\Mail\NewInvoiceNotification;
|
||||
use Webkul\Admin\Mail\NewShipmentNotification;
|
||||
use Webkul\Admin\Mail\NewInventorySourceNotification;
|
||||
use Webkul\Admin\Mail\CancelOrderNotification;
|
||||
use Webkul\Admin\Mail\NewOrderNotification;
|
||||
use Webkul\Admin\Mail\NewRefundNotification;
|
||||
use Webkul\Admin\Mail\NewInvoiceNotification;
|
||||
use Webkul\Admin\Mail\CancelOrderNotification;
|
||||
use Webkul\Admin\Mail\NewShipmentNotification;
|
||||
use Webkul\Admin\Mail\OrderCommentNotification;
|
||||
use Webkul\Admin\Mail\CancelOrderAdminNotification;
|
||||
use Webkul\Admin\Mail\NewInventorySourceNotification;
|
||||
|
||||
class Order
|
||||
{
|
||||
|
|
@ -117,10 +118,18 @@ class Order
|
|||
public function sendCancelOrderMail($order)
|
||||
{
|
||||
try {
|
||||
/* email to customer */
|
||||
$configKey = 'emails.general.notifications.emails.general.notifications.cancel-order';
|
||||
if (core()->getConfigData($configKey)) {
|
||||
Mail::queue(new CancelOrderNotification($order));
|
||||
}
|
||||
|
||||
/* email to admin */
|
||||
$configKey = 'emails.general.notifications.emails.general.notifications.new-admin';
|
||||
if (core()->getConfigData($configKey)) {
|
||||
app()->setLocale(env('APP_LOCALE'));
|
||||
Mail::queue(new CancelOrderAdminNotification($order));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Admin\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CancelOrderAdminNotification extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var \Webkul\Sales\Contracts\Order
|
||||
*/
|
||||
public $order;
|
||||
|
||||
/**
|
||||
* @param \Webkul\Sales\Contracts\Order $order
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
return $this->from(core()->getSenderEmailDetails()['email'], core()->getSenderEmailDetails()['name'])
|
||||
->to(core()->getAdminEmailDetails()['email'])
|
||||
->subject(trans('shop::app.mail.order.cancel.subject'))
|
||||
->view('shop::emails.sales.order-cancel-admin');
|
||||
}
|
||||
}
|
||||
|
|
@ -592,7 +592,7 @@ return [
|
|||
'subject' => 'Order Cancel Confirmation',
|
||||
'heading' => 'Order Cancelled',
|
||||
'dear' => 'Dear :customer_name',
|
||||
'greeting' => 'You Order with order id #:order_id placed on :created_at has been cancelled',
|
||||
'greeting' => 'Your Order with order id :order_id placed on :created_at has been cancelled',
|
||||
'summary' => 'Summary of Order',
|
||||
'shipping-address' => 'Shipping Address',
|
||||
'billing-address' => 'Billing Address',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,212 @@
|
|||
@component('shop::emails.layouts.master')
|
||||
<div style="text-align: center;">
|
||||
<a href="{{ config('app.url') }}">
|
||||
@if (core()->getConfigData('general.design.admin_logo.logo_image'))
|
||||
<img src="{{ \Illuminate\Support\Facades\Storage::url(core()->getConfigData('general.design.admin_logo.logo_image')) }}" alt="{{ config('app.name') }}" style="height: 40px; width: 110px;"/>
|
||||
@else
|
||||
<img src="{{ asset('vendor/webkul/ui/assets/images/logo.png') }}" alt="{{ config('app.name') }}"/>
|
||||
@endif
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div style="padding: 30px;">
|
||||
<div style="font-size: 20px;color: #242424;line-height: 30px;margin-bottom: 34px;">
|
||||
<span style="font-weight: bold;">
|
||||
{{ __('shop::app.mail.order.cancel.heading') }}
|
||||
</span> <br>
|
||||
|
||||
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
|
||||
{{ __('shop::app.mail.order.cancel.dear', ['customer_name' => config('mail.from.name')]) }},
|
||||
</p>
|
||||
|
||||
<p style="font-size: 16px;color: #5E5E5E;line-height: 24px;">
|
||||
{!! __('shop::app.mail.order.cancel.greeting', [
|
||||
'order_id' => '<a href="' . route('customer.orders.view', $order->id) . '" style="color: #0041FF; font-weight: bold;">#' . $order->increment_id . '</a>',
|
||||
'created_at' => $order->created_at
|
||||
])
|
||||
!!}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div style="font-weight: bold;font-size: 20px;color: #242424;line-height: 30px;margin-bottom: 20px !important;">
|
||||
{{ __('shop::app.mail.order.cancel.summary') }}
|
||||
</div>
|
||||
|
||||
<div style="display: flex;flex-direction: row;margin-top: 20px;justify-content: space-between;margin-bottom: 40px;">
|
||||
<div style="line-height: 25px;">
|
||||
<div style="font-weight: bold;font-size: 16px;color: #242424;">
|
||||
{{ __('shop::app.mail.order.cancel.shipping-address') }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ $order->shipping_address->company_name ?? '' }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ $order->shipping_address->name }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ $order->shipping_address->address1 }}, {{ $order->shipping_address->state }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ core()->country_name($order->shipping_address->country) }} {{ $order->shipping_address->postcode }}
|
||||
</div>
|
||||
|
||||
<div>---</div>
|
||||
|
||||
<div style="margin-bottom: 40px;">
|
||||
{{ __('shop::app.mail.order.cancel.contact') }} : {{ $order->shipping_address->phone }}
|
||||
</div>
|
||||
|
||||
<div style="font-size: 16px;color: #242424; font-weight: bold">
|
||||
{{ __('shop::app.mail.order.cancel.shipping') }}
|
||||
</div>
|
||||
|
||||
<div style="font-size: 16px;color: #242424;">
|
||||
{{ $order->shipping_title }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="line-height: 25px;">
|
||||
<div style="font-weight: bold;font-size: 16px;color: #242424;">
|
||||
{{ __('shop::app.mail.order.cancel.billing-address') }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ $order->billing_address->company_name ?? '' }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ $order->billing_address->name }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ $order->billing_address->address1 }}, {{ $order->billing_address->state }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ core()->country_name($order->billing_address->country) }} {{ $order->billing_address->postcode }}
|
||||
</div>
|
||||
|
||||
<div>---</div>
|
||||
|
||||
<div style="margin-bottom: 40px;">
|
||||
{{ __('shop::app.mail.order.cancel.contact') }} : {{ $order->billing_address->phone }}
|
||||
</div>
|
||||
|
||||
<div style="font-size: 16px; color: #242424; font-weight: bold">
|
||||
{{ __('shop::app.mail.order.cancel.payment') }}
|
||||
</div>
|
||||
|
||||
<div style="font-size: 16px; color: #242424;">
|
||||
{{ core()->getConfigData('sales.paymentmethods.' . $order->payment->method . '.title') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
<div class="table mb-20">
|
||||
<table style="overflow-x: auto; border-collapse: collapse;
|
||||
border-spacing: 0;width: 100%">
|
||||
<thead>
|
||||
<tr style="background-color: #f2f2f2">
|
||||
<th style="text-align: left;padding: 8px">{{ __('shop::app.customer.account.order.view.SKU') }}</th>
|
||||
<th style="text-align: left;padding: 8px">{{ __('shop::app.customer.account.order.view.product-name') }}</th>
|
||||
<th style="text-align: left;padding: 8px">{{ __('shop::app.customer.account.order.view.price') }}</th>
|
||||
<th style="text-align: left;padding: 8px">{{ __('shop::app.customer.account.order.view.qty') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($order->items as $item)
|
||||
<tr>
|
||||
<td data-value="{{ __('shop::app.customer.account.order.view.SKU') }}" style="text-align: left;padding: 8px">
|
||||
{{ $item->child ? $item->child->sku : $item->sku }}
|
||||
</td>
|
||||
|
||||
<td data-value="{{ __('shop::app.customer.account.order.view.product-name') }}" style="text-align: left;padding: 8px">
|
||||
{{ $item->name }}
|
||||
|
||||
@if (isset($item->additional['attributes']))
|
||||
<div class="item-options">
|
||||
|
||||
@foreach ($item->additional['attributes'] as $attribute)
|
||||
<b>{{ $attribute['attribute_name'] }} : </b>{{ $attribute['option_label'] }}</br>
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
@endif
|
||||
</td>
|
||||
|
||||
<td data-value="{{ __('shop::app.customer.account.order.view.price') }}" style="text-align: left;padding: 8px">
|
||||
{{ core()->formatPrice($item->price, $order->order_currency_code) }}
|
||||
</td>
|
||||
|
||||
<td data-value="{{ __('shop::app.customer.account.order.view.qty') }}" style="text-align: left;padding: 8px">
|
||||
{{ $item->qty_canceled }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="font-size: 16px;color: #242424;line-height: 30px;float: right;width: 40%;margin-top: 20px;">
|
||||
<div>
|
||||
<span>{{ __('shop::app.mail.order.cancel.subtotal') }}</span>
|
||||
<span style="float: right;">
|
||||
{{ core()->formatPrice($order->sub_total, $order->order_currency_code) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span>{{ __('shop::app.mail.order.cancel.shipping-handling') }}</span>
|
||||
<span style="float: right;">
|
||||
{{ core()->formatPrice($order->shipping_amount, $order->order_currency_code) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@foreach (Webkul\Tax\Helpers\Tax::getTaxRatesWithAmount($order, false) as $taxRate => $taxAmount )
|
||||
<div>
|
||||
<span id="taxrate-{{ core()->taxRateAsIdentifier($taxRate) }}">{{ __('shop::app.mail.order.cancel.tax') }} {{ $taxRate }} %</span>
|
||||
<span id="taxamount-{{ core()->taxRateAsIdentifier($taxRate) }}" style="float: right;">
|
||||
{{ core()->formatPrice($taxAmount, $order->order_currency_code) }}
|
||||
</span>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
@if ($order->discount_amount > 0)
|
||||
<div>
|
||||
<span>{{ __('shop::app.mail.order.cancel.discount') }}</span>
|
||||
<span style="float: right;">
|
||||
{{ core()->formatPrice($order->discount_amount, $order->order_currency_code) }}
|
||||
</span>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div style="font-weight: bold">
|
||||
<span>{{ __('shop::app.mail.order.cancel.grand-total') }}</span>
|
||||
<span style="float: right;">
|
||||
{{ core()->formatPrice($order->grand_total, $order->order_currency_code) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 65px;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.cancel.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.cancel.thanks') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@endcomponent
|
||||
Loading…
Reference in New Issue