Add Woo Manager email notification milestones with shared mail templates.
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:
isaacclad
2026-07-07 02:59:45 +00:00
co-authored by Cursor
parent 1edf5aad43
commit cfdc8c7c09
22 changed files with 926 additions and 12 deletions
@@ -0,0 +1,74 @@
<?php
namespace App\Notifications\Woo;
use App\Models\WooOrder;
use App\Models\WooStore;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class WooOrderReceivedNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(
private readonly WooOrder $order,
private readonly WooStore $store,
) {}
public function via(object $notifiable): array
{
return $this->channels('order_received');
}
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage())
->subject($this->subjectLine())
->view('mail.notifications.woo-order-received', [
'order' => $this->order,
'store' => $this->store,
'manageUrl' => route('woo.orders.index'),
]);
}
/** @return array<string, mixed> */
public function toArray(object $notifiable): array
{
$label = $this->store->site_name ?? parse_url($this->store->site_url, PHP_URL_HOST) ?? 'your store';
return [
'title' => 'New order received',
'message' => "Order #{$this->order->order_number} for {$this->order->totalFormatted()} from {$label}.",
'icon' => 'order',
'milestone' => 'order_received',
'url' => route('woo.orders.index'),
'order_id' => $this->order->id,
'store_id' => $this->store->id,
];
}
private function subjectLine(): string
{
$storeLabel = $this->store->site_name ?? parse_url($this->store->site_url, PHP_URL_HOST) ?? 'WooCommerce store';
return "New order #{$this->order->order_number}{$storeLabel}";
}
/** @return list<string> */
private function channels(string $event): array
{
$config = (array) config("notifications.woo_events.{$event}", ['mail' => true, 'database' => true]);
$channels = [];
if ($config['mail'] ?? false) {
$channels[] = 'mail';
}
if ($config['database'] ?? false) {
$channels[] = 'database';
}
return $channels ?: ['database'];
}
}
@@ -0,0 +1,87 @@
<?php
namespace App\Notifications\Woo;
use App\Models\Woo\ProSubscription;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class WooProExpiringNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(
private readonly ProSubscription $subscription,
private readonly int $daysRemaining,
) {}
public function via(object $notifiable): array
{
return $this->channels('pro_expiring');
}
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage())
->subject($this->subjectLine())
->view('mail.notifications.woo-pro-expiring', [
'subscription' => $this->subscription,
'daysRemaining' => $this->daysRemaining,
'planLabel' => $this->planLabel(),
'renewUrl' => route('woo.pro.index'),
]);
}
/** @return array<string, mixed> */
public function toArray(object $notifiable): array
{
return [
'title' => $this->headline(),
'message' => "Your Woo Manager {$this->planLabel()} plan expires in {$this->daysRemaining} day(s).",
'icon' => 'billing',
'milestone' => 'pro_expiring',
'url' => route('woo.pro.index'),
'days_remaining' => $this->daysRemaining,
];
}
private function subjectLine(): string
{
return match (true) {
$this->daysRemaining <= 1 => 'Woo Manager plan expires tomorrow',
$this->daysRemaining <= 3 => "Woo Manager plan expires in {$this->daysRemaining} days",
default => 'Woo Manager plan renewal reminder',
};
}
private function headline(): string
{
return match (true) {
$this->daysRemaining <= 1 => 'Plan expires soon',
$this->daysRemaining <= 3 => 'Urgent plan renewal',
default => 'Plan renewal reminder',
};
}
private function planLabel(): string
{
return $this->subscription->plan === ProSubscription::PLAN_ENTERPRISE ? 'Business' : 'Pro';
}
/** @return list<string> */
private function channels(string $event): array
{
$config = (array) config("notifications.woo_events.{$event}", ['mail' => true, 'database' => true]);
$channels = [];
if ($config['mail'] ?? false) {
$channels[] = 'mail';
}
if ($config['database'] ?? false) {
$channels[] = 'database';
}
return $channels ?: ['database'];
}
}
@@ -0,0 +1,64 @@
<?php
namespace App\Notifications\Woo;
use App\Models\Woo\ProSubscription;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class WooProPastDueNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(private readonly ProSubscription $subscription) {}
public function via(object $notifiable): array
{
return $this->channels('pro_past_due');
}
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage())
->subject('Woo Manager subscription payment failed')
->view('mail.notifications.woo-pro-past-due', [
'subscription' => $this->subscription,
'planLabel' => $this->planLabel(),
'renewUrl' => route('woo.pro.index'),
]);
}
/** @return array<string, mixed> */
public function toArray(object $notifiable): array
{
return [
'title' => 'Subscription payment failed',
'message' => "We could not renew your Woo Manager {$this->planLabel()} plan. Top up your wallet to restore access.",
'icon' => 'billing',
'milestone' => 'pro_past_due',
'url' => route('woo.pro.index'),
];
}
private function planLabel(): string
{
return $this->subscription->plan === ProSubscription::PLAN_ENTERPRISE ? 'Business' : 'Pro';
}
/** @return list<string> */
private function channels(string $event): array
{
$config = (array) config("notifications.woo_events.{$event}", ['mail' => true, 'database' => true]);
$channels = [];
if ($config['mail'] ?? false) {
$channels[] = 'mail';
}
if ($config['database'] ?? false) {
$channels[] = 'database';
}
return $channels ?: ['database'];
}
}
@@ -0,0 +1,61 @@
<?php
namespace App\Notifications\Woo;
use App\Models\WooStore;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class WooStoreConnectedNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(private readonly WooStore $store) {}
public function via(object $notifiable): array
{
return $this->channels('store_connected');
}
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage())
->subject('WooCommerce store connected — '.($this->store->site_name ?? parse_url($this->store->site_url, PHP_URL_HOST)))
->view('mail.notifications.woo-store-connected', [
'store' => $this->store,
'manageUrl' => route('woo.dashboard'),
]);
}
/** @return array<string, mixed> */
public function toArray(object $notifiable): array
{
$label = $this->store->site_name ?? parse_url($this->store->site_url, PHP_URL_HOST) ?? 'your store';
return [
'title' => 'Store connected',
'message' => "{$label} is now linked to Ladill Woo Manager.",
'icon' => 'success',
'milestone' => 'store_connected',
'url' => route('woo.stores.index'),
'store_id' => $this->store->id,
];
}
/** @return list<string> */
private function channels(string $event): array
{
$config = (array) config("notifications.woo_events.{$event}", ['mail' => true, 'database' => true]);
$channels = [];
if ($config['mail'] ?? false) {
$channels[] = 'mail';
}
if ($config['database'] ?? false) {
$channels[] = 'database';
}
return $channels ?: ['database'];
}
}