Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion backend/app/DomainObjects/Enums/EmailTemplateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ enum EmailTemplateType: string
{
use BaseEnum;

case ORGANIZER_ORDER_NOTIFICATION = 'organizer_order_notification';
case ORDER_CONFIRMATION = 'order_confirmation';
case ATTENDEE_TICKET = 'attendee_ticket';
case OCCURRENCE_CANCELLATION = 'occurrence_cancellation';

public function label(): string
{
return match ($this) {
self::ORGANIZER_ORDER_NOTIFICATION => __('New Order Notification'),
self::ORDER_CONFIRMATION => __('Order Confirmation'),
self::ATTENDEE_TICKET => __('Attendee Ticket'),
self::OCCURRENCE_CANCELLATION => __('Date Cancellation'),
Expand All @@ -22,6 +24,7 @@ public function label(): string
public function description(): string
{
return match ($this) {
self::ORGANIZER_ORDER_NOTIFICATION => __('Sent to the organizer and opted-in team members when an order is placed'),
self::ORDER_CONFIRMATION => __('Sent to the customer after placing an order'),
self::ATTENDEE_TICKET => __('Sent to each attendee with their ticket'),
self::OCCURRENCE_CANCELLATION => __('Sent to attendees when a scheduled date is cancelled'),
Expand All @@ -31,7 +34,7 @@ public function description(): string
public function ctaUrlToken(): string
{
return match ($this) {
self::ORDER_CONFIRMATION => 'order.url',
self::ORDER_CONFIRMATION, self::ORGANIZER_ORDER_NOTIFICATION => 'order.url',
self::ATTENDEE_TICKET => 'ticket.url',
self::OCCURRENCE_CANCELLATION => 'event.url',
};
Expand Down
24 changes: 18 additions & 6 deletions backend/app/Mail/Organizer/OrderSummaryForOrganizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
use HiEvents\Mail\BaseMail;
use HiEvents\Mail\Concerns\ContainsEventContent;
use HiEvents\Mail\Concerns\ProvidesEventContent;
use HiEvents\Services\Domain\Email\DTO\RenderedEmailTemplateDTO;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Support\Str;

/**
* @uses /backend/resources/views/emails/orders/organizer/summary-for-organizer.blade.php
*/
class OrderSummaryForOrganizer extends BaseMail implements ContainsEventContent
{
use ProvidesEventContent;
Expand All @@ -24,12 +22,15 @@ class OrderSummaryForOrganizer extends BaseMail implements ContainsEventContent

private EventDomainObject $event;

public function __construct(OrderDomainObject $order, EventDomainObject $event)
private ?RenderedEmailTemplateDTO $renderedTemplate = null;

public function __construct(OrderDomainObject $order, EventDomainObject $event, ?RenderedEmailTemplateDTO $renderedTemplate = null)
{
parent::__construct();

$this->order = $order;
$this->event = $event;
$this->renderedTemplate = $renderedTemplate;
}

public function isSentToBuyers(): bool
Expand All @@ -39,12 +40,12 @@ public function isSentToBuyers(): bool

public function envelope(): Envelope
{
$subject = $this->order->getTotalGross() > 0
$subject = $this->renderedTemplate?->subject ?? ($this->order->getTotalGross() > 0
? __('New order for :amount for :event 🎉', [
'amount' => Currency::format($this->order->getTotalGross(), $this->event->getCurrency()),
'event' => Str::limit($this->event->getTitle(), 75)]
)
: __('New order for :event 🎉', ['event' => Str::limit($this->event->getTitle(), 75)]);
: __('New order for :event 🎉', ['event' => Str::limit($this->event->getTitle(), 75)]));

return new Envelope(
subject: $subject,
Expand All @@ -58,6 +59,17 @@ public function withheldEventContentReplacement(): BaseMail

public function content(): Content
{
if ($this->renderedTemplate !== null) {
return new Content(
markdown: 'emails.custom-template',
with: [
'renderedBody' => $this->renderedTemplate->body,
'renderedCta' => $this->renderedTemplate->cta,
'eventSettings' => $this->event->getEventSettings(),
],
);
}

return new Content(
markdown: 'emails.orders.organizer.summary-for-organizer',
with: [
Expand Down
22 changes: 22 additions & 0 deletions backend/app/Services/Domain/Email/EmailTemplateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ private function getValueFromDotNotation(array $array, string $key)
private function getDefaultCTAs(): array
{
return [
EmailTemplateType::ORGANIZER_ORDER_NOTIFICATION->value => [
'label' => __('View Order'),
'url_token' => 'order.url',
],
EmailTemplateType::ORDER_CONFIRMATION->value => [
'label' => __('View Order & Tickets'),
'url_token' => 'order.url',
Expand All @@ -159,6 +163,24 @@ private function getDefaultCTAs(): array
private function getDefaultTemplates(): array
{
return [
EmailTemplateType::ORGANIZER_ORDER_NOTIFICATION->value => [
'subject' => 'New order for {{ order.total }} for {{ event.title }} 🎉',
'body' => <<<'LIQUID'
<strong>You've received a new order! 🎉</strong><br>
Congratulations! You've received a new order for <strong>{{ event.title }}</strong>! Please find the details below.<br>
<br>
{% if order.is_awaiting_offline_payment %}
<strong>ℹ️ This order is pending payment.</strong> Please mark the payment as received on the order management page once payment is received.<br>
<br>
{% endif %}
<strong>Name:</strong> {{ order.first_name }} {{ order.last_name }}<br>
<strong>Email:</strong> {{ order.email }}<br>
{% if order.phone %}<strong>Mobile number:</strong> {{ order.phone }}<br>{% endif %}
<strong>Order Amount:</strong> {{ order.total }}<br>
<strong>Order ID:</strong> {{ order.number }}<br>
<strong>Order Status:</strong> {{ order.status }}<br>
LIQUID
],
EmailTemplateType::ORDER_CONFIRMATION->value => [
'subject' => '{% if order.is_awaiting_offline_payment %}Order placed: payment needed{% else %}Your Order is Confirmed! 🎉{% endif %}',
'body' => <<<'LIQUID'
Expand Down
22 changes: 21 additions & 1 deletion backend/app/Services/Domain/Email/EmailTokenContextBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,22 @@ public function buildOrderConfirmationContext(
return $context;
}

public function buildOrganizerOrderNotificationContext(
OrderDomainObject $order,
EventDomainObject $event,
): array {
$context = $this->buildOrderConfirmationContext($order, $event, $event->getOrganizer(), $event->getEventSettings());
$context['order']['url'] = sprintf(
Url::getFrontEndUrlFromConfig(Url::ORGANIZER_ORDER_SUMMARY),
$event->getId(),
$order->getId(),
);
$context['order']['phone'] = $order->getPhone() ?? '';
$context['order']['status'] = $order->getHumanReadableStatus();

return $context;
}

private function renderOfflinePaymentInstructions(array $context): string
{
$instructions = $context['settings']['offline_payment_instructions'];
Expand Down Expand Up @@ -245,13 +261,17 @@ public function buildPreviewContext(string $templateType): array
],
],
'order' => [
'url' => 'https://example.com/order/ABC123',
'url' => $templateType === 'organizer_order_notification'
? 'https://example.com/manage/event/123/orders#order-456'
: 'https://example.com/order/ABC123',
'number' => $previewOrderNumber,
'total' => '$150.00',
'date' => 'January 10, 2024',
'first_name' => 'John',
'last_name' => 'Smith',
'email' => 'john@example.com',
'phone' => '+353123456789',
'status' => __('Completed'),
'is_awaiting_offline_payment' => false,
'is_offline_payment' => false,
'payment_reference' => $previewOrderNumber,
Expand Down
23 changes: 23 additions & 0 deletions backend/app/Services/Domain/Email/MailBuilderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use HiEvents\Mail\Attendee\AttendeeTicketMail;
use HiEvents\Mail\Occurrence\OccurrenceCancellationMail;
use HiEvents\Mail\Order\OrderSummary;
use HiEvents\Mail\Organizer\OrderSummaryForOrganizer;
use HiEvents\Services\Domain\Email\DTO\RenderedEmailTemplateDTO;
use HiEvents\Services\Domain\Lineup\DTO\EmailLineupHighlightsDTO;
use HiEvents\Services\Domain\Lineup\EmailLineupHighlightsService;
Expand Down Expand Up @@ -106,6 +107,28 @@ public function buildAttendeeTicketMails(
];
}

public function buildOrganizerOrderNotificationMail(
OrderDomainObject $order,
EventDomainObject $event,
?string $locale = null,
): OrderSummaryForOrganizer {
$renderedTemplate = $this->withLocale($locale, function () use ($order, $event): ?RenderedEmailTemplateDTO {
$template = $this->emailTemplateService->getTemplateByType(
type: EmailTemplateType::ORGANIZER_ORDER_NOTIFICATION,
accountId: $event->getAccountId(),
eventId: $event->getId(),
organizerId: $event->getOrganizer()->getId(),
);

return $template === null ? null : $this->emailTemplateService->renderTemplate(
$template,
$this->tokenContextBuilder->buildOrganizerOrderNotificationContext($order, $event),
);
});

return new OrderSummaryForOrganizer($order, $event, $renderedTemplate);
}

public function buildOrderSummaryMail(
OrderDomainObject $order,
EventDomainObject $event,
Expand Down
5 changes: 2 additions & 3 deletions backend/app/Services/Domain/Mail/SendOrderDetailsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use HiEvents\DomainObjects\ProductDomainObject;
use HiEvents\DomainObjects\Status\AttendeeStatus;
use HiEvents\Mail\Order\OrderFailed;
use HiEvents\Mail\Organizer\OrderSummaryForOrganizer;
use HiEvents\Repository\Eloquent\Value\Relationship;
use HiEvents\Repository\Interfaces\EventRepositoryInterface;
use HiEvents\Repository\Interfaces\OrderRepositoryInterface;
Expand Down Expand Up @@ -163,7 +162,7 @@ private function sendOrderSummaryEmails(OrderDomainObject $order, EventDomainObj
if ($notifiesOrganizer) {
$this->mailer
->to($event->getOrganizer()->getEmail())
->send(new OrderSummaryForOrganizer($order, $event));
->send($this->mailBuilderService->buildOrganizerOrderNotificationMail($order, $event));
}

$teamRecipients = $this->teamRecipientService->recipientsFor(
Expand All @@ -175,7 +174,7 @@ private function sendOrderSummaryEmails(OrderDomainObject $order, EventDomainObj
$this->mailer
->to($user->getEmail())
->locale($user->getLocale())
->send(new OrderSummaryForOrganizer($order, $event));
->send($this->mailBuilderService->buildOrganizerOrderNotificationMail($order, $event, $user->getLocale()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ public function getAvailableTokens(EmailTemplateType $type): array
];

return match ($type) {
EmailTemplateType::ORGANIZER_ORDER_NOTIFICATION => array_merge($commonTokens, $orderTokens, [
['token' => '{{ order.phone }}', 'description' => __('Mobile number'), 'example' => '+353123456789'],
['token' => '{{ order.status }}', 'description' => __('Order Status:'), 'example' => 'Completed'],
]),
EmailTemplateType::ORDER_CONFIRMATION => array_merge($commonTokens, $orderTokens, $lineupTokens),
EmailTemplateType::ATTENDEE_TICKET => array_merge($commonTokens, $orderTokens, $attendeeTokens, $lineupTokens),
EmailTemplateType::OCCURRENCE_CANCELLATION => array_merge($commonTokens, $cancellationTokens),
Expand Down
4 changes: 3 additions & 1 deletion backend/lang/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1900,5 +1900,7 @@
"This ticket is listed for resale. Close the listing on the resale page before changing its status.": "Tato vstupenka je nabízena k dalšímu prodeji. Před změnou stavu zavřete nabídku na stránce dalšího prodeje.",
"Payment was successful, but the resale ticket in this order is no longer available. Order: :id": "Platba proběhla úspěšně, ale vstupenka z dalšího prodeje v této objednávce už není k dispozici. Objednávka: :id",
"This token was issued to a connected app and only works with the MCP server. Use an API key to call the API.": "Tento token byl vydán připojené aplikaci a funguje pouze se serverem MCP. K volání API použijte klíč API.",
"You cannot change the role, status or access of a Super Admin": "Nemůžete změnit roli, stav ani přístup superadministrátora"
"You cannot change the role, status or access of a Super Admin": "Nemůžete změnit roli, stav ani přístup superadministrátora",
"New Order Notification": "Oznámení o nové objednávce",
"Sent to the organizer and opted-in team members when an order is placed": "Odesílá se pořadateli a přihlášeným členům týmu při vytvoření objednávky"
}
4 changes: 3 additions & 1 deletion backend/lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1717,5 +1717,7 @@
"This ticket is listed for resale. Close the listing on the resale page before changing its status.": "Dieses Ticket wird zum Weiterverkauf angeboten. Schließe das Angebot auf der Weiterverkaufsseite, bevor du den Status änderst.",
"Payment was successful, but the resale ticket in this order is no longer available. Order: :id": "Die Zahlung war erfolgreich, aber das Weiterverkaufsticket in dieser Bestellung ist nicht mehr verfügbar. Bestellung: :id",
"This token was issued to a connected app and only works with the MCP server. Use an API key to call the API.": "Dieses Token wurde einer verbundenen App ausgestellt und funktioniert nur mit dem MCP-Server. Verwenden Sie einen API-Schlüssel, um die API aufzurufen.",
"You cannot change the role, status or access of a Super Admin": "Sie können die Rolle, den Status oder den Zugriff eines Super-Admins nicht ändern"
"You cannot change the role, status or access of a Super Admin": "Sie können die Rolle, den Status oder den Zugriff eines Super-Admins nicht ändern",
"New Order Notification": "Benachrichtigung über neue Bestellungen",
"Sent to the organizer and opted-in team members when an order is placed": "Wird bei einer Bestellung an den Veranstalter und Teammitglieder gesendet, die Benachrichtigungen abonniert haben"
}
4 changes: 3 additions & 1 deletion backend/lang/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -1717,5 +1717,7 @@
"This ticket is listed for resale. Close the listing on the resale page before changing its status.": "Αυτό το εισιτήριο διατίθεται για μεταπώληση. Κλείστε την αγγελία στη σελίδα μεταπώλησης πριν αλλάξετε την κατάστασή του.",
"Payment was successful, but the resale ticket in this order is no longer available. Order: :id": "Η πληρωμή ολοκληρώθηκε, αλλά το εισιτήριο μεταπώλησης αυτής της παραγγελίας δεν είναι πλέον διαθέσιμο. Παραγγελία: :id",
"This token was issued to a connected app and only works with the MCP server. Use an API key to call the API.": "Αυτό το διακριτικό εκδόθηκε σε μια συνδεδεμένη εφαρμογή και λειτουργεί μόνο με τον διακομιστή MCP. Χρησιμοποιήστε ένα κλειδί API για να καλέσετε το API.",
"You cannot change the role, status or access of a Super Admin": "Δεν μπορείτε να αλλάξετε τον ρόλο, την κατάσταση ή την πρόσβαση ενός Super Admin"
"You cannot change the role, status or access of a Super Admin": "Δεν μπορείτε να αλλάξετε τον ρόλο, την κατάσταση ή την πρόσβαση ενός Super Admin",
"New Order Notification": "Ειδοποίηση νέας παραγγελίας",
"Sent to the organizer and opted-in team members when an order is placed": "Αποστέλλεται στον διοργανωτή και στα μέλη της ομάδας που έχουν επιλέξει ειδοποιήσεις όταν γίνεται μια παραγγελία"
}
4 changes: 3 additions & 1 deletion backend/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1752,5 +1752,7 @@
"This ticket is listed for resale. Close the listing on the resale page before changing its status.": "Esta entrada está en reventa. Cierra el anuncio en la página de reventa antes de cambiar su estado.",
"Payment was successful, but the resale ticket in this order is no longer available. Order: :id": "El pago se realizó correctamente, pero la entrada de reventa de este pedido ya no está disponible. Pedido: :id",
"This token was issued to a connected app and only works with the MCP server. Use an API key to call the API.": "Este token se emitió para una aplicación conectada y solo funciona con el servidor MCP. Usa una clave de API para llamar a la API.",
"You cannot change the role, status or access of a Super Admin": "No puedes cambiar el rol, el estado ni el acceso de un superadministrador"
"You cannot change the role, status or access of a Super Admin": "No puedes cambiar el rol, el estado ni el acceso de un superadministrador",
"New Order Notification": "Notificación de nuevo pedido",
"Sent to the organizer and opted-in team members when an order is placed": "Se envía al organizador y a los miembros del equipo que han activado las notificaciones cuando se realiza un pedido"
}
4 changes: 3 additions & 1 deletion backend/lang/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1899,5 +1899,7 @@
"This ticket is listed for resale. Close the listing on the resale page before changing its status.": "Tämä lippu on jälleenmyynnissä. Sulje myynti-ilmoitus jälleenmyyntisivulla ennen tilan muuttamista.",
"Payment was successful, but the resale ticket in this order is no longer available. Order: :id": "Maksu onnistui, mutta tämän tilauksen jälleenmyyntilippu ei ole enää saatavilla. Tilaus: :id",
"This token was issued to a connected app and only works with the MCP server. Use an API key to call the API.": "Tämä tunnus on myönnetty yhdistetylle sovellukselle, ja se toimii vain MCP-palvelimen kanssa. Käytä API-avainta API-kutsuihin.",
"You cannot change the role, status or access of a Super Admin": "Et voi muuttaa pääkäyttäjän roolia, tilaa tai käyttöoikeuksia"
"You cannot change the role, status or access of a Super Admin": "Et voi muuttaa pääkäyttäjän roolia, tilaa tai käyttöoikeuksia",
"New Order Notification": "Ilmoitus uudesta tilauksesta",
"Sent to the organizer and opted-in team members when an order is placed": "Lähetetään järjestäjälle ja ilmoitukset tilanneille tiimin jäsenille, kun tilaus tehdään"
}
4 changes: 3 additions & 1 deletion backend/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1717,5 +1717,7 @@
"This ticket is listed for resale. Close the listing on the resale page before changing its status.": "Ce billet est en revente. Fermez l'annonce sur la page de revente avant de modifier son statut.",
"Payment was successful, but the resale ticket in this order is no longer available. Order: :id": "Le paiement a réussi, mais le billet en revente de cette commande n'est plus disponible. Commande : :id",
"This token was issued to a connected app and only works with the MCP server. Use an API key to call the API.": "Ce jeton a été délivré à une application connectée et ne fonctionne qu'avec le serveur MCP. Utilisez une clé API pour appeler l'API.",
"You cannot change the role, status or access of a Super Admin": "Vous ne pouvez pas modifier le rôle, le statut ou l'accès d'un super administrateur"
"You cannot change the role, status or access of a Super Admin": "Vous ne pouvez pas modifier le rôle, le statut ou l'accès d'un super administrateur",
"New Order Notification": "Notification de nouvelle commande",
"Sent to the organizer and opted-in team members when an order is placed": "Envoyée à l’organisateur et aux membres de l’équipe ayant activé les notifications lorsqu’une commande est passée"
}
Loading
Loading