Add Woo Manager email notification milestones with shared mail templates.
Deploy Ladill Woo Manager / deploy (push) Successful in 2m11s
Deploy Ladill Woo Manager / deploy (push) Successful in 2m11s
New order, store connected, Pro expiry, and past-due alerts use the Ladill notification layout with woo branding; expiry reminders dedupe per threshold like hosting. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Woo;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Woo\ProSubscription;
|
||||
use App\Models\WooOrder;
|
||||
use App\Models\WooStore;
|
||||
use App\Notifications\Woo\WooOrderReceivedNotification;
|
||||
use App\Notifications\Woo\WooProExpiringNotification;
|
||||
use App\Notifications\Woo\WooProPastDueNotification;
|
||||
use App\Notifications\Woo\WooStoreConnectedNotification;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class WooNotificationService
|
||||
{
|
||||
public function orderReceived(WooOrder $order, WooStore $store): void
|
||||
{
|
||||
$order->loadMissing('store');
|
||||
$user = $store->user;
|
||||
if (! $user) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->send($user, 'order_received', new WooOrderReceivedNotification($order, $store));
|
||||
}
|
||||
|
||||
public function storeConnected(WooStore $store): void
|
||||
{
|
||||
$user = $store->user;
|
||||
if (! $user) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->send($user, 'store_connected', new WooStoreConnectedNotification($store));
|
||||
}
|
||||
|
||||
public function proExpiring(ProSubscription $subscription, int $daysRemaining): void
|
||||
{
|
||||
$user = $subscription->user;
|
||||
if (! $user) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->send($user, 'pro_expiring', new WooProExpiringNotification($subscription, $daysRemaining));
|
||||
}
|
||||
|
||||
public function proPastDue(ProSubscription $subscription): void
|
||||
{
|
||||
$user = $subscription->user;
|
||||
if (! $user) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->send($user, 'pro_past_due', new WooProPastDueNotification($subscription));
|
||||
}
|
||||
|
||||
private function send(User $user, string $event, Notification $notification): void
|
||||
{
|
||||
$channels = (array) config("notifications.woo_events.{$event}", ['mail' => true, 'database' => true]);
|
||||
if (! ($channels['mail'] ?? false) && ! ($channels['database'] ?? false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$user->notify($notification);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user