PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
← All changes | app/Services/ReviewReminderService.php +16 -27 3.0.2.8 → 3.0.16 View file →
@@ -47,48 +47,37 @@
47 47 */
48 48 public static function sendReminder(int $bookingId): void
49 49 {
50 50 $bookingRepository = new \Yatra\Repositories\BookingRepository();
51 - $booking = $bookingRepository->find($bookingId);
52 -
53 - if (!$booking || empty($booking->email)) {
51 + $booking = $bookingRepository->findWithTrip($bookingId);
52 +
53 + if (!$booking || empty($booking->contact_email)) {
54 54 return;
55 55 }
56 -
56 +
57 57 // Check if customer has already reviewed
58 - if (self::hasCustomerReviewed($bookingId, $booking->customer_id)) {
58 + if (self::hasCustomerReviewed($bookingId, (int) ($booking->customer_id ?? 0))) {
59 59 return;
60 60 }
61 -
61 +
62 62 // Get trip details
63 63 $tripRepository = new \Yatra\Repositories\TripRepository();
64 - $trip = $tripRepository->find($booking->trip_id);
65 -
64 + $trip = $tripRepository->find((int) ($booking->trip_id ?? 0));
65 +
66 66 if (!$trip) {
67 67 return;
68 68 }
69 -
69 +
70 70 $review_url = get_permalink($trip->id) . '#reviews';
71 - $customerName = trim((string) (($booking->first_name ?? '') . ' ' . ($booking->last_name ?? '')));
72 - if ($customerName === '') {
73 - $customerName = __('there', 'yatra');
74 - }
75 - $tripName = (string) ($trip->title ?? '');
71 + $vars = TransactionalEmailTemplateService::variablesFromBooking($booking);
72 + $vars['review_url'] = esc_url($review_url);
73 + $vars['completion_date'] = date_i18n(get_option('date_format'));
76 74
77 - $subject = sprintf(
78 - /* translators: 1: site name, 2: trip title */
79 - __('⭐ [%1$s] How was %2$s?', 'yatra'),
80 - get_bloginfo('name'),
81 - $tripName !== '' ? $tripName : __('your trip', 'yatra')
75 + TransactionalEmailTemplateService::sendIfEnabled(
76 + TransactionalEmailTemplateService::TYPE_REVIEW_REQUEST,
77 + (string) $booking->contact_email,
78 + $vars
82 79 );
83 -
84 - $body = EmailTemplateDefaults::renderCoreReviewReminderHtml(
85 - $customerName,
86 - $tripName !== '' ? $tripName : __('your trip', 'yatra'),
87 - $review_url
88 - );
89 -
90 - EmailService::send($booking->email, $subject, $body, ['Content-Type: text/html; charset=UTF-8']);
91 80 }
92 81
93 82 /**
94 83 * Check if customer has already reviewed the trip