| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
?> |
| 6 |
<aside class="yatra-trip-sidebar" id="booking"> |
| 7 |
<?php |
| 8 |
// Determine if this is a multi-day trip |
| 9 |
$is_multi_day = ($trip->getDurationDays() ?? 1) > 1; |
| 10 |
|
| 11 |
// Check for group discounts availability early for the badge (premium feature) |
| 12 |
$sidebar_has_group_discounts = false; |
| 13 |
$sidebar_group_discounts_data = []; |
| 14 |
$sidebar_group_discount_summary = ''; |
| 15 |
try { |
| 16 |
// Check if group discounts method exists (premium feature) |
| 17 |
if (class_exists('\Yatra\Services\DiscountService') && |
| 18 |
method_exists('\Yatra\Services\DiscountService', 'getGroupDiscountsForTrip')) { |
| 19 |
$discountService = new \Yatra\Services\DiscountService(); |
| 20 |
$groupDiscountsResult = $discountService->getGroupDiscountsForTrip((int) $trip->getId()); |
| 21 |
|
| 22 |
|
| 23 |
if (!empty($groupDiscountsResult)) { |
| 24 |
$sidebar_has_group_discounts = true; |
| 25 |
$all_ranges = []; |
| 26 |
|
| 27 |
// Process ALL group discount rules |
| 28 |
foreach ($groupDiscountsResult as $discount) { |
| 29 |
$ranges = []; |
| 30 |
|
| 31 |
// Try different field names where ranges might be stored |
| 32 |
$possible_fields = ['group_discount_ranges', 'ranges', 'discount_ranges']; |
| 33 |
foreach ($possible_fields as $field) { |
| 34 |
if (!empty($discount->$field)) { |
| 35 |
if (is_string($discount->$field)) { |
| 36 |
$ranges = json_decode($discount->$field, true); |
| 37 |
} elseif (is_array($discount->$field)) { |
| 38 |
$ranges = $discount->$field; |
| 39 |
} |
| 40 |
break; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
// If no ranges found, create a basic structure from other fields |
| 45 |
if (empty($ranges)) { |
| 46 |
$ranges = []; |
| 47 |
// Check if it's a simple discount with min/max fields |
| 48 |
$min_size = !empty($discount->min_group_size) ? (int) $discount->min_group_size : 0; |
| 49 |
$max_size = !empty($discount->max_group_size) ? (int) $discount->max_group_size : null; |
| 50 |
|
| 51 |
// Handle different field names for discount value and type |
| 52 |
$discount_value = 0; |
| 53 |
$discount_type = 'percentage'; |
| 54 |
|
| 55 |
if (!empty($discount->amount)) { |
| 56 |
$discount_value = (float) $discount->amount; |
| 57 |
} elseif (!empty($discount->discount_amount)) { |
| 58 |
$discount_value = (float) $discount->discount_amount; |
| 59 |
} |
| 60 |
|
| 61 |
if (!empty($discount->type)) { |
| 62 |
$discount_type = $discount->type; |
| 63 |
} elseif (!empty($discount->discount_type)) { |
| 64 |
$discount_type = $discount->discount_type; |
| 65 |
} |
| 66 |
|
| 67 |
// If no min_size is set, assume it's a general group discount starting from 2 people |
| 68 |
if ($min_size === 0) { |
| 69 |
$min_size = 2; |
| 70 |
} |
| 71 |
|
| 72 |
if ($min_size > 0 && $discount_value > 0) { |
| 73 |
$ranges[] = [ |
| 74 |
'min_group_size' => $min_size, |
| 75 |
'max_group_size' => $max_size, |
| 76 |
'discount_amount' => $discount_value, |
| 77 |
'discount_type' => $discount_type, |
| 78 |
'discount_percentage' => $discount_type === 'percentage' ? $discount_value : null, |
| 79 |
'discount_code' => $discount->code ?? '' |
| 80 |
]; |
| 81 |
} |
| 82 |
} else { |
| 83 |
// Add discount code to existing ranges if available |
| 84 |
foreach ($ranges as &$range) { |
| 85 |
if (!isset($range['discount_code'])) { |
| 86 |
$range['discount_code'] = $discount->code ?? ''; |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
// Merge ranges from this discount rule |
| 92 |
$all_ranges = array_merge($all_ranges, $ranges); |
| 93 |
} |
| 94 |
|
| 95 |
$sidebar_group_discounts_data = $all_ranges; |
| 96 |
} |
| 97 |
} |
| 98 |
} catch (\Exception $e) { |
| 99 |
// Silently fail if premium features are not available |
| 100 |
$sidebar_has_group_discounts = false; |
| 101 |
} |
| 102 |
|
| 103 |
// Prepare availability data for JavaScript |
| 104 |
$availability_json = []; |
| 105 |
if ($has_availability) { |
| 106 |
foreach ($trip->getAvailabilityDates() as $avail) { |
| 107 |
$availability_json[] = [ |
| 108 |
'id' => (int) $avail->id, |
| 109 |
'date' => $avail->departure_date, |
| 110 |
'departure_date' => $avail->departure_date, |
| 111 |
'return_date' => (isset($avail->return_date) && $avail->return_date !== '') |
| 112 |
? $avail->return_date |
| 113 |
: (isset($avail->arrival_date) ? $avail->arrival_date : null), |
| 114 |
'price' => $avail->effective_price ?? $avail->original_price, |
| 115 |
'original_price' => $avail->original_price, |
| 116 |
'discounted_price' => $avail->discounted_price, |
| 117 |
'seats_available' => $avail->seats_available, |
| 118 |
'seats_total' => $avail->seats_total, |
| 119 |
'status' => $avail->status, |
| 120 |
'is_limited' => $avail->is_limited ?? false, |
| 121 |
'is_sold_out' => $avail->is_sold_out ?? false, |
| 122 |
'pricing_type' => (!empty($avail->price_types) && is_array($avail->price_types)) ? 'traveler_based' : $pricing_type, |
| 123 |
'price_types' => !empty($avail->price_types) ? $avail->price_types : [], |
| 124 |
]; |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
// Pro: check whether this trip has booking disabled (enquiry-only mode) |
| 129 |
$booking_disabled = method_exists($trip, 'isBookingDisabled') && $trip->isBookingDisabled(); |
| 130 |
|
| 131 |
// Pricing — resolved via centralized TripPricingService (single source of truth) |
| 132 |
// SingleTripController pre-computes effective_price_min, min_category_original_price, max_discount_percentage |
| 133 |
$displayPricing = \Yatra\Services\TripPricingService::resolveDisplayPricing($trip); |
| 134 |
|
| 135 |
$pricing = [ |
| 136 |
'has_price' => $displayPricing['effective_price_min'] > 0, |
| 137 |
'current_price' => $displayPricing['effective_price_min'] > 0 ? yatra_format_price($displayPricing['effective_price_min']) : '', |
| 138 |
'original_price' => $displayPricing['has_discount'] ? yatra_format_price($displayPricing['min_category_original_price']) : '', |
| 139 |
'price_prefix' => $displayPricing['price_prefix'], |
| 140 |
'has_discount' => $displayPricing['has_discount'], |
| 141 |
'raw_current_price' => $displayPricing['effective_price_min'], |
| 142 |
'raw_original_price' => $displayPricing['min_category_original_price'], |
| 143 |
'is_traveler_based' => $displayPricing['has_traveler_pricing'], |
| 144 |
]; |
| 145 |
|
| 146 |
$discount = [ |
| 147 |
'has_discount' => $displayPricing['has_discount'] && $displayPricing['max_discount_percentage'] > 0, |
| 148 |
'discount_text' => $displayPricing['max_discount_percentage'] > 0 |
| 149 |
? sprintf(__('Save up to %d%%', 'yatra'), $displayPricing['max_discount_percentage']) : '', |
| 150 |
'discount_percentage' => $displayPricing['max_discount_percentage'], |
| 151 |
]; |
| 152 |
?> |
| 153 |
<?php if ($booking_disabled): ?> |
| 154 |
<div class="yatra-booking-card yatra-enquiry-only-card"> |
| 155 |
<!-- Price Display --> |
| 156 |
<div class="yatra-booking-price"> |
| 157 |
<?php if ($discount['has_discount']): ?> |
| 158 |
<div class="yatra-booking-discount-badge"> |
| 159 |
<?php echo esc_html($discount['discount_text']); ?> |
| 160 |
</div> |
| 161 |
<?php endif; ?> |
| 162 |
<div class="yatra-booking-price-main"> |
| 163 |
<?php if ($pricing['has_price']): ?> |
| 164 |
<span class="yatra-booking-price-label-top"><?php echo esc_html__('From', 'yatra'); ?></span> |
| 165 |
<?php if ($pricing['has_discount'] && !empty($pricing['original_price'])): ?> |
| 166 |
<span class="yatra-booking-price-original"><?php echo esc_html($pricing['original_price']); ?></span> |
| 167 |
<?php endif; ?> |
| 168 |
<span class="yatra-booking-price-amount" id="display-price"><?php echo esc_html($pricing['current_price']); ?></span> |
| 169 |
<span class="yatra-booking-price-label"><?php echo esc_html__('per person', 'yatra'); ?></span> |
| 170 |
<?php else: ?> |
| 171 |
<span class="yatra-booking-price-amount yatra-contact-pricing" id="display-price"><?php echo esc_html__('Contact for pricing', 'yatra'); ?></span> |
| 172 |
<?php endif; ?> |
| 173 |
</div> |
| 174 |
</div> |
| 175 |
|
| 176 |
<!-- Enquiry-only notice --> |
| 177 |
<div class="yatra-enquiry-notice" style="margin:12px 0 4px;padding:10px 12px;background:#f0f7ff;border:1px solid #cce0ff;border-radius:6px;font-size:0.85rem;color:#1a5fa8;display:flex;align-items:flex-start;gap:8px;"> |
| 178 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24" style="flex-shrink:0;margin-top:1px"> |
| 179 |
<circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/> |
| 180 |
</svg> |
| 181 |
<span><?php esc_html_e('This trip is available for enquiry only. Please contact us to discuss dates and availability.', 'yatra'); ?></span> |
| 182 |
</div> |
| 183 |
|
| 184 |
<!-- Enquiry button --> |
| 185 |
<button type="button" class="yatra-booking-button" style="margin-top:12px;" id="open-enquiry-modal" onclick="window.YatraEnquiry?.open?.(); return false;"> |
| 186 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 187 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"/> |
| 188 |
</svg> |
| 189 |
<?php echo esc_html__('Send Enquiry', 'yatra'); ?> |
| 190 |
</button> |
| 191 |
</div> |
| 192 |
<?php else: ?> |
| 193 |
<div class="yatra-booking-card" |
| 194 |
data-has-availability="<?php echo $has_availability ? 'true' : 'false'; ?>" |
| 195 |
data-is-multi-day="<?php echo $is_multi_day ? 'true' : 'false'; ?>" |
| 196 |
data-pricing-type="<?php echo esc_attr($pricing_type); ?>" |
| 197 |
data-availability='<?php echo esc_attr(json_encode($availability_json)); ?>' |
| 198 |
data-group-discounts='<?php echo esc_attr(json_encode($sidebar_group_discounts_data)); ?>'> |
| 199 |
|
| 200 |
<?php if ($sidebar_has_group_discounts): ?> |
| 201 |
<!-- Group Discount Badge - Minimal with Tooltip --> |
| 202 |
<div class="yatra-group-discount-badge-minimal yatra-has-tooltip"> |
| 203 |
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> |
| 204 |
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path> |
| 205 |
<circle cx="9" cy="7" r="4"></circle> |
| 206 |
<path d="M23 21v-2a4 4 0 0 0-3-3.87"></path> |
| 207 |
<path d="M16 3.13a4 4 0 0 1 0 7.75"></path> |
| 208 |
</svg> |
| 209 |
<span><?php echo esc_html__('Group discount available', 'yatra'); ?></span> |
| 210 |
<svg class="yatra-info-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> |
| 211 |
<circle cx="12" cy="12" r="10"></circle> |
| 212 |
<line x1="12" y1="16" x2="12" y2="12"></line> |
| 213 |
<line x1="12" y1="8" x2="12.01" y2="8"></line> |
| 214 |
</svg> |
| 215 |
<div class="yatra-tooltip"> |
| 216 |
<div class="yatra-tooltip-header"> |
| 217 |
<strong><?php echo esc_html__('Group Discount Tiers', 'yatra'); ?></strong> |
| 218 |
</div> |
| 219 |
<div class="yatra-tooltip-content"> |
| 220 |
<?php if (!empty($sidebar_group_discounts_data) && is_array($sidebar_group_discounts_data)): ?> |
| 221 |
<?php foreach ($sidebar_group_discounts_data as $range): ?> |
| 222 |
<div class="yatra-discount-tier"> |
| 223 |
<span class="yatra-tier-size"> |
| 224 |
<?php |
| 225 |
$min = (int) ($range['min_group_size'] ?? 0); |
| 226 |
$max = isset($range['max_group_size']) && $range['max_group_size'] > 0 ? (int) $range['max_group_size'] : null; |
| 227 |
if ($max) { |
| 228 |
echo sprintf(esc_html__('%d-%d travelers', 'yatra'), $min, $max); |
| 229 |
} else { |
| 230 |
echo sprintf(esc_html__('%d+ travelers', 'yatra'), $min); |
| 231 |
} |
| 232 |
?> |
| 233 |
</span> |
| 234 |
<span class="yatra-tier-discount"> |
| 235 |
<?php |
| 236 |
$discount_type = $range['discount_type'] ?? 'percentage'; |
| 237 |
$discount_value = (float) ($range['discount_amount'] ?? $range['discount_percentage'] ?? 0); |
| 238 |
|
| 239 |
if ($discount_type === 'percentage') { |
| 240 |
echo esc_html(sprintf(__('%s%% OFF', 'yatra'), number_format($discount_value, 1))); |
| 241 |
} else { |
| 242 |
echo esc_html(sprintf(__('%s OFF', 'yatra'), yatra_format_price($discount_value))); |
| 243 |
} |
| 244 |
?> |
| 245 |
</span> |
| 246 |
</div> |
| 247 |
<?php endforeach; ?> |
| 248 |
<?php endif; ?> |
| 249 |
</div> |
| 250 |
</div> |
| 251 |
</div> |
| 252 |
<?php endif; ?> |
| 253 |
|
| 254 |
<!-- Price Display --> |
| 255 |
<div class="yatra-booking-price"> |
| 256 |
<?php if ($discount['has_discount']): ?> |
| 257 |
<div class="yatra-booking-discount-badge"> |
| 258 |
<?php echo esc_html($discount['discount_text']); ?> |
| 259 |
</div> |
| 260 |
<?php endif; ?> |
| 261 |
<div class="yatra-booking-price-main"> |
| 262 |
<?php if ($pricing['has_price']): ?> |
| 263 |
<?php if ($has_availability || $has_traveler_pricing): ?> |
| 264 |
<span class="yatra-booking-price-label-top"><?php echo esc_html__('From', 'yatra'); ?></span> |
| 265 |
<?php endif; ?> |
| 266 |
<?php if ($pricing['has_discount'] && !empty($pricing['original_price'])): ?> |
| 267 |
<span class="yatra-booking-price-original"><?php echo esc_html($pricing['original_price']); ?></span> |
| 268 |
<?php endif; ?> |
| 269 |
<span class="yatra-booking-price-amount" id="display-price"><?php echo esc_html($pricing['current_price']); ?></span> |
| 270 |
<span class="yatra-booking-price-label"><?php echo esc_html__('per person', 'yatra'); ?></span> |
| 271 |
<?php else: ?> |
| 272 |
<span class="yatra-booking-price-amount yatra-contact-pricing" id="display-price"><?php echo esc_html__('Contact for pricing', 'yatra'); ?></span> |
| 273 |
<span class="yatra-booking-price-label"><?php echo esc_html__('per person', 'yatra'); ?></span> |
| 274 |
<?php endif; ?> |
| 275 |
</div> |
| 276 |
</div> |
| 277 |
|
| 278 |
<?php if ($trip->getBookingMode() === 'date_specific' && $has_availability): ?> |
| 279 |
<!-- ========================================== --> |
| 280 |
<!-- DATE-SPECIFIC BOOKING (Has Availability Dates/Rules) --> |
| 281 |
<!-- ========================================== --> |
| 282 |
<div class="yatra-availability-info"> |
| 283 |
<span class="yatra-availability-count"> |
| 284 |
<?php echo esc_html(sprintf(_n('%d departure available', '%d departures available', count($trip->getAvailabilityDates()), 'yatra'), count($trip->getAvailabilityDates()))); ?> |
| 285 |
</span> |
| 286 |
</div> |
| 287 |
|
| 288 |
<form class="yatra-booking-form" data-booking-mode="date_specific"> |
| 289 |
<!-- Date Selection --> |
| 290 |
<div class="yatra-booking-field-select"> |
| 291 |
<div class="yatra-booking-field-icon"> |
| 292 |
<?php echo yatra_svg_icon('calendar', 'yatra-icon-sm'); ?> |
| 293 |
</div> |
| 294 |
<input type="text" |
| 295 |
id="travel_date" |
| 296 |
name="travel_date" |
| 297 |
class="yatra-booking-select yatra-datepicker" |
| 298 |
placeholder="<?php esc_attr_e('Select date', 'yatra'); ?>" |
| 299 |
readonly |
| 300 |
required> |
| 301 |
<svg class="yatra-select-arrow" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 302 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 303 |
</svg> |
| 304 |
</div> |
| 305 |
|
| 306 |
<!-- Travelers Selection - Respects Trip's Pricing Type --> |
| 307 |
<?php |
| 308 |
// Use helper function to prepare traveler data |
| 309 |
$traveler_data = \Yatra\Controllers\SingleTripController::prepareTravelerSelectorData($trip, 'availability'); |
| 310 |
|
| 311 |
if ($traveler_data['has_traveler_pricing']): |
| 312 |
// Setup variables for traveler-selector.php |
| 313 |
$root_id = ''; |
| 314 |
$root_class = 'yatra-booking-field-select yatra-participants-select yatra-availability-participants'; |
| 315 |
$container_attrs = []; |
| 316 |
|
| 317 |
$display_id = 'participants-display'; |
| 318 |
$display_class = 'yatra-participants-display yatra-availability-participants-display'; |
| 319 |
$display_attrs = []; |
| 320 |
|
| 321 |
$dropdown_id = 'quantity-selector'; |
| 322 |
$dropdown_class = 'yatra-booking-quantity-selector yatra-availability-quantity-selector'; |
| 323 |
$dropdown_attrs = []; |
| 324 |
|
| 325 |
$display_text = $traveler_data['traveler_display_text']; |
| 326 |
$icon_html = yatra_svg_icon('users', 'yatra-icon-sm'); |
| 327 |
$rows = $traveler_data['traveler_rows']; |
| 328 |
|
| 329 |
include YATRA_PLUGIN_PATH . 'templates/partials/traveler-selector.php'; |
| 330 |
else: |
| 331 |
// Regular Pricing: Simple number of travelers input |
| 332 |
?> |
| 333 |
<div class="yatra-booking-field-group"> |
| 334 |
<label for="num_travelers" class="yatra-booking-field-label"><?php echo esc_html__('Number of Travelers', 'yatra'); ?></label> |
| 335 |
<?php |
| 336 |
// Setup variables for traveler-input-simple.php |
| 337 |
$input_id = 'num_travelers'; |
| 338 |
$input_name = 'num_travelers'; |
| 339 |
$value = 1; |
| 340 |
$min = $trip->getMinTravelers() ?: 1; |
| 341 |
$max = $trip->getMaxTravelers() ?: 20; |
| 342 |
$data_price = $base_price; |
| 343 |
$range_text = sprintf(__('Min: %d, Max: %d', 'yatra'), $min, $max); |
| 344 |
|
| 345 |
include YATRA_PLUGIN_PATH . 'templates/partials/traveler-input-simple.php'; |
| 346 |
?> |
| 347 |
</div> |
| 348 |
<?php endif; ?> |
| 349 |
<?php else: ?> |
| 350 |
<!-- ========================================== --> |
| 351 |
<!-- FLEXIBLE BOOKING MODE (No Specific Availability Configured) --> |
| 352 |
<!-- ========================================== --> |
| 353 |
<div class="yatra-availability-info yatra-flexible-booking-info"> |
| 354 |
<span class="yatra-availability-count"> |
| 355 |
<?php echo esc_html__('Flexible booking available', 'yatra'); ?> |
| 356 |
</span> |
| 357 |
<?php if (!empty($trip->getAvailableFrom()) || !empty($trip->getAvailableTo())): ?> |
| 358 |
<span class="yatra-availability-note"> |
| 359 |
<?php |
| 360 |
if (!empty($trip->getAvailableFrom()) && !empty($trip->getAvailableTo())) { |
| 361 |
echo esc_html(sprintf(__('Available: %s - %s', 'yatra'), |
| 362 |
date_i18n(get_option('date_format'), strtotime($trip->getAvailableFrom())), |
| 363 |
date_i18n(get_option('date_format'), strtotime($trip->getAvailableTo())) |
| 364 |
)); |
| 365 |
} elseif (!empty($trip->getAvailableFrom())) { |
| 366 |
echo esc_html(sprintf(__('Available from: %s', 'yatra'), |
| 367 |
date_i18n(get_option('date_format'), strtotime($trip->getAvailableFrom())) |
| 368 |
)); |
| 369 |
} else { |
| 370 |
echo esc_html(sprintf(__('Available until: %s', 'yatra'), |
| 371 |
date_i18n(get_option('date_format'), strtotime($trip->getAvailableTo())) |
| 372 |
)); |
| 373 |
} |
| 374 |
?> |
| 375 |
</span> |
| 376 |
<?php endif; ?> |
| 377 |
</div> |
| 378 |
|
| 379 |
<form class="yatra-booking-form" data-booking-mode="flexible"> |
| 380 |
<!-- Date Selection (Flexible) --> |
| 381 |
<div class="yatra-booking-field-select"> |
| 382 |
<div class="yatra-booking-field-icon"> |
| 383 |
<?php echo yatra_svg_icon('calendar', 'yatra-icon-sm'); ?> |
| 384 |
</div> |
| 385 |
<input type="text" |
| 386 |
id="travel_date" |
| 387 |
name="travel_date" |
| 388 |
class="yatra-booking-select yatra-datepicker" |
| 389 |
placeholder="<?php esc_attr_e('Select date', 'yatra'); ?>" |
| 390 |
data-min-date="<?php echo esc_attr($trip->getAvailableFrom() ?: date('Y-m-d')); ?>" |
| 391 |
data-max-date="<?php echo esc_attr($trip->getAvailableTo() ?: ''); ?>" |
| 392 |
readonly |
| 393 |
required> |
| 394 |
<svg class="yatra-select-arrow" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 395 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 396 |
</svg> |
| 397 |
</div> |
| 398 |
|
| 399 |
<!-- Travelers Selection --> |
| 400 |
<?php |
| 401 |
// Use helper function to prepare traveler data |
| 402 |
$traveler_data = \Yatra\Controllers\SingleTripController::prepareTravelerSelectorData($trip, 'sidebar'); |
| 403 |
|
| 404 |
if ($traveler_data['has_traveler_pricing']): |
| 405 |
// Setup variables for traveler-selector.php |
| 406 |
$root_id = ''; |
| 407 |
$root_class = 'yatra-booking-field-select yatra-participants-select'; |
| 408 |
$container_attrs = []; |
| 409 |
|
| 410 |
$display_id = 'participants-display'; |
| 411 |
$display_class = 'yatra-participants-display'; |
| 412 |
$display_attrs = []; |
| 413 |
|
| 414 |
$dropdown_id = 'quantity-selector'; |
| 415 |
$dropdown_class = 'yatra-booking-quantity-selector'; |
| 416 |
$dropdown_attrs = []; |
| 417 |
|
| 418 |
$display_text = $traveler_data['traveler_display_text']; |
| 419 |
$icon_html = yatra_svg_icon('users', 'yatra-icon-sm'); |
| 420 |
$rows = $traveler_data['traveler_rows']; |
| 421 |
|
| 422 |
include YATRA_PLUGIN_PATH . 'templates/partials/traveler-selector.php'; |
| 423 |
else: |
| 424 |
// Regular Pricing: Simple number of travelers input |
| 425 |
?> |
| 426 |
<div class="yatra-booking-field-group"> |
| 427 |
<label for="num_travelers" class="yatra-booking-field-label"><?php echo esc_html__('Number of Travelers', 'yatra'); ?></label> |
| 428 |
<?php |
| 429 |
// Setup variables for traveler-input-simple.php |
| 430 |
$input_id = 'num_travelers'; |
| 431 |
$input_name = 'num_travelers'; |
| 432 |
$value = 1; |
| 433 |
$min = $trip->getMinTravelers() ?: 1; |
| 434 |
$max = $trip->getMaxTravelers() ?: 20; |
| 435 |
$data_price = $base_price; |
| 436 |
$range_text = sprintf(__('Min: %d, Max: %d', 'yatra'), $min, $max); |
| 437 |
|
| 438 |
include YATRA_PLUGIN_PATH . 'templates/partials/traveler-input-simple.php'; |
| 439 |
?> |
| 440 |
</div> |
| 441 |
<?php endif; ?> |
| 442 |
<?php endif; ?> |
| 443 |
|
| 444 |
|
| 445 |
<!-- Action Buttons --> |
| 446 |
<button type="button" class="yatra-booking-button" id="check-availability-btn" data-trip-id="<?php echo esc_attr($trip->getId()); ?>"> |
| 447 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 448 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/> |
| 449 |
</svg> |
| 450 |
<?php echo esc_html__('Check Availability', 'yatra'); ?> |
| 451 |
</button> |
| 452 |
|
| 453 |
<button type="button" class="yatra-booking-enquiry-button" id="open-enquiry-modal" onclick="window.YatraEnquiry?.open?.(); return false;"> |
| 454 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 455 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"/> |
| 456 |
</svg> |
| 457 |
<?php echo esc_html__('Make Enquiry', 'yatra'); ?> |
| 458 |
</button> |
| 459 |
|
| 460 |
<!-- Cancellation Policy Trust Signal --> |
| 461 |
<?php |
| 462 |
$cancellation_policy = ''; |
| 463 |
if (method_exists($trip, 'getCancellationPolicy')) { |
| 464 |
$cancellation_policy = $trip->getCancellationPolicy(); |
| 465 |
} elseif (isset($trip->cancellation_policy)) { |
| 466 |
$cancellation_policy = $trip->cancellation_policy; |
| 467 |
} |
| 468 |
|
| 469 |
$cancellation_text = ''; |
| 470 |
if (!empty($cancellation_policy)) { |
| 471 |
// Extract cancellation info from policy |
| 472 |
$policy_lower = strtolower($cancellation_policy); |
| 473 |
if (strpos($policy_lower, 'free') !== false || strpos($policy_lower, 'no charge') !== false) { |
| 474 |
if (preg_match('/(\d+)\s*(hour|day|week)s?\s*before/i', $cancellation_policy, $matches)) { |
| 475 |
$time_value = $matches[1]; |
| 476 |
$time_unit = $matches[2]; |
| 477 |
$cancellation_text = sprintf( |
| 478 |
__('Free cancellation up to %d %s%s before', 'yatra'), |
| 479 |
$time_value, |
| 480 |
$time_unit, |
| 481 |
$time_value > 1 ? 's' : '' |
| 482 |
); |
| 483 |
} else { |
| 484 |
$cancellation_text = __('Free cancellation', 'yatra'); |
| 485 |
} |
| 486 |
} else { |
| 487 |
// Non-free cancellation, show brief info |
| 488 |
$cancellation_text = __('Cancellation policy applies', 'yatra'); |
| 489 |
} |
| 490 |
} else { |
| 491 |
// Default fallback when no policy is set |
| 492 |
$cancellation_text = __('Cancellation policy may apply', 'yatra'); |
| 493 |
} |
| 494 |
?> |
| 495 |
<div class="yatra-booking-trust"> |
| 496 |
<div class="yatra-booking-trust-icon"> |
| 497 |
<?php echo yatra_svg_icon('check', 'yatra-icon-xs'); ?> |
| 498 |
</div> |
| 499 |
<div class="yatra-booking-trust-text"> |
| 500 |
<strong><?php echo esc_html($cancellation_text); ?></strong> |
| 501 |
</div> |
| 502 |
</div> |
| 503 |
</form> |
| 504 |
</div> |
| 505 |
<?php endif; // end else (booking not disabled) ?> |
| 506 |
</aside> |