fix: always filter ski passes by participant's age
This commit is contained in:
@@ -982,12 +982,10 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
||||
/**
|
||||
* Filters ski pass choices for display.
|
||||
*
|
||||
* Unlike other services, ski passes are shown even when age-restricted
|
||||
* (marked as readonly instead of hidden) to avoid user confusion about
|
||||
* included ski passes not being visible.
|
||||
*
|
||||
* Baby filtering is preserved: babies only see services explicitly
|
||||
* including their age range.
|
||||
* Ski passes follow the same age evaluation rules as the rest of the booking flow.
|
||||
* Participants only see passes that match their age or birth year. In edit mode,
|
||||
* the currently booked ski pass is preserved even if it would otherwise be filtered
|
||||
* out, so existing bookings remain renderable and editable.
|
||||
*
|
||||
* @param Service[] $services Array of ski pass Service objects to filter
|
||||
* @param BookingDto $bookingDto The booking DTO containing participant data
|
||||
@@ -1004,17 +1002,18 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
||||
return [];
|
||||
}
|
||||
|
||||
// Check if participant is a baby
|
||||
$age = $participant->getAge($bookingDto->travel->dateFrom);
|
||||
$isBaby = null !== $age && $age <= Constants::BABY_MAX_AGE;
|
||||
$filteredServices = $this->filterServicesByAgeConstraints($services, $bookingDto, $participantIndex);
|
||||
|
||||
// For babies: keep existing filtering logic (only show services with explicit baby age ranges)
|
||||
if ($isBaby) {
|
||||
return $this->filterServicesByAgeConstraints($services, $bookingDto, $participantIndex);
|
||||
if (BookingDto::MODE_EDIT !== $bookingDto->getMode() || null === $participant->skiPass?->id) {
|
||||
return $filteredServices;
|
||||
}
|
||||
|
||||
// For non-babies: return all services (age-restricted ones will be marked readonly in choice_attr)
|
||||
return $services;
|
||||
$currentSkiPassId = $participant->skiPass->id;
|
||||
if (false === isset($filteredServices[$currentSkiPassId])) {
|
||||
$filteredServices[$currentSkiPassId] = $services[$currentSkiPassId] ?? $participant->skiPass;
|
||||
}
|
||||
|
||||
return $filteredServices;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user