getFieldValue($submittedData, $this->getFieldName()); return null !== $promoCode && '' !== trim($promoCode); } public function processField(array $submittedData, BookingDto $bookingDto, int $participantIndex): void { $participant = $this->getParticipant($bookingDto, $participantIndex); if (null === $participant) { return; } $promoCode = $this->getFieldValue($submittedData, $this->getFieldName()); // Clear validated voucher if code is empty if (null === $promoCode || '' === trim($promoCode)) { $participant->validatedPromoVoucher = null; return; } // Calculate participant price for validation $participantPrice = $this->priceCalculatorService->calculateIndividualParticipantPrice( $bookingDto, $participantIndex ); // Validate promo voucher and store result $result = $this->voucherValidationService->validatePromoVoucher( trim($promoCode), $bookingDto->travel->id, $participantPrice ); // Store validated voucher (null if invalid) $participant->validatedPromoVoucher = $result->isValid ? $result->voucher : null; } }