From 9fd138582a2402dd438ce066c7726414612d9dd3 Mon Sep 17 00:00:00 2001 From: twotalesanimation <80506065+twotalesanimation@users.noreply.github.com> Date: Fri, 2 Jan 2026 16:15:57 +0200 Subject: [PATCH] feat: Enhance Slack notification with design and size details - Add emoji () and design name to order creation Slack message - Include print size information (wallpaper length or mural dimensions) - Extract design/size info once and reuse for both Slack and Trello - Message format: 'New [type] order: Order #[number]\\nDesign: [name]\\nSize: [dimensions]' --- app/Listeners/NotifySlackOnOrderCreated.php | 36 ++++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/app/Listeners/NotifySlackOnOrderCreated.php b/app/Listeners/NotifySlackOnOrderCreated.php index a1c7f33..8f54f3e 100644 --- a/app/Listeners/NotifySlackOnOrderCreated.php +++ b/app/Listeners/NotifySlackOnOrderCreated.php @@ -18,7 +18,25 @@ class NotifySlackOnOrderCreated public function handle(OrderCreated $event): void { $order = $event->order; - $message = "New {$event->orderType} order created: Order #{$order->order_number}"; + + // Extract design name from first order item's product + $designName = $order->items->first()?->product?->name ?? '—'; + + // Calculate print size from first item's dimensions + $printSize = '—'; + $firstItem = $order->items->first(); + if ($firstItem) { + if ($firstItem->type === 'wallpaper' && $firstItem->length) { + $printSize = $firstItem->length . 'm'; + } elseif ($firstItem->type === 'mural' && $firstItem->width && $firstItem->height) { + $printSize = $firstItem->width . 'cm × ' . $firstItem->height . 'cm'; + } + } + + // Build detailed Slack message + $message = "🆕 New {$event->orderType} order: Order #{$order->order_number}\n" . + "Design: '{$designName}'\n" . + "Size: {$printSize}"; // Notify Slack $this->slack->orders($message); @@ -35,21 +53,7 @@ class NotifySlackOnOrderCreated if ($cardId) { $order->update(['trello_card_id' => $cardId]); - // Extract design name from first order item's product - $designName = $order->items->first()?->product?->name ?? '—'; - - // Calculate print size from first item's dimensions - $printSize = '—'; - $firstItem = $order->items->first(); - if ($firstItem) { - if ($firstItem->type === 'wallpaper' && $firstItem->length) { - $printSize = $firstItem->length . 'm'; - } elseif ($firstItem->type === 'mural' && $firstItem->width && $firstItem->height) { - $printSize = $firstItem->width . 'cm × ' . $firstItem->height . 'cm'; - } - } - - // Populate custom fields + // Populate custom fields with the same info $this->trello->setTextField($cardId, 'order_id', $order->uuid); $this->trello->setTextField($cardId, 'design_name', $designName); $this->trello->setTextField($cardId, 'customer_name', $order->customer_name ?? '—');