*/
private static function baseSamples(): array
{
$currency = SettingsService::getCurrency();
$travelSample = date_i18n(get_option('date_format'), strtotime('+14 days'));
$specialSample = __('Late check-in after 10pm if possible.', 'yatra');
return [
'customer_name' => __('Alex Traveler', 'yatra'),
'customer_first_name' => 'Alex',
'customer_last_name' => __('Traveler', 'yatra'),
'customer_email' => 'alex@example.com',
'new_email' => 'alex.new@example.com',
'customer_phone' => '+1 555 0100',
'booking_reference' => 'YTR-PREVIEW-001',
'booking_id' => '42',
'trip_id' => '101',
'trip_name' => __('Sample Mountain Trek', 'yatra'),
'travel_date' => $travelSample,
'travelers_count' => '2',
'total_amount_formatted' => yatra_format_price(2499.0, $currency),
'amount_due_formatted' => yatra_format_price(499.0, $currency),
// Aliases for the same monetary values — keep the preview
// consistent regardless of which spelling the template
// uses ({{total_amount}} vs {{total_amount_formatted}},
// {{balance_due}} vs {{amount_due_formatted}}, etc.).
'total_amount' => yatra_format_price(2499.0, $currency),
'balance_due' => yatra_format_price(499.0, $currency),
'amount_due' => yatra_format_price(499.0, $currency),
'amount_paid' => yatra_format_price(2000.0, $currency),
'amount_paid_formatted' => yatra_format_price(2000.0, $currency),
'currency' => $currency,
'booking_status' => __('confirmed', 'yatra'),
'payment_status' => __('pending', 'yatra'),
'intro_paragraph' => __('Thank you for your booking. This preview uses sample data.', 'yatra'),
'details_html' => '' . esc_html__('Note', 'yatra') . ': ' . esc_html__('Optional line items appear here.', 'yatra') . '
',
'footer_note' => __('We look forward to hosting you.', 'yatra'),
'payment_amount_formatted' => yatra_format_price(500.0, $currency),
'payment_method' => __('Credit card', 'yatra'),
'transaction_id' => 'txn_preview_001',
'reminder_days' => '7',
'days_until_trip' => '7',
'reminder_extra_html' => '' . esc_html__('Reminder: check your packing list before departure.', 'yatra') . '
',
'trip_url' => home_url('/'),
'review_url' => home_url('/#reviews'),
'admin_url' => admin_url('admin.php?page=yatra'),
'booking_url' => home_url('/my-account/bookings/42'),
'message' => __('Could you confirm whether airport pickup is included on day one?', 'yatra'),
'response' => __('Hi Alex, yes — pickup is included for all guests. Safe travels!', 'yatra'),
'original_message' => __('Interested in the April departure dates.', 'yatra'),
'expiry_policy_note' => __('Unpaid bookings are released after the deadline.', 'yatra'),
'scheduled_amount_formatted' => yatra_format_price(750.0, $currency),
'scheduled_date_formatted' => date_i18n(get_option('date_format'), strtotime('+5 days')),
'payment_type_label' => __('Installment', 'yatra'),
'scheduled_payment_id' => '9',
'balance_after_formatted' => yatra_format_price(1749.0, $currency),
'failure_reason' => __('Card declined (insufficient funds).', 'yatra'),
'failure_intro_html' => ''
. esc_html__('We could not process your scheduled payment.', 'yatra')
. '
',
'failure_followup_html' => esc_html__(
'Please update your payment method or contact us so we can retry before your booking is affected.',
'yatra'
),
'recovery_intro_html' => ''
. esc_html__('You left items in your cart — your trip is still available to book.', 'yatra')
. '
',
'recovery_reminder_label' => __('48 hours left at this price', 'yatra'),
'recovery_link' => home_url('/book/preview-recovery/'),
'payment_gateway' => 'stripe',
'payment_gateway_label' => 'Stripe',
'payment_schedule' => 'deposit',
'payment_schedule_label' => __('Deposit (balance due later)', 'yatra'),
'travelers_list' => "1. Alex Traveler (" . __('Lead', 'yatra') . ")\n2. Sam Guest",
'travelers_list_html' => ''
. '- Alex Traveler (' . esc_html__('Lead', 'yatra') . ')
'
. '- Sam Guest
',
'traveler_custom_fields_html' => ''
. '
' . esc_html__('Traveler 1 — Alex Traveler', 'yatra') . '
'
. '
'
. '| ' . esc_html__('Dietary Requirements', 'yatra') . ' | '
. '' . esc_html__('Vegetarian', 'yatra') . ' |
',
'booking_custom_fields_html' => ''
. '
' . esc_html__('Additional services', 'yatra') . '
'
. '
'
. '- ' . esc_html__('Airport transfer', 'yatra') . ' — ' . esc_html(yatra_format_price(45.0, $currency)) . '
'
. '
',
'special_requests' => $specialSample,
'special_requests_html' => nl2br(esc_html($specialSample)),
];
}
/**
* @param array $vars
* @return array
*/
private static function mergeTripContext(int $tripId, array $vars): array
{
try {
$repo = new TripRepository();
$trip = $repo->findWithRelations($tripId, true);
if ($trip && !empty($trip->id)) {
$vars['trip_id'] = (string) (int) $trip->id;
if (!empty($trip->title)) {
$vars['trip_name'] = (string) $trip->title;
}
if (!empty($trip->slug)) {
$vars['trip_url'] = home_url('/' . SettingsService::getTripBase() . '/' . rawurlencode((string) $trip->slug) . '/');
}
}
} catch (\Throwable $e) {
// Leave sample trip_* as-is
}
/** @var array */
return apply_filters('yatra_email_template_trip_variables', $vars, $tripId);
}
public static function isPreviewableTemplateKey(string $templateKey): bool
{
if (TransactionalEmailTemplateService::coreTemplateKeyToType($templateKey) !== null) {
return true;
}
return EmailTemplateDefaults::proSystemTemplate($templateKey) !== null;
}
}