← All changes
|
app/Services/TransactionalEmailTemplateService.php
+24
-1
3.0.14.1
→
3.0.17
View file →
| @@ -518,14 +518,34 @@ | ||
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | $rendered = self::render($type, $variables); |
| 521 | 521 | |
| 522 | - return EmailService::send( | |
| 522 | + $sent = EmailService::send( | |
| 523 | 523 | $to, |
| 524 | 524 | $rendered['subject'], |
| 525 | 525 | $rendered['body'], |
| 526 | 526 | ['Content-Type: text/html; charset=UTF-8'] |
| 527 | 527 | ); |
| 528 | + | |
| 529 | + /** | |
| 530 | + * A transactional email core just sent. | |
| 531 | + * | |
| 532 | + * Yatra Pro writes the Email Logs, but only from its own modules — | |
| 533 | + * nothing records what core sends, so a booking confirmation or a | |
| 534 | + * review request left no trace and an operator looking for "which | |
| 535 | + * email went to this customer" found a log that quietly covered | |
| 536 | + * only part of the picture. Pro listens for this and logs it. | |
| 537 | + * | |
| 538 | + * @param string $type Template type, e.g. review_request. | |
| 539 | + * @param string $to Recipient address. | |
| 540 | + * @param string $subject Rendered subject. | |
| 541 | + * @param string $body Rendered body. | |
| 542 | + * @param bool $sent Whether wp_mail() accepted it. | |
| 543 | + * @param array<string, mixed> $variables Merge variables used to render. | |
| 544 | + */ | |
| 545 | + do_action('yatra_transactional_email_sent', $type, $to, $rendered['subject'], $rendered['body'], $sent, $variables); | |
| 546 | + | |
| 547 | + return $sent; | |
| 528 | 548 | } finally { |
| 529 | 549 | self::$dispatchingType = $previousType; |
| 530 | 550 | } |
| 531 | 551 | } |
| @@ -1004,8 +1024,11 @@ | ||
| 1004 | 1024 | 'customer_phone' => (string) ($booking->contact_phone ?? ''), |
| 1005 | 1025 | 'booking_reference' => (string) ($booking->reference ?? ''), |
| 1006 | 1026 | 'booking_id' => (string) $bookingId, |
| 1007 | 1027 | 'booking_url' => $bookingId > 0 ? home_url('/my-account/bookings/' . $bookingId) : home_url('/'), |
| 1028 | + // Trip context for per-trip template selection (Pro overrides) and | |
| 1029 | + // for {{trip_id}}; "0" when the booking has no trip. | |
| 1030 | + 'trip_id' => (string) (int) ($booking->trip_id ?? 0), | |
| 1008 | 1031 | 'trip_name' => (string) ($booking->trip_title ?? ''), |
| 1009 | 1032 | 'trip_url' => !empty($booking->trip_slug) |
| 1010 | 1033 | ? home_url('/' . SettingsService::getTripBase() . '/' . rawurlencode((string) $booking->trip_slug) . '/') |
| 1011 | 1034 | : home_url('/'), |