Skip to content

Commit 3c28546

Browse files
authored
Fix: Unable to re-assign orders on sold out events (#826)
1 parent 57d7f17 commit 3c28546

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

backend/app/Services/Application/Handlers/Attendee/EditAttendeeHandler.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

frontend/src/components/modals/ManageAttendeeModal/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const ManageAttendeeModal = ({onClose, attendeeId}: ManageAttendeeModalPr
6161
email: attendee.email,
6262
notes: attendee.notes || "",
6363
product_id: String(attendee.product_id),
64-
product_price_id: String(attendee.product_price_id),
64+
product_price_id: attendee.product_price_id ? String(attendee.product_price_id) : "",
6565
});
6666
}
6767
}, [attendee]);
@@ -72,11 +72,11 @@ export const ManageAttendeeModal = ({onClose, attendeeId}: ManageAttendeeModalPr
7272
}
7373
let productPriceId = event?.product_categories
7474
?.flatMap(category => category.products)
75-
.find(product => product.id === form.values.product_id)?.prices?.[0]?.id;
75+
.find(product => String(product?.id) === String(form.values.product_id))?.prices?.[0]?.id;
7676

7777
form.setValues({
7878
...form.values,
79-
product_price_id: String(productPriceId),
79+
product_price_id: productPriceId ? String(productPriceId) : "",
8080
});
8181
}, [form.values.product_id]);
8282

0 commit comments

Comments
 (0)