@@ -39,10 +39,10 @@ public function __construct(
3939 public function handle (EditAttendeeDTO $ editAttendeeDTO ): AttendeeDomainObject
4040 {
4141 return $ this ->databaseManager ->transaction (function () use ($ editAttendeeDTO ) {
42- $ this ->validateProductId ($ editAttendeeDTO );
43-
4442 $ attendee = $ this ->getAttendee ($ editAttendeeDTO );
4543
44+ $ this ->validateProductId ($ editAttendeeDTO , $ attendee );
45+
4646 $ this ->adjustProductQuantities ($ attendee , $ editAttendeeDTO );
4747
4848 $ updatedAttendee = $ this ->updateAttendee ($ editAttendeeDTO );
@@ -84,7 +84,10 @@ private function updateAttendee(EditAttendeeDTO $editAttendeeDTO): AttendeeDomai
8484 * @throws ValidationException
8585 * @throws NoTicketsAvailableException
8686 */
87- private function validateProductId (EditAttendeeDTO $ editAttendeeDTO ): void
87+ private function validateProductId (
88+ EditAttendeeDTO $ editAttendeeDTO ,
89+ AttendeeDomainObject $ attendee ,
90+ ): void
8891 {
8992 /** @var ProductDomainObject $product */
9093 $ product = $ this ->productRepository
@@ -106,6 +109,11 @@ private function validateProductId(EditAttendeeDTO $editAttendeeDTO): void
106109 ]);
107110 }
108111
112+ // No need to check availability if the product price hasn't changed
113+ if ($ attendee ->getProductPriceId () === $ editAttendeeDTO ->product_price_id ) {
114+ return ;
115+ }
116+
109117 $ availableQuantity = $ this ->productRepository ->getQuantityRemainingForProductPrice (
110118 productId: $ editAttendeeDTO ->product_id ,
111119 productPriceId: $ product ->getType () === ProductPriceType::TIERED ->name
0 commit comments