From 7a7db738b58b1b19b53ed495bd3abec3e7998b0f Mon Sep 17 00:00:00 2001 From: Dave Earley Date: Fri, 31 Oct 2025 06:56:02 +0000 Subject: [PATCH] Fix: Deleted products preventing attendee export --- backend/app/Exports/AttendeesExport.php | 8 ++++++-- backend/app/Repository/Eloquent/ProductRepository.php | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/app/Exports/AttendeesExport.php b/backend/app/Exports/AttendeesExport.php index 0880642ba3..d617a5ca5e 100644 --- a/backend/app/Exports/AttendeesExport.php +++ b/backend/app/Exports/AttendeesExport.php @@ -97,14 +97,18 @@ public function map($attendee): array /** @var ProductDomainObject $ticket */ $ticket = $attendee->getProduct(); - $ticketName = $ticket->getTitle(); - if ($ticket->getType() === ProductPriceType::TIERED->name) { + $ticketName = $ticket?->getTitle(); + if ($ticket && $ticket->getType() === ProductPriceType::TIERED->name) { $ticketName .= ' - ' . $ticket ->getProductPrices() ->first(fn(ProductPriceDomainObject $tp) => $tp->getId() === $attendee->getProductPriceId()) ->getLabel(); } + if (!$ticketName) { + $ticketName = __('Unknown'); + } + $checkIns = $attendee->getCheckIns() ? $attendee->getCheckIns() ->map(fn($checkIn) => sprintf( diff --git a/backend/app/Repository/Eloquent/ProductRepository.php b/backend/app/Repository/Eloquent/ProductRepository.php index 707bec536b..7d2a450903 100644 --- a/backend/app/Repository/Eloquent/ProductRepository.php +++ b/backend/app/Repository/Eloquent/ProductRepository.php @@ -256,7 +256,11 @@ public function hasAssociatedOrders(int $productId): bool { return $this->db->table('order_items') ->join('orders', 'order_items.order_id', '=', 'orders.id') - ->whereIn('orders.status', [OrderStatus::COMPLETED->name, OrderStatus::CANCELLED->name]) + ->whereIn('orders.status', [ + OrderStatus::COMPLETED->name, + OrderStatus::CANCELLED->name, + OrderStatus::AWAITING_OFFLINE_PAYMENT->name, + ]) ->where('order_items.product_id', $productId) ->exists(); }