[OrderFulfillmentService::class.'::markReady'], // OrderPickupReadyNotification 'dispatched' => [AdvanceFulfillmentOnCarrierCheckpoint::class], // OrderDispatchedNotification 'delivered' => [AdvanceFulfillmentOnDelivered::class], // OrderDeliveredNotification 'completed' => [CompleteOrderOnPickedUp::class, CloseExpiredReturnWindows::class], // OrderCompletedNotification ]; /** * Suppressed when a dedicated notification covers this write (see * OWN_EMAIL). Returning no channels is the standard Laravel way to * suppress a notification outright. * * Also suppressed for the order's very first transition off * 'awaiting_payment' — for every payment method except bank transfer, * that transition happens in the SAME request as checkout itself * (Modules\Core\Order\Services\OrderPaymentResolutionService:: * resolveCaptureOrAuthorization()/resolveDeferredPayment(), both * called synchronously alongside Checkout\Events\OrderPlaced), so it's * not new information — the shopper was already told their order is * confirmed by Modules\Core\Order\Notifications\ * OrderPlacedNotification moments earlier. A bank transfer order is * the one genuine exception: it sits at 'awaiting_payment' until * staff separately mark it paid (Modules\Core\Order\Services\ * OrderFulfillmentService::markPaid()), a real, later event the * shopper does need to hear about — see OrderStatusFlow's own * docblock for why bank transfer is the only payment method where * placement and payment aren't the same moment. */ public function via(object $notifiable): array { if (in_array($this->event->causeClass, self::OWN_EMAIL[$this->event->newStatus] ?? [], true)) { return []; } if ($this->event->previousStatus === 'awaiting_payment' && ! app(OrderStatusFlow::class)->isBankTransfer($this->event->order)) { return []; } return ['mail']; } public function notifiable(): AnonymousNotifiable { $order = $this->event->order; $email = $order->billingAddress?->contact_email ?? $order->shippingAddress?->contact_email; return NotificationFacade::route('mail', $email); } public function toMail(object $notifiable): MailMessage { $order = $this->event->order; $reference = OrderReferenceDisplay::resolve($order); $statusLabel = config("lunar.orders.statuses.{$order->status}.label", $order->status); return (new MailMessage) ->subject(__('Your order :reference is now :status', [ 'reference' => $reference, 'status' => $statusLabel, ])) ->view('core::order.notifications.status-updated', [ 'order' => $order, 'reference' => $reference, 'statusLabel' => $statusLabel, ]); } }