Skip to content

Commit

Permalink
fix base
Browse files Browse the repository at this point in the history
  • Loading branch information
xxl4 committed Dec 21, 2024
1 parent 02b2915 commit 79912a3
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/Listeners/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down Expand Up @@ -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);
}

}

0 comments on commit 79912a3

Please sign in to comment.