Skip to content

Commit

Permalink
Add schema.org EventReservation to ticket email
Browse files Browse the repository at this point in the history
  • Loading branch information
daveearley committed Jun 18, 2024
1 parent 4acbd51 commit 13d39ae
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
15 changes: 15 additions & 0 deletions backend/app/DomainObjects/EventSettingDomainObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace HiEvents\DomainObjects;

use HiEvents\DataTransferObjects\AddressDTO;

class EventSettingDomainObject extends Generated\EventSettingDomainObjectAbstract
{
/**
Expand Down Expand Up @@ -43,4 +45,17 @@ public function getAddressString(): string

return implode(', ', $filteredAddressParts);
}

public function getAddress(): AddressDTO
{
return new AddressDTO(
venue_name: $this->getLocationDetails()['venue_name'] ?? null,
address_line_1: $this->getLocationDetails()['address_line_1'] ?? null,
address_line_2: $this->getLocationDetails()['address_line_2'] ?? null,
city: $this->getLocationDetails()['city'] ?? null,
state_or_region: $this->getLocationDetails()['state_or_region'] ?? null,
zip_or_postal_code: $this->getLocationDetails()['zip_or_postal_code'] ?? null,
country: $this->getLocationDetails()['country'] ?? null,
);
}
}
1 change: 1 addition & 0 deletions backend/app/Mail/Attendee/AttendeeTicketMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function content(): Content
'event' => $this->event,
'attendee' => $this->attendee,
'eventSettings' => $this->eventSettings,
'organizer' => $this->organizer,
'ticketUrl' => sprintf(
Url::getFrontEndUrlFromConfig(Url::ATTENDEE_TICKET),
$this->event->getId(),
Expand Down
49 changes: 48 additions & 1 deletion backend/resources/views/emails/orders/attendee-ticket.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@php use HiEvents\Helper\DateHelper; @endphp
@php /** @uses /backend/app/Mail/OrderSummary.php */ @endphp
@php /** @var \HiEvents\DomainObjects\OrderDomainObject $order */ @endphp
@php /** @var \HiEvents\DomainObjects\EventDomainObject $event */ @endphp
@php /** @var \HiEvents\DomainObjects\EventSettingDomainObject $eventSettings */ @endphp
@php /** @var \HiEvents\DomainObjects\OrganizerDomainObject $organizer */ @endphp
@php /** @var \HiEvents\DomainObjects\AttendeeDomainObject $attendee */ @endphp
@php /** @var string $ticketUrl */ @endphp
@php /** @see \HiEvents\Mail\Attendee\AttendeeTicketMail */ @endphp

Expand All @@ -22,4 +24,49 @@
Best regards,
<br>
{{config('app.name')}}

<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "EventReservation",
"reservationNumber": "{{ $attendee->getPublicId() }}",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"@type": "Person",
"name": "{{ $attendee->getFirstName() }} {{ $attendee->getLastName() }}"
},
"reservationFor": {
"@type": "Event",
"name": "{{ $event->getTitle() }}",
"performer": {
"@type": "Organization",
"name": "{{ $organizer->getName() }}",
},
"startDate": "{{ DateHelper::convertFromUTC($event->getStartDate(), $event->getTimezone()) }}",
@if($event->getEndDate())
"endDate": "{{ DateHelper::convertFromUTC($event->getEndDate(), $event->getTimezone()) }}",
@endif
@if ($eventSettings->getLocationDetails())
"location": {
"@type": "Place",
"name": "{{ $eventSettings->getAddress()->venue_name }}",
"address": {
"@type": "PostalAddress",
"streetAddress": "{{ $eventSettings->getAddress()->address_line_1 . ' ' . $eventSettings->getAddress()->address_line_2 }}",
"addressLocality": "{{ $eventSettings->getAddress()->city }}",
"addressRegion": "{{ $eventSettings->getAddress()->state_or_region }}",
"postalCode": "{{ $eventSettings->getAddress()->zip_or_postal_code }}",
"addressCountry": "{{ $eventSettings->getAddress()->country }}"
}
}
},
@endif
"ticketToken": "qrCode:{{ $attendee->getPublicId() }}",
"ticketNumber": "{{ $attendee->getPublicId() }}",
"ticketPrintUrl": "{{ $ticketUrl }}",
}
</script>
</x-mail::message>

0 comments on commit 13d39ae

Please sign in to comment.