| @@ -206,15 +206,15 @@ | ||
| 206 | 206 | <div class="yatra-card-header-sub"><?php esc_html_e('per departure', 'yatra'); ?></div> |
| 207 | 207 | </div> |
| 208 | 208 | |
| 209 | 209 | <!-- Price (sale only; struck original + % badge sit in .yatra-card-badges-container with status) --> |
| 210 | - <div class="yatra-card-header-price"> | |
| 210 | + <div class="yatra-card-header-price" data-price-unit="<?php echo esc_attr($card['price_unit'] ?? 'per_person'); ?>"> | |
| 211 | 211 | <div class="yatra-card-price-group yatra-card-price-group--stack"> |
| 212 | 212 | <?php |
| 213 | 213 | echo '<span class="yatra-sale-price">' . yatra_format_price($display_sale_price) . '</span>'; |
| 214 | 214 | ?> |
| 215 | 215 | </div> |
| 216 | - <span class="yatra-price-label"><?php echo esc_html__('per person', 'yatra'); ?></span> | |
| 216 | + <span class="yatra-price-label"><?php echo esc_html($card['price_unit_label'] ?? __('per person', 'yatra')); ?></span> | |
| 217 | 217 | </div> |
| 218 | 218 | |
| 219 | 219 | <!-- Toggle Arrow --> |
| 220 | 220 | <div class="yatra-card-header-arrow"> |
| @@ -239,9 +239,19 @@ | ||
| 239 | 239 | <?php |
| 240 | 240 | // Prefer the per-card span (matches this card's departure/return |
| 241 | 241 | // dates); fall back to the trip default for sample cards. |
| 242 | 242 | $duration_days = (int) ($card['duration_days'] ?? $trip_data->duration_days ?? 1); |
| 243 | - echo esc_html($duration_days . ' ' . _n('Day', 'Days', $duration_days, 'yatra')); | |
| 243 | + $duration_hours = (int) ($trip_data->duration_hours ?? 0); | |
| 244 | + if ($duration_hours > 0) { | |
| 245 | + // Hour-based day tour: "8 Hours", not "1 Day". | |
| 246 | + echo esc_html(sprintf( | |
| 247 | + /* translators: %d: number of hours. */ | |
| 248 | + _n('%d Hour', '%d Hours', $duration_hours, 'yatra'), | |
| 249 | + $duration_hours | |
| 250 | + )); | |
| 251 | + } else { | |
| 252 | + echo esc_html($duration_days . ' ' . _n('Day', 'Days', $duration_days, 'yatra')); | |
| 253 | + } | |
| 244 | 254 | ?> |
| 245 | 255 | </div> |
| 246 | 256 | </div> |
| 247 | 257 | </div> |
| @@ -353,8 +363,14 @@ | ||
| 353 | 363 | if ($pt_is_per_group && !empty($pt->max_pax) |
| 354 | 364 | && (($pt->group_overflow ?? 'block') !== 'per_block')) { |
| 355 | 365 | $pt_max_qty = (int) min($pt_max_qty, (int) $pt->max_pax); |
| 356 | 366 | } |
| 367 | + // A sold-out departure has no seats left to offer, so the | |
| 368 | + // first category must not still open at 1 traveler. Clamping | |
| 369 | + // here also disables both +/- buttons below (0 <= 0 >= 0). | |
| 370 | + if ($pt_default > $pt_max_qty) { | |
| 371 | + $pt_default = $pt_max_qty; | |
| 372 | + } | |
| 357 | 373 | |
| 358 | 374 | // Determine price with fallback chain |
| 359 | 375 | $pt_price = 0; |
| 360 | 376 | if (isset($pt->effective_price) && $pt->effective_price > 0) { |
| @@ -505,8 +521,17 @@ | ||
| 505 | 521 | include YATRA_PLUGIN_PATH . 'templates/partials/traveler-selector.php'; |
| 506 | 522 | ?> |
| 507 | 523 | <?php else: ?> |
| 508 | 524 | <!-- Regular pricing: Show simple number of travelers --> |
| 525 | + <?php | |
| 526 | + // A sold-out departure offers no seats, so the counter must start | |
| 527 | + // at 0 (not 1) and both controls stay disabled. Only the ceiling | |
| 528 | + // was capacity-aware before, which left sold-out cards showing a | |
| 529 | + // selectable traveler. | |
| 530 | + $simple_max_qty = (int) min($seats_available, $max_travelers); | |
| 531 | + $simple_qty = $simple_max_qty > 0 ? 1 : 0; | |
| 532 | + $simple_min_qty = $simple_qty; | |
| 533 | + ?> | |
| 509 | 534 | <div class="yatra-booking-travelers-simple yatra-availability-travelers-simple" data-item="<?php echo esc_attr($item_id); ?>"> |
| 510 | 535 | <div class="yatra-booking-field-icon"> |
| 511 | 536 | <?php echo yatra_svg_icon('users', 'yatra-icon-sm'); ?> |
| 512 | 537 | </div> |
| @@ -515,18 +540,18 @@ | ||
| 515 | 540 | <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 516 | 541 | <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4"/> |
| 517 | 542 | </svg> |
| 518 | 543 | </button> |
| 519 | - <input type="number" | |
| 520 | - id="num-travelers-<?php echo esc_attr($item_id); ?>" | |
| 521 | - class="yatra-quantity-input-simple yatra-availability-num-travelers" | |
| 544 | + <input type="number" | |
| 545 | + id="num-travelers-<?php echo esc_attr($item_id); ?>" | |
| 546 | + class="yatra-quantity-input-simple yatra-availability-num-travelers" | |
| 522 | 547 | data-item="<?php echo esc_attr($item_id); ?>" |
| 523 | - value="1" | |
| 524 | - min="1" | |
| 525 | - max="<?php echo esc_attr(min($seats_available, $max_travelers)); ?>" | |
| 548 | + value="<?php echo esc_attr($simple_qty); ?>" | |
| 549 | + min="<?php echo esc_attr($simple_min_qty); ?>" | |
| 550 | + max="<?php echo esc_attr($simple_max_qty); ?>" | |
| 526 | 551 | readonly |
| 527 | 552 | data-price="<?php echo esc_attr($display_sale_price); ?>"> |
| 528 | - <button type="button" class="yatra-quantity-btn yatra-quantity-plus" data-target="num-travelers-<?php echo esc_attr($item_id); ?>" aria-label="<?php esc_attr_e('Increase travelers', 'yatra'); ?>"> | |
| 553 | + <button type="button" class="yatra-quantity-btn yatra-quantity-plus" data-target="num-travelers-<?php echo esc_attr($item_id); ?>" aria-label="<?php esc_attr_e('Increase travelers', 'yatra'); ?>"<?php echo $simple_qty >= $simple_max_qty ? ' disabled' : ''; ?>> | |
| 529 | 554 | <svg fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 530 | 555 | <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/> |
| 531 | 556 | </svg> |
| 532 | 557 | </button> |