fix: Correct print stock relationship accessor
- Change print_stocks (plural) to printStock (singular) - Properly accesses the PrintStock model via OrderItem's belongsTo relationship - Gets the correct print stock name from the print_stocks table
This commit is contained in:
@@ -21,6 +21,7 @@ class NotifySlackOnOrderCreated
|
||||
|
||||
// Extract design name from first order item's product
|
||||
$designName = $order->items->first()?->product?->name ?? '—';
|
||||
$printStock = $order->items->first()?->printStock?->name ?? '—';
|
||||
|
||||
// Calculate print size from first item's dimensions
|
||||
$printSize = '—';
|
||||
@@ -29,7 +30,7 @@ class NotifySlackOnOrderCreated
|
||||
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';
|
||||
$printSize = $firstItem->width . 'm × ' . $firstItem->height . 'm';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +57,7 @@ class NotifySlackOnOrderCreated
|
||||
// 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, 'print_stock', $printStock);
|
||||
$this->trello->setTextField($cardId, 'customer_name', $order->customer_name ?? '—');
|
||||
$this->trello->setTextField($cardId, 'print_size', $printSize);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user