From 79912a3a5c200d5e1ebe67b49b22cee066fc79e9 Mon Sep 17 00:00:00 2001 From: xxl4 Date: Sat, 21 Dec 2024 12:09:30 +0800 Subject: [PATCH] fix base --- src/Listeners/Base.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/Listeners/Base.php b/src/Listeners/Base.php index 697bb19..3829d48 100644 --- a/src/Listeners/Base.php +++ b/src/Listeners/Base.php @@ -3,8 +3,10 @@ namespace NexaMerchant\Webhooks\Listeners; use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\Log; use Webkul\Sales\Contracts\OrderComment; + class Base { /** @@ -40,9 +42,33 @@ protected function prepareMail($entity, $notification) try { Mail::queue($notification); } catch(\Exception $e) { - \Log::error('Error in Sending Email' . $e->getMessage()); + Log::error('Error in Sending Email' . $e->getMessage()); + } + + app()->setLocale($previousLocale); + } + + /** + * Get the locale of the customer if somehow item name changes then the english locale will pe provided. + * + * @param object \Webkul\Sales\Contracts\Order|\Webkul\Sales\Contracts\Invoice|\Webkul\Sales\Contracts\Refund|\Webkul\Sales\Contracts\Shipment|\Webkul\Sales\Contracts\OrderComment + * @return string + */ + protected function preparePostData($entity, $notification) + { + $customerLocale = $this->getLocale($entity); + + $previousLocale = core()->getCurrentLocale()->code; + + app()->setLocale($customerLocale); + + try { + $notification->send(); + } catch(\Exception $e) { + Log::error('Error in Sending Email' . $e->getMessage()); } app()->setLocale($previousLocale); } + } \ No newline at end of file