Skip to content

Commit

Permalink
Fix errors when saving events with invalid tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Mar 2, 2023
1 parent 8a8d859 commit cdccee2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/helpers/EventHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function populateEventTicketModel(EventModel $event, $ticket, $key
$newTicket = str_starts_with($key, 'new');

if ($eventId && !$newTicket) {
$ticketModel = Events::$plugin->getTickets()->getTicketById($key, $event->siteId);
$ticketModel = Events::$plugin->getTickets()->getTicketById((int)$key, $event->siteId);

if (!$ticketModel) {
$ticketModel = new Ticket();
Expand All @@ -37,14 +37,14 @@ public static function populateEventTicketModel(EventModel $event, $ticket, $key
$ticketModel->typeId = $ticket['typeIds'][0] ?? 0;
$ticketModel->enabled = (bool)($ticket['enabled'] ?? 1);
$ticketModel->sku = $ticket['sku'] ?? '';
$ticketModel->quantity = (int)$ticket['quantity'] ?? null;
$ticketModel->price = LocalizationHelper::normalizeNumber($ticket['price']);
$ticketModel->quantity = (int)($ticket['quantity'] ?? null);
$ticketModel->price = (float)LocalizationHelper::normalizeNumber($ticket['price'] ?? null);

if (($availableFrom = $ticket['availableFrom']) !== null) {
if (($availableFrom = ($ticket['availableFrom'] ?? null)) !== null) {
$ticketModel->availableFrom = DateTimeHelper::toDateTime($availableFrom) ?: null;
}

if (($availableTo = $ticket['availableTo']) !== null) {
if (($availableTo = ($ticket['availableTo'] ?? null)) !== null) {
$ticketModel->availableTo = DateTimeHelper::toDateTime($availableTo) ?: null;
}

Expand Down
Loading

0 comments on commit cdccee2

Please sign in to comment.