PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.7
Yatra – Travel Booking & Tour Operator Software v3.0.2.7
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
yatra / templates / booking-confirmation.php

booking-confirmation.php in Yatra – Travel Booking & Tour Operator Software 3.0.2.7, at templates/booking-confirmation.php

1,088 lines 46.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Booking Confirmation Template
4 *
5 * Displays booking confirmation after successful booking
6 *
7 * @package Yatra
8 *
9 * Global variables available:
10 * - $booking_data or $GLOBALS['yatra_booking']
11 */
12
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 // Get booking data
18 $booking = $GLOBALS['yatra_booking'] ?? null;
19
20 if (!$booking) {
21 wp_safe_redirect(home_url('/'));
22 exit;
23 }
24
25 // Completed booking: ensure checkout session and its transient cannot repopulate the booking form.
26 if (function_exists('yatra_clear_booking_session')) {
27 yatra_clear_booking_session();
28 }
29
30 // Format dates
31 $travel_date_formatted = \Yatra\Helpers\FormatHelper::formatDate((string) ($booking->travel_date ?? ''));
32 $booking_date_formatted = \Yatra\Helpers\FormatHelper::formatDateTime((string) ($booking->created_at ?? ''));
33
34 // Get status color
35 $status_colors = [
36 'pending' => ['bg' => '#fef3c7', 'text' => '#d97706', 'label' => 'Pending'],
37 'confirmed' => ['bg' => '#d1fae5', 'text' => '#059669', 'label' => 'Confirmed'],
38 'processing' => ['bg' => '#dbeafe', 'text' => '#2563eb', 'label' => 'Processing'],
39 'completed' => ['bg' => '#d1fae5', 'text' => '#059669', 'label' => 'Completed'],
40 'cancelled' => ['bg' => '#fee2e2', 'text' => '#dc2626', 'label' => 'Cancelled'],
41 'refunded' => ['bg' => '#fce7f3', 'text' => '#db2777', 'label' => 'Refunded'],
42 'on_hold' => ['bg' => '#e5e7eb', 'text' => '#6b7280', 'label' => 'On Hold'],
43 ];
44
45 $status_style = $status_colors[$booking->status] ?? $status_colors['pending'];
46
47 yatra_get_header();
48
49 // Hook for Pro modules to add custom scripts (Facebook Pixel, etc.)
50 do_action('yatra_booking_confirmation_header', $booking);
51 ?>
52
53 <div class="yatra-wrapper yatra-confirmation-wrapper">
54 <div class="yatra-confirmation-container">
55
56 <!-- Success Header -->
57 <div class="yatra-confirmation-header">
58 <div class="yatra-confirmation-icon">
59 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
60 <circle cx="12" cy="12" r="10"></circle>
61 <polyline points="9,12 12,15 16,10"></polyline>
62 </svg>
63 </div>
64 <h1 class="yatra-confirmation-title">
65 <?php
66 if ($booking->status === 'confirmed') {
67 esc_html_e('Booking Confirmed!', 'yatra');
68 } elseif ($booking->status === 'pending') {
69 esc_html_e('Booking Received!', 'yatra');
70 } elseif ($booking->status === 'cancelled') {
71 esc_html_e('Booking Cancelled', 'yatra');
72 } else {
73 esc_html_e('Booking Submitted!', 'yatra');
74 }
75 ?>
76 </h1>
77 <p class="yatra-confirmation-subtitle">
78 <?php
79 if ($booking->status === 'confirmed') {
80 esc_html_e('Thank you for your booking. We look forward to hosting you!', 'yatra');
81 } elseif ($booking->status === 'pending') {
82 esc_html_e('Thank you for your booking. Your booking is pending confirmation.', 'yatra');
83 } elseif ($booking->status === 'cancelled') {
84 esc_html_e('This booking has been cancelled.', 'yatra');
85 } else {
86 esc_html_e('Thank you for your booking submission.', 'yatra');
87 }
88 ?>
89 </p>
90 <div class="yatra-confirmation-reference">
91 <span class="yatra-ref-label"><?php esc_html_e('Booking Reference:', 'yatra'); ?></span>
92 <span class="yatra-ref-code"><?php echo esc_html($booking->reference); ?></span>
93 </div>
94 </div>
95
96 <?php
97 // Resolve featured image URL (handle attachment ID or direct URL)
98 $featured_image_url = '';
99 if (!empty($booking->featured_image)) {
100 if (is_numeric($booking->featured_image)) {
101 $featured_image_url = wp_get_attachment_url((int) $booking->featured_image) ?: '';
102 } else {
103 $featured_image_url = $booking->featured_image;
104 }
105 }
106 ?>
107
108 <div class="yatra-confirmation-content">
109 <!-- Trip Summary Card -->
110 <div class="yatra-confirmation-card yatra-trip-summary-card">
111 <div class="yatra-trip-summary">
112 <?php if (!empty($featured_image_url)) : ?>
113 <div class="yatra-trip-image">
114 <img src="<?php echo esc_url($featured_image_url); ?>" alt="<?php echo esc_attr($booking->trip_title); ?>">
115 </div>
116 <?php endif; ?>
117
118 <div class="yatra-trip-info">
119 <h2 class="yatra-trip-name"><?php echo esc_html($booking->trip_title); ?></h2>
120
121 <?php if (!empty($booking->trip_average_rating) && $booking->trip_review_count >= 0) : ?>
122 <div class="yatra-trip-rating">
123 <div class="yatra-rating-stars">
124 <?php
125 $filled_stars = floor($booking->trip_average_rating);
126 $has_half = ($booking->trip_average_rating - $filled_stars) >= 0.5;
127 for ($i = 1; $i <= 5; $i++) :
128 $class = $i <= $filled_stars ? 'yatra-star-filled' : ($has_half && $i === $filled_stars + 1 ? 'yatra-star-half' : '');
129 ?>
130 <span class="yatra-star <?php echo esc_attr($class); ?>">
131 <svg viewBox="0 0 24 24" fill="currentColor"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26"></polygon></svg>
132 </span>
133 <?php endfor; ?>
134 </div>
135 <div class="yatra-rating-meta">
136 <strong><?php echo esc_html(number_format($booking->trip_average_rating, 1)); ?></strong>
137 <span>
138 <?php
139 /* translators: %d review count */
140 printf(esc_html(_n('%d Review', '%d Reviews', (int) $booking->trip_review_count, 'yatra')), (int) $booking->trip_review_count);
141 ?>
142 </span>
143 </div>
144 </div>
145 <?php endif; ?>
146
147 <div class="yatra-trip-meta">
148 <?php if (!empty($booking->duration_days)) : ?>
149 <span class="yatra-meta-item">
150 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
151 <circle cx="12" cy="12" r="10"></circle>
152 <polyline points="12 6 12 12 16 14"></polyline>
153 </svg>
154 <?php printf(esc_html__('%d Days / %d Nights', 'yatra'), (int) $booking->duration_days, (int) $booking->duration_nights); ?>
155 </span>
156 <?php endif; ?>
157
158 <?php if (!empty($booking->difficulty_level)) : ?>
159 <span class="yatra-meta-item">
160 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
161 <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>
162 </svg>
163 <?php echo esc_html(ucfirst($booking->difficulty_level)); ?>
164 </span>
165 <?php endif; ?>
166 </div>
167
168 <?php if (!empty($booking->starting_location)) : ?>
169 <p class="yatra-trip-location">
170 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
171 <path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path>
172 <circle cx="12" cy="10" r="3"></circle>
173 </svg>
174 <?php echo esc_html($booking->starting_location); ?>
175 <?php if (!empty($booking->ending_location) && $booking->ending_location !== $booking->starting_location) : ?>
176 → <?php echo esc_html($booking->ending_location); ?>
177 <?php endif; ?>
178 </p>
179 <?php endif; ?>
180
181 <?php if (!empty($booking->trip_destinations_list)) : ?>
182 <div class="yatra-trip-tags">
183 <span class="yatra-tag-label"><?php esc_html_e('Destinations:', 'yatra'); ?></span>
184 <div class="yatra-tag-group">
185 <?php foreach ($booking->trip_destinations_list as $destination) : ?>
186 <span class="yatra-tag-item"><?php echo esc_html($destination); ?></span>
187 <?php endforeach; ?>
188 </div>
189 </div>
190 <?php endif; ?>
191
192 <?php if (!empty($booking->trip_activities_list)) : ?>
193 <div class="yatra-trip-tags">
194 <span class="yatra-tag-label"><?php esc_html_e('Activities:', 'yatra'); ?></span>
195 <div class="yatra-tag-group">
196 <?php foreach ($booking->trip_activities_list as $activity) : ?>
197 <span class="yatra-tag-item"><?php echo esc_html($activity); ?></span>
198 <?php endforeach; ?>
199 </div>
200 </div>
201 <?php endif; ?>
202
203 <?php if (!empty($booking->trip_categories_list)) : ?>
204 <div class="yatra-trip-tags">
205 <span class="yatra-tag-label"><?php esc_html_e('Trip Type:', 'yatra'); ?></span>
206 <div class="yatra-tag-group">
207 <?php foreach ($booking->trip_categories_list as $category) : ?>
208 <span class="yatra-tag-item"><?php echo esc_html($category); ?></span>
209 <?php endforeach; ?>
210 </div>
211 </div>
212 <?php endif; ?>
213
214 <?php if (!empty($booking->trip_attributes_list)) : ?>
215 <div class="yatra-trip-tags">
216 <span class="yatra-tag-label"><?php esc_html_e('Features:', 'yatra'); ?></span>
217 <div class="yatra-tag-group">
218 <?php foreach ($booking->trip_attributes_list as $attribute) : ?>
219 <span class="yatra-tag-item yatra-attribute-tag"><?php echo esc_html($attribute); ?></span>
220 <?php endforeach; ?>
221 </div>
222 </div>
223 <?php endif; ?>
224 </div>
225 </div>
226 </div>
227
228 <!-- Booking Details -->
229 <div class="yatra-confirmation-grid">
230 <!-- Left Column -->
231 <div class="yatra-confirmation-column">
232 <!-- Booking Info Card -->
233 <div class="yatra-confirmation-card">
234 <h3 class="yatra-card-title">
235 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
236 <rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
237 <line x1="16" y1="2" x2="16" y2="6"></line>
238 <line x1="8" y1="2" x2="8" y2="6"></line>
239 <line x1="3" y1="10" x2="21" y2="10"></line>
240 </svg>
241 <?php esc_html_e('Booking Information', 'yatra'); ?>
242 </h3>
243
244 <div class="yatra-info-grid">
245 <div class="yatra-info-item">
246 <span class="yatra-info-label"><?php esc_html_e('Status', 'yatra'); ?></span>
247 <span class="yatra-info-value">
248 <span class="yatra-status-badge" style="background: <?php echo esc_attr($status_style['bg']); ?>; color: <?php echo esc_attr($status_style['text']); ?>;">
249 <?php echo esc_html($status_style['label']); ?>
250 </span>
251 </span>
252 </div>
253 <div class="yatra-info-item">
254 <span class="yatra-info-label"><?php esc_html_e('Travel Date', 'yatra'); ?></span>
255 <span class="yatra-info-value"><?php echo esc_html($travel_date_formatted); ?></span>
256 </div>
257 <div class="yatra-info-item">
258 <span class="yatra-info-label"><?php esc_html_e('Number of Travelers', 'yatra'); ?></span>
259 <span class="yatra-info-value"><?php echo esc_html($booking->travelers_count); ?></span>
260 </div>
261 <div class="yatra-info-item">
262 <span class="yatra-info-label"><?php esc_html_e('Booked On', 'yatra'); ?></span>
263 <span class="yatra-info-value"><?php echo esc_html($booking_date_formatted); ?></span>
264 </div>
265 </div>
266 </div>
267
268 <!-- Travelers Card -->
269 <?php if (!empty($booking->travelers)) : ?>
270 <div class="yatra-confirmation-card">
271 <h3 class="yatra-card-title">
272 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
273 <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
274 <circle cx="9" cy="7" r="4"></circle>
275 <path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
276 <path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
277 </svg>
278 <?php esc_html_e('Travelers', 'yatra'); ?>
279 </h3>
280
281 <div class="yatra-travelers-list">
282 <?php foreach ($booking->travelers as $index => $traveler) :
283 $traveler_name = trim(($traveler['first_name'] ?? '') . ' ' . ($traveler['last_name'] ?? ''));
284 ?>
285 <div class="yatra-traveler-item">
286 <span class="yatra-traveler-number"><?php echo esc_html($index + 1); ?></span>
287 <div class="yatra-traveler-details">
288 <span class="yatra-traveler-name">
289 <?php echo esc_html($traveler_name ?: __('Traveler', 'yatra') . ' ' . ($index + 1)); ?>
290 </span>
291 <?php if (!empty($traveler['date_of_birth'])) : ?>
292 <span class="yatra-traveler-dob">
293 <?php echo esc_html(\Yatra\Helpers\FormatHelper::formatDate((string) $traveler['date_of_birth'])); ?>
294 </span>
295 <?php endif; ?>
296 </div>
297 </div>
298 <?php endforeach; ?>
299 </div>
300 </div>
301 <?php endif; ?>
302
303 <?php
304 // Allow gateways to inject cards (e.g., Bank Transfer instructions)
305 do_action('yatra_booking_confirmation_after_details', $booking);
306 ?>
307 </div>
308
309 <!-- Right Column -->
310 <div class="yatra-confirmation-column">
311 <!-- Payment Summary Card -->
312 <div class="yatra-confirmation-card yatra-payment-card">
313 <h3 class="yatra-card-title">
314 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
315 <rect x="1" y="4" width="22" height="16" rx="2" ry="2"></rect>
316 <line x1="1" y1="10" x2="23" y2="10"></line>
317 </svg>
318 <?php esc_html_e('Payment Summary', 'yatra'); ?>
319 </h3>
320
321 <div class="yatra-payment-rows">
322 <?php
323 // ── Raw figures from DB ───────────────────────────────────
324 $db_subtotal = (float) ($booking->subtotal ?? $booking->total_amount);
325 $discount_amount = (float) ($booking->discount_amount ?? 0);
326 $itinerary_costs_total = (float) ($booking->itinerary_costs_total ?? 0);
327 $tax_amount = (float) ($booking->tax_amount ?? 0);
328 $tax_inclusive = !empty($booking->tax_inclusive);
329 $total_amount = (float) $booking->total_amount;
330 $amount_paid = (float) ($booking->amount_paid ?? 0);
331 $amount_due = (float) ($booking->amount_due ?? 0);
332
333 // ── Tax breakdown (built first so it can gate later rows) ─
334 $tax_breakdown = [];
335 if (!empty($booking->tax_details)) {
336 $taxes = json_decode($booking->tax_details, true) ?: [];
337 foreach ($taxes as $tax) {
338 $tax_breakdown[] = [
339 'name' => $tax['name'] ?? __('Tax', 'yatra'),
340 'rate' => (float) ($tax['rate'] ?? 0),
341 'amount' => (float) ($tax['amount'] ?? 0),
342 ];
343 }
344 } elseif ($tax_amount > 0) {
345 $tax_breakdown[] = [
346 'name' => __('Tax', 'yatra'),
347 'rate' => (float) ($booking->tax_rate ?? 0),
348 'amount' => $tax_amount,
349 ];
350 }
351
352 // ── Itinerary costs ───────────────────────────────────────
353 $itinerary_costs = [];
354 if (!empty($booking->itinerary_costs)) {
355 $itinerary_costs = json_decode($booking->itinerary_costs, true) ?: [];
356 }
357
358 // ── Additional services ───────────────────────────────────
359 $raw_services = apply_filters('yatra_booking_get_services', [], (int) ($booking->id ?? 0));
360 $selected_services = [];
361 if (!empty($raw_services) && is_array($raw_services)) {
362 foreach ($raw_services as $s) {
363 $arr = is_array($s) ? $s : (array) $s;
364 if (!isset($arr['selected']) || !empty($arr['selected'])) {
365 $selected_services[] = $arr;
366 }
367 }
368 }
369 $services_total = 0.0;
370 foreach ($selected_services as $s) {
371 $services_total += (float) ($s['total_price'] ?? $s['calculated_price'] ?? $s['total_cost'] ?? $s['amount'] ?? $s['unit_price'] ?? $s['price'] ?? 0);
372 }
373
374 // ── Derived amounts ───────────────────────────────────────
375 // base_trip_cost: the trip price without services (services are embedded in db_subtotal by Pro)
376 $base_trip_cost = $db_subtotal - $services_total;
377 // taxable_amount: what tax is calculated on
378 $taxable_amount = max(0.0, $db_subtotal - $discount_amount) + $itinerary_costs_total;
379
380 $has_services = !empty($selected_services);
381 $has_discount = $discount_amount > 0;
382 $has_itinerary = !empty($itinerary_costs) && $itinerary_costs_total > 0;
383 $has_tax = !empty($tax_breakdown);
384 $show_taxable_row = $has_tax && ($has_discount || $has_itinerary);
385 ?>
386
387 <!-- Trip Base Price (always the first line) -->
388 <div class="yatra-payment-row">
389 <span>
390 <?php esc_html_e('Trip Base Price', 'yatra'); ?>
391 <?php if ($tax_inclusive): ?>
392 <span style="display:inline-flex;align-items:center;padding:1px 6px;border-radius:4px;font-size:0.72em;font-weight:600;background:#eff6ff;color:#1d4ed8;margin-left:5px;letter-spacing:0;">
393 <?php esc_html_e('Tax Incl.', 'yatra'); ?>
394 </span>
395 <?php endif; ?>
396 </span>
397 <span><?php echo esc_html(yatra_format_price($base_trip_cost, $booking->currency)); ?></span>
398 </div>
399
400 <?php if ($has_services): ?>
401 <!-- Additional Services section header -->
402 <div class="yatra-payment-row" style="margin-top: 4px;">
403 <span style="font-size: 0.75em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280;">
404 + <?php esc_html_e('Additional Services', 'yatra'); ?>
405 </span>
406 <span></span>
407 </div>
408 <!-- Service line items -->
409 <?php foreach ($selected_services as $svc): ?>
410 <?php
411 $svc_name = $svc['service_name'] ?? $svc['name'] ?? $svc['title'] ?? $svc['label'] ?? __('Service', 'yatra');
412 $svc_amount = (float) ($svc['total_price'] ?? $svc['calculated_price'] ?? $svc['total_cost'] ?? $svc['amount'] ?? $svc['unit_price'] ?? $svc['price'] ?? 0);
413 ?>
414 <div class="yatra-payment-row" style="margin-left: 16px;">
415 <span><?php echo esc_html($svc_name); ?></span>
416 <span><?php echo esc_html(yatra_format_price($svc_amount, $booking->currency, false)); ?></span>
417 </div>
418 <?php endforeach; ?>
419 <!-- Gross Total = Trip Base Price + Services -->
420 <div class="yatra-payment-row" style="border-top: 1px solid #e5e7eb; margin-top: 6px; padding-top: 6px;">
421 <span><strong><?php esc_html_e('Gross Total', 'yatra'); ?></strong></span>
422 <span><strong><?php echo esc_html(yatra_format_price($db_subtotal, $booking->currency)); ?></strong></span>
423 </div>
424 <?php endif; ?>
425
426 <?php if ($has_discount): ?>
427 <!-- Discount -->
428 <div class="yatra-payment-row">
429 <span><?php esc_html_e('Discount', 'yatra'); ?></span>
430 <span style="color: #059669; font-weight: 500;">-<?php echo esc_html(yatra_format_price($discount_amount, $booking->currency)); ?></span>
431 </div>
432 <?php endif; ?>
433
434 <?php if ($has_itinerary): ?>
435 <!-- Itinerary costs header -->
436 <div class="yatra-payment-row" style="margin-top: 4px;">
437 <span><strong><?php esc_html_e('Itinerary Costs', 'yatra'); ?></strong></span>
438 <span></span>
439 </div>
440 <?php foreach ($itinerary_costs as $cost): ?>
441 <div class="yatra-payment-row" style="margin-left: 20px;">
442 <span>
443 <?php echo esc_html($cost['name']); ?>
444 <?php if (!empty($cost['price_per'])): ?>
445 <small style="opacity: 0.65;">
446 <?php
447 if ($cost['price_per'] === 'person') {
448 esc_html_e('(per person)', 'yatra');
449 } elseif ($cost['price_per'] === 'group') {
450 esc_html_e('(per booking)', 'yatra');
451 } else {
452 esc_html_e('(flat rate)', 'yatra');
453 }
454 ?>
455 </small>
456 <?php endif; ?>
457 </span>
458 <span><?php echo esc_html(yatra_format_price($cost['total_cost'] ?? $cost['price'], $booking->currency)); ?></span>
459 </div>
460 <?php endforeach; ?>
461 <?php endif; ?>
462
463 <?php if (!$tax_inclusive && $show_taxable_row): ?>
464 <!-- Taxable Amount (only for exclusive tax when there are deductions above it) -->
465 <div class="yatra-payment-row" style="border-top: 1px dashed #e5e7eb; margin-top: 8px; padding-top: 8px;">
466 <span><strong><?php esc_html_e('Taxable Amount', 'yatra'); ?></strong></span>
467 <span><strong><?php echo esc_html(yatra_format_price($taxable_amount, $booking->currency)); ?></strong></span>
468 </div>
469 <?php endif; ?>
470
471 <?php if ($has_tax && !$tax_inclusive): ?>
472 <!-- Exclusive tax: shown as an addition before Net Amount -->
473 <div class="yatra-payment-row" style="margin-top: 4px;">
474 <span style="font-size: 0.75em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #6b7280;">
475 + <?php esc_html_e('Tax', 'yatra'); ?>
476 </span>
477 <span></span>
478 </div>
479 <?php foreach ($tax_breakdown as $tax): ?>
480 <div class="yatra-payment-row" style="margin-left: 16px;">
481 <span>
482 <?php echo esc_html($tax['name']); ?>
483 <?php if ($tax['rate'] > 0): ?>
484 (<?php echo esc_html($tax['rate']); ?>%)
485 <?php endif; ?>
486 </span>
487 <span>+<?php echo esc_html(yatra_format_price($tax['amount'], $booking->currency)); ?></span>
488 </div>
489 <?php endforeach; ?>
490 <?php endif; ?>
491
492 <!-- Net Amount -->
493 <div class="yatra-payment-row" style="border-top: 2px solid #111827; margin-top: 10px; padding-top: 10px;">
494 <span style="font-size: 1.05em;"><strong><?php esc_html_e('Net Amount', 'yatra'); ?></strong></span>
495 <span style="font-size: 1.05em;"><strong><?php echo esc_html(yatra_format_price($total_amount, $booking->currency)); ?></strong></span>
496 </div>
497
498 <?php if ($has_tax && $tax_inclusive): ?>
499 <!-- Inclusive tax: shown as an informational footnote after Net Amount -->
500 <?php foreach ($tax_breakdown as $tax): ?>
501 <div class="yatra-payment-row" style="margin-top: 4px; opacity: 0.7;">
502 <span style="font-size: 0.85em; font-style: italic;">
503 <?php
504 printf(
505 /* translators: %1$s = tax name, %2$s = rate, %3$s = amount */
506 esc_html__('Incl. %1$s%2$s: %3$s', 'yatra'),
507 esc_html($tax['name']),
508 $tax['rate'] > 0 ? ' (' . esc_html($tax['rate']) . '%)' : '',
509 esc_html(yatra_format_price($tax['amount'], $booking->currency))
510 );
511 ?>
512 </span>
513 <span></span>
514 </div>
515 <?php endforeach; ?>
516 <?php endif; ?>
517
518 <?php if ($amount_paid > 0): ?>
519 <div class="yatra-payment-row" style="margin-top: 6px;">
520 <span><?php esc_html_e('Amount Paid', 'yatra'); ?></span>
521 <span style="color: #059669;"><?php echo esc_html(yatra_format_price($amount_paid, $booking->currency)); ?></span>
522 </div>
523 <?php endif; ?>
524
525 <?php if ($amount_due > 0): ?>
526 <div class="yatra-payment-row yatra-due-row">
527 <span><strong><?php esc_html_e('Due Now', 'yatra'); ?></strong></span>
528 <span><strong><?php echo esc_html(yatra_format_price($amount_due, $booking->currency)); ?></strong></span>
529 </div>
530 <?php endif; ?>
531 </div>
532
533 <div class="yatra-payment-method">
534 <span class="yatra-pm-label"><?php esc_html_e('Payment Method:', 'yatra'); ?></span>
535 <span class="yatra-pm-value"><?php echo esc_html(ucwords(str_replace('_', ' ', $booking->payment_gateway))); ?></span>
536 </div>
537 </div>
538
539 <!-- Contact Info Card -->
540 <div class="yatra-confirmation-card">
541 <h3 class="yatra-card-title">
542 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
543 <path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path>
544 <polyline points="22,6 12,13 2,6"></polyline>
545 </svg>
546 <?php esc_html_e('Contact Information', 'yatra'); ?>
547 </h3>
548
549 <div class="yatra-contact-info">
550 <?php
551 // Try to get contact data from multiple sources
552 $contact_data = [];
553 if (!empty($booking->contact_data)) {
554 $contact_data = json_decode($booking->contact_data, true) ?: [];
555 }
556
557 $contact_name = trim((
558 $contact_data['first_name'] ??
559 $booking->contact_first_name ??
560 ($booking->contact['first_name'] ?? '')
561 ) . ' ' . (
562 $contact_data['last_name'] ??
563 $booking->contact_last_name ??
564 ($booking->contact['last_name'] ?? '')
565 ));
566
567 $contact_email = $contact_data['email'] ?? $booking->contact_email ?? ($booking->contact['email'] ?? '');
568 $contact_phone = $contact_data['phone'] ?? $booking->contact_phone ?? ($booking->contact['phone'] ?? '');
569 ?>
570
571 <?php if ($contact_name) : ?>
572 <p class="yatra-contact-item">
573 <strong><?php esc_html_e('Name:', 'yatra'); ?></strong>
574 <?php echo esc_html($contact_name); ?>
575 </p>
576 <?php endif; ?>
577
578 <?php if ($contact_email) : ?>
579 <p class="yatra-contact-item">
580 <strong><?php esc_html_e('Email:', 'yatra'); ?></strong>
581 <?php echo esc_html($contact_email); ?>
582 </p>
583 <?php endif; ?>
584
585 <?php if ($contact_phone) : ?>
586 <p class="yatra-contact-item">
587 <strong><?php esc_html_e('Phone:', 'yatra'); ?></strong>
588 <?php echo esc_html($contact_phone); ?>
589 </p>
590 <?php endif; ?>
591
592 <?php if (!$contact_name && !$contact_email && !$contact_phone) : ?>
593 <p class="yatra-contact-item">
594 <em><?php esc_html_e('Contact information not available', 'yatra'); ?></em>
595 </p>
596 <?php endif; ?>
597 </div>
598 </div>
599 </div>
600 </div>
601
602 <!-- What's Next Section -->
603 <div class="yatra-confirmation-card yatra-whats-next">
604 <h3 class="yatra-card-title">
605 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
606 <circle cx="12" cy="12" r="10"></circle>
607 <polyline points="12 16 16 12 12 8"></polyline>
608 <line x1="8" y1="12" x2="16" y2="12"></line>
609 </svg>
610 <?php esc_html_e("What's Next?", 'yatra'); ?>
611 </h3>
612
613 <div class="yatra-next-steps">
614 <div class="yatra-step">
615 <span class="yatra-step-number">1</span>
616 <div class="yatra-step-content">
617 <h4><?php esc_html_e('Check Your Email', 'yatra'); ?></h4>
618 <p><?php esc_html_e('We\'ve sent a confirmation email with all the details to your registered email address.', 'yatra'); ?></p>
619 </div>
620 </div>
621
622 <div class="yatra-step">
623 <span class="yatra-step-number">2</span>
624 <div class="yatra-step-content">
625 <h4><?php esc_html_e('Detailed Itinerary', 'yatra'); ?></h4>
626 <p><?php esc_html_e('You\'ll receive a detailed itinerary and preparation guide within 24-48 hours.', 'yatra'); ?></p>
627 </div>
628 </div>
629
630 <div class="yatra-step">
631 <span class="yatra-step-number">3</span>
632 <div class="yatra-step-content">
633 <h4><?php esc_html_e('Prepare for Adventure', 'yatra'); ?></h4>
634 <p><?php esc_html_e('Ensure all travelers have valid ID or travel documents and any required visas for your destination.', 'yatra'); ?></p>
635 </div>
636 </div>
637 </div>
638 </div>
639
640 <!-- Action Buttons -->
641 <div class="yatra-confirmation-actions">
642 <a href="<?php echo esc_url(home_url('/')); ?>" class="yatra-btn yatra-btn-secondary">
643 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
644 <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
645 <polyline points="9 22 9 12 15 12 15 22"></polyline>
646 </svg>
647 <?php esc_html_e('Return to Home', 'yatra'); ?>
648 </a>
649
650 <?php
651 // Get latest payment for this booking to enable invoice download
652 $paymentRepository = new \Yatra\Repositories\PaymentRepository();
653 $latestPayment = $paymentRepository->findLatestByBookingId((int) $booking->id);
654 if ($latestPayment && in_array($latestPayment->status, ['completed', 'paid'], true)) :
655 ?>
656 <a href="<?php echo esc_url(rest_url('yatra/v1/payment/' . $latestPayment->id . '/invoice')); ?>"
657 target="_blank"
658 class="yatra-btn yatra-btn-primary">
659 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
660 <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
661 <polyline points="7 10 12 15 17 10"></polyline>
662 <line x1="12" y1="15" x2="12" y2="3"></line>
663 </svg>
664 <?php esc_html_e('Download Invoice', 'yatra'); ?>
665 </a>
666 <?php endif; ?>
667
668 <button onclick="window.print();" class="yatra-btn yatra-btn-outline">
669 <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
670 <polyline points="6 9 6 2 18 2 18 9"></polyline>
671 <path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"></path>
672 <rect x="6" y="14" width="12" height="8"></rect>
673 </svg>
674 <?php esc_html_e('Print Confirmation', 'yatra'); ?>
675 </button>
676 </div>
677
678 </div>
679 </div>
680 </div>
681
682 <style>
683 /* Confirmation Page Styles */
684 .yatra-confirmation-wrapper {
685 max-width: 1300px;
686 margin: 0 auto;
687 padding: 40px 20px;
688 }
689
690 .yatra-confirmation-container {
691 max-width: 900px;
692 margin: 0 auto;
693 }
694
695 .yatra-confirmation-header {
696 text-align: center;
697 margin-bottom: 40px;
698 }
699
700 .yatra-confirmation-icon {
701 width: 100px;
702 height: 100px;
703 margin: 0 auto 24px;
704 background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
705 border-radius: 50%;
706 display: flex;
707 align-items: center;
708 justify-content: center;
709 animation: scaleIn 0.5s ease-out;
710 }
711
712 .yatra-confirmation-icon svg {
713 width: 50px;
714 height: 50px;
715 color: white;
716 }
717
718 @keyframes scaleIn {
719 0% { transform: scale(0); opacity: 0; }
720 50% { transform: scale(1.1); }
721 100% { transform: scale(1); opacity: 1; }
722 }
723
724 .yatra-confirmation-title {
725 font-size: 36px;
726 font-weight: 700;
727 color: #111827;
728 margin: 0 0 12px;
729 }
730
731 .yatra-confirmation-subtitle {
732 font-size: 18px;
733 color: #6b7280;
734 margin: 0 0 24px;
735 }
736
737 .yatra-confirmation-reference {
738 display: inline-flex;
739 align-items: center;
740 gap: 12px;
741 background: #f3f4f6;
742 padding: 12px 24px;
743 border-radius: 100px;
744 }
745
746 .yatra-ref-label {
747 color: #6b7280;
748 font-size: 14px;
749 }
750
751 .yatra-ref-code {
752 font-size: 18px;
753 font-weight: 700;
754 color: #111827;
755 font-family: monospace;
756 letter-spacing: 1px;
757 }
758
759 .yatra-confirmation-card {
760 background: #fff;
761 border: 1px solid #e5e7eb;
762 border-radius: 16px;
763 padding: 24px;
764 margin-bottom: 24px;
765 }
766
767 .yatra-card-title {
768 display: flex;
769 align-items: center;
770 gap: 12px;
771 font-size: 18px;
772 font-weight: 600;
773 color: #111827;
774 margin: 0 0 20px;
775 padding-bottom: 16px;
776 border-bottom: 1px solid #e5e7eb;
777 }
778
779 .yatra-card-title svg {
780 width: 22px;
781 height: 22px;
782 color: #3b82f6;
783 }
784
785 .yatra-trip-summary-card {
786 background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
787 border-color: #bfdbfe;
788 }
789
790 .yatra-trip-summary {
791 display: flex;
792 gap: 24px;
793 align-items: center;
794 }
795
796 .yatra-trip-image {
797 width: 120px;
798 height: 120px;
799 border-radius: 12px;
800 overflow: hidden;
801 flex-shrink: 0;
802 }
803
804 .yatra-trip-image img {
805 width: 100%;
806 height: 100%;
807 object-fit: cover;
808 }
809
810 .yatra-trip-name {
811 font-size: 22px;
812 font-weight: 700;
813 color: #111827;
814 margin: 0 0 12px;
815 }
816
817 .yatra-trip-meta {
818 display: flex;
819 gap: 20px;
820 flex-wrap: wrap;
821 margin-bottom: 8px;
822 }
823
824 .yatra-meta-item {
825 display: flex;
826 align-items: center;
827 gap: 6px;
828 font-size: 14px;
829 color: #4b5563;
830 }
831
832 .yatra-meta-item svg {
833 width: 16px;
834 height: 16px;
835 }
836
837 .yatra-trip-location {
838 display: flex;
839 align-items: center;
840 gap: 6px;
841 font-size: 14px;
842 color: #6b7280;
843 margin: 0;
844 }
845
846 .yatra-trip-location svg {
847 width: 16px;
848 height: 16px;
849 }
850
851 .yatra-confirmation-grid {
852 display: grid;
853 grid-template-columns: 1fr 1fr;
854 gap: 24px;
855 }
856
857 @media (max-width: 768px) {
858 .yatra-confirmation-grid {
859 grid-template-columns: 1fr;
860 }
861
862 .yatra-trip-summary {
863 flex-direction: column;
864 text-align: center;
865 }
866 }
867
868 .yatra-info-grid {
869 display: grid;
870 grid-template-columns: 1fr 1fr;
871 gap: 16px;
872 }
873
874 .yatra-info-item {
875 display: flex;
876 flex-direction: column;
877 gap: 4px;
878 }
879
880 .yatra-info-label {
881 font-size: 13px;
882 color: #6b7280;
883 }
884
885 .yatra-info-value {
886 font-size: 15px;
887 font-weight: 600;
888 color: #111827;
889 }
890
891 .yatra-status-badge {
892 display: inline-block;
893 padding: 4px 12px;
894 border-radius: 100px;
895 font-size: 13px;
896 font-weight: 600;
897 }
898
899 .yatra-travelers-list {
900 display: flex;
901 flex-direction: column;
902 gap: 12px;
903 }
904
905 .yatra-traveler-item {
906 display: flex;
907 align-items: center;
908 gap: 12px;
909 padding: 12px;
910 background: #f9fafb;
911 border-radius: 8px;
912 }
913
914 .yatra-traveler-number {
915 width: 28px;
916 height: 28px;
917 display: flex;
918 align-items: center;
919 justify-content: center;
920 background: #3b82f6;
921 color: white;
922 border-radius: 50%;
923 font-size: 13px;
924 font-weight: 600;
925 }
926
927 .yatra-traveler-name {
928 font-weight: 600;
929 color: #111827;
930 }
931
932 .yatra-traveler-dob {
933 font-size: 13px;
934 color: #6b7280;
935 }
936
937 .yatra-payment-card {
938 background: #fafafa;
939 }
940
941 .yatra-payment-rows {
942 border: 1px solid #e5e7eb;
943 border-radius: 8px;
944 overflow: hidden;
945 }
946
947 .yatra-payment-row {
948 display: flex;
949 justify-content: space-between;
950 padding: 12px 16px;
951 border-bottom: 1px solid #e5e7eb;
952 }
953
954 .yatra-payment-row:last-child {
955 border-bottom: none;
956 background: #111827;
957 color: white;
958 font-weight: 600;
959 }
960
961 .yatra-discount-row span:last-child {
962 color: #22c55e;
963 }
964
965 .yatra-payment-method {
966 margin-top: 16px;
967 padding: 12px;
968 background: white;
969 border-radius: 8px;
970 display: flex;
971 justify-content: space-between;
972 }
973
974 .yatra-pm-label {
975 color: #6b7280;
976 }
977
978 .yatra-pm-value {
979 font-weight: 600;
980 color: #111827;
981 }
982
983 .yatra-contact-info p {
984 margin: 0 0 8px;
985 }
986
987 .yatra-whats-next {
988 background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
989 border-color: #bbf7d0;
990 }
991
992 .yatra-next-steps {
993 display: flex;
994 flex-direction: column;
995 gap: 20px;
996 }
997
998 .yatra-step {
999 display: flex;
1000 gap: 16px;
1001 }
1002
1003 .yatra-step-number {
1004 width: 32px;
1005 height: 32px;
1006 display: flex;
1007 align-items: center;
1008 justify-content: center;
1009 background: #22c55e;
1010 color: white;
1011 border-radius: 50%;
1012 font-weight: 600;
1013 flex-shrink: 0;
1014 }
1015
1016 .yatra-step-content h4 {
1017 margin: 0 0 4px;
1018 font-size: 16px;
1019 color: #111827;
1020 }
1021
1022 .yatra-step-content p {
1023 margin: 0;
1024 font-size: 14px;
1025 color: #6b7280;
1026 }
1027
1028 .yatra-confirmation-actions {
1029 display: flex;
1030 gap: 16px;
1031 justify-content: center;
1032 margin-top: 32px;
1033 }
1034
1035 .yatra-btn {
1036 display: inline-flex;
1037 align-items: center;
1038 gap: 8px;
1039 padding: 14px 28px;
1040 border-radius: 8px;
1041 font-size: 15px;
1042 font-weight: 600;
1043 text-decoration: none;
1044 cursor: pointer;
1045 transition: all 0.2s;
1046 border: none;
1047 }
1048
1049 .yatra-btn svg {
1050 width: 18px;
1051 height: 18px;
1052 }
1053
1054 .yatra-btn-secondary {
1055 background: #3b82f6;
1056 color: white;
1057 }
1058
1059 .yatra-btn-secondary:hover {
1060 background: #2563eb;
1061 }
1062
1063 .yatra-btn-outline {
1064 background: white;
1065 color: #374151;
1066 border: 2px solid #e5e7eb;
1067 }
1068
1069 .yatra-btn-outline:hover {
1070 border-color: #3b82f6;
1071 color: #3b82f6;
1072 }
1073
1074 /* Print Styles */
1075 @media print {
1076 .yatra-confirmation-actions {
1077 display: none;
1078 }
1079
1080 .yatra-confirmation-wrapper {
1081 padding: 0;
1082 }
1083 }
1084 </style>
1085
1086 <?php yatra_get_footer(); ?>
1087
1088