This commit is contained in:
Marcus Moore
2025-05-15 16:22:31 -07:00
parent 0685ff3818
commit 68ef975726
2 changed files with 6 additions and 10 deletions

View File

@@ -51,13 +51,11 @@ class CheckoutableListener
return;
}
// @todo: remove this
// $shouldSendEmailNotifications = $this->shouldSendEmailNotifications($event->checkoutable);
$shouldSendEmailToUser = $this->shouldSendEmailToUser($event->checkoutable);
$shouldSendEmailToAlertAddress = $this->shouldSendEmailToAlertAddress();
$shouldSendWebhookNotification = $this->shouldSendWebhookNotification();
if (!$shouldSendEmailToUser && !$shouldSendWebhookNotification) {
if (!$shouldSendEmailToUser && !$shouldSendWebhookNotification && !$shouldSendEmailToAlertAddress) {
return;
}
@@ -72,13 +70,13 @@ class CheckoutableListener
// if user && cc: to user, cc admin
if ($shouldSendEmailToUser && $shouldSendEmailToAlertAddress) {
$to[] = $notifiable->email;
$to[] = $notifiable;
$cc[] = $this->getFormattedAlertAddresses();
}
// if user && no cc: to user
if ($shouldSendEmailToUser && !$shouldSendEmailToAlertAddress) {
$to[] = $notifiable->email;
$to[] = $notifiable;
}
// if no user && cc: to admin
@@ -87,7 +85,7 @@ class CheckoutableListener
}
try {
Mail::to($to)->cc($cc)->send($mailable);
Mail::to(array_flatten($to))->cc(array_flatten($cc))->send($mailable);
Log::info('Checkout Mail sent to checkout target');
} catch (ClientException $e) {
Log::debug("Exception caught during checkout email: " . $e->getMessage());

View File

@@ -89,16 +89,14 @@ class EmailNotificationsUponCheckoutTest extends TestCase
public function test_sends_alert_email()
{
$this->markTestIncomplete();
$this->settings->enableAdminCC('cc@example.com');
$this->category->update(['checkin_email' => true]);
$this->fireCheckoutEvent();
Mail::assertSent(CheckoutAssetMail::class, function ($mail) {
return $mail->hasTo('cc@example.com');
Mail::assertSent(CheckoutAssetMail::class, function (CheckoutAssetMail $mail) {
return $mail->hasCc('cc@example.com');
});
}