| 1 |
<?php |
| 2 |
/** |
| 3 |
* Trip listing template (presentation). Data is prepared in {@see TripListingPageContextFactory} and set by {@see ListingPageHandler}. |
| 4 |
* |
| 5 |
* @package Yatra |
| 6 |
*/ |
| 7 |
|
| 8 |
use Yatra\Services\TripListingService; |
| 9 |
|
| 10 |
if (!defined('ABSPATH')) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
$tripListingService = new TripListingService(); |
| 15 |
|
| 16 |
$ctx = $GLOBALS['yatra_trip_listing_context'] ?? []; |
| 17 |
$filter_data = $ctx['filter_data'] ?? []; |
| 18 |
if ($filter_data === []) { |
| 19 |
$filter_data = $tripListingService->getFilterData(); |
| 20 |
} |
| 21 |
$yatra_trip_list = $ctx['trip_list'] ?? ($GLOBALS['yatra_trip_list'] ?? null); |
| 22 |
$trips_source = $ctx['trips'] ?? []; |
| 23 |
$trip_total = (int) ($ctx['total'] ?? 0); |
| 24 |
$trip_total_pages = (int) ($ctx['pages'] ?? 1); |
| 25 |
$trip_current_page = (int) ($ctx['current_page'] ?? 1); |
| 26 |
$trip_dest_options = $ctx['destinations'] ?? []; |
| 27 |
$trip_act_options = $ctx['activities'] ?? []; |
| 28 |
$active_filters = $ctx['active_filters'] ?? []; |
| 29 |
$yatra_listing_title = $ctx['listing_title'] ?? __('All Trips', 'yatra'); |
| 30 |
$current_filter_type = $ctx['taxonomy_type'] ?? ''; |
| 31 |
$current_filter_slug = $ctx['taxonomy_slug'] ?? ''; |
| 32 |
$current_filter_name = $ctx['taxonomy_name'] ?? ''; |
| 33 |
$yatra_results = $ctx['results'] ?? [ |
| 34 |
'display_total' => 0, |
| 35 |
'start_item' => 0, |
| 36 |
'end_item' => 0, |
| 37 |
'per_page' => yatra_get_posts_per_page(), |
| 38 |
]; |
| 39 |
$yatra_pagination = $ctx['pagination'] ?? [ |
| 40 |
'total_pages' => 1, |
| 41 |
'current_page' => 1, |
| 42 |
'prev_url' => null, |
| 43 |
'next_url' => null, |
| 44 |
'items' => [], |
| 45 |
]; |
| 46 |
$yatra_sort_options = $ctx['sort_options'] ?? []; |
| 47 |
$show_taxonomy_context = !empty($ctx['show_taxonomy_context']); |
| 48 |
|
| 49 |
yatra_get_header(); |
| 50 |
?> |
| 51 |
|
| 52 |
<?php if ($show_taxonomy_context) : ?> |
| 53 |
<div id="yatra-trip-context" |
| 54 |
data-type="<?php echo esc_attr($current_filter_type); ?>" |
| 55 |
data-slug="<?php echo esc_attr($current_filter_slug); ?>" |
| 56 |
data-name="<?php echo esc_attr($current_filter_name); ?>" |
| 57 |
style="display:none;"></div> |
| 58 |
<?php endif; ?> |
| 59 |
|
| 60 |
<?php |
| 61 |
// Trip-listing card layout (Settings → Design). The archive follows the |
| 62 |
// site-wide setting; the class is placed on this container so the listing CSS |
| 63 |
// can key off it (see assets/css/listing.css "Compact card layout"). |
| 64 |
$yatra_listing_layout_class = \Yatra\Providers\FrontendAssetsProvider::listingLayoutClasses( |
| 65 |
\Yatra\Providers\FrontendAssetsProvider::resolveListingLayout() |
| 66 |
); |
| 67 |
?> |
| 68 |
<div class="yatra-listing-page yatra-trip-listing<?php echo $yatra_listing_layout_class ? ' ' . esc_attr($yatra_listing_layout_class) : ''; ?>" id="yatra-trip-listing-root"> |
| 69 |
<!-- Trip Search Shortcode - replaces hardcoded search UI --> |
| 70 |
<div class="yatra-trip-listing-search-wrap"> |
| 71 |
<?php |
| 72 |
// Build the [yatra_search] arguments from the Search & Listing toggles so |
| 73 |
// the listing bar reflects the operator's settings explicitly at the call |
| 74 |
// site. Each field becomes a yes/no argument the shortcode honours, so |
| 75 |
// turning a field off in Settings → Search & Listing hides it here. |
| 76 |
$yatra_search_field_settings = [ |
| 77 |
'keyword' => 'search_show_keyword', |
| 78 |
'destination' => 'search_show_destination', |
| 79 |
'activities' => 'search_show_activities', |
| 80 |
'duration' => 'search_show_duration', |
| 81 |
'budget' => 'search_show_budget', |
| 82 |
]; |
| 83 |
$yatra_search_atts = ''; |
| 84 |
foreach ($yatra_search_field_settings as $yatra_arg => $yatra_setting_key) { |
| 85 |
$yatra_search_atts .= sprintf( |
| 86 |
' %s="%s"', |
| 87 |
$yatra_arg, |
| 88 |
\Yatra\Services\SettingsService::isEnabled($yatra_setting_key) ? 'yes' : 'no' |
| 89 |
); |
| 90 |
} |
| 91 |
echo do_shortcode('[yatra_search' . $yatra_search_atts . ']'); |
| 92 |
?> |
| 93 |
</div> |
| 94 |
|
| 95 |
<div class="yatra-listing-wrapper yatra-listing-wrapper--overlay-host"> |
| 96 |
<div id="yatra-listing-loading-overlay" class="yatra-listing-loading-overlay" aria-hidden="true" role="status"> |
| 97 |
<div class="yatra-listing-loading-card"> |
| 98 |
<span class="yatra-listing-loading-spinner" aria-hidden="true"></span> |
| 99 |
<p class="yatra-listing-loading-text"><?php esc_html_e('Updating trips…', 'yatra'); ?></p> |
| 100 |
</div> |
| 101 |
</div> |
| 102 |
<div class="yatra-listing-container"> |
| 103 |
|
| 104 |
<!-- Results Header --> |
| 105 |
<div class="yatra-results-header"> |
| 106 |
<div class="yatra-results-info"> |
| 107 |
<h1><?php echo esc_html($yatra_listing_title); ?></h1> |
| 108 |
<?php if (empty($show_taxonomy_context)) : ?> |
| 109 |
<p class="yatra-listing-archive-lede"><?php esc_html_e('Compare trips, filter by budget and trip style, then open a trip for full details and booking.', 'yatra'); ?></p> |
| 110 |
<?php elseif (!empty($current_filter_name) || !empty($current_filter_slug)) : ?> |
| 111 |
<p class="yatra-listing-archive-lede"><?php |
| 112 |
printf( |
| 113 |
/* translators: %s: applied taxonomy filter label (destination, activity, or category name). */ |
| 114 |
esc_html__('Filtered by: %s', 'yatra'), |
| 115 |
esc_html($current_filter_name !== '' ? $current_filter_name : (string) $current_filter_slug) |
| 116 |
); |
| 117 |
?></p> |
| 118 |
<?php endif; ?> |
| 119 |
<p class="yatra-results-count"> |
| 120 |
<?php |
| 121 |
if ($yatra_results['display_total'] > 0) { |
| 122 |
echo sprintf( |
| 123 |
/* translators: 1: first item index on the page, 2: last item index on the page, 3: total trips, 4: current page number, 5: total page count. */ |
| 124 |
__('Showing <strong>%1$d-%2$d</strong> of %3$d trips (Page %4$d of %5$d)', 'yatra'), |
| 125 |
(int) $yatra_results['start_item'], |
| 126 |
(int) $yatra_results['end_item'], |
| 127 |
(int) $yatra_results['display_total'], |
| 128 |
$trip_current_page, |
| 129 |
$trip_total_pages |
| 130 |
); |
| 131 |
} else { |
| 132 |
echo esc_html__('No trips found', 'yatra'); |
| 133 |
} |
| 134 |
?> |
| 135 |
</p> |
| 136 |
</div> |
| 137 |
<div class="yatra-results-controls"> |
| 138 |
<div class="yatra-sort-control"> |
| 139 |
<label><?php esc_html_e('Sort by:', 'yatra'); ?></label> |
| 140 |
<?php |
| 141 |
?> |
| 142 |
<select id="yatra-sort-filter" class="yatra-sort-filter-select"> |
| 143 |
<?php foreach ($yatra_sort_options as $sort_opt) : ?> |
| 144 |
<option value="<?php echo esc_attr(esc_url($sort_opt['url'])); ?>"<?php echo !empty($sort_opt['selected']) ? ' selected="selected"' : ''; ?>> |
| 145 |
<?php echo esc_html($sort_opt['label']); ?> |
| 146 |
</option> |
| 147 |
<?php endforeach; ?> |
| 148 |
</select> |
| 149 |
</div> |
| 150 |
<div class="yatra-view-toggle"> |
| 151 |
<button class="yatra-view-btn active" data-view="grid" title="<?php esc_attr_e('Grid View', 'yatra'); ?>"> |
| 152 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 153 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"/> |
| 154 |
</svg> |
| 155 |
</button> |
| 156 |
<button class="yatra-view-btn" data-view="list" title="<?php esc_attr_e('List View', 'yatra'); ?>"> |
| 157 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 158 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"/> |
| 159 |
</svg> |
| 160 |
</button> |
| 161 |
</div> |
| 162 |
</div> |
| 163 |
</div> |
| 164 |
|
| 165 |
<div class="yatra-listing-layout"> |
| 166 |
<!-- Filter Sidebar - Comprehensive Filters --> |
| 167 |
<aside class="yatra-filter-sidebar"<?php echo \Yatra\Services\SettingsService::isEnabled('collapse_filters_on_mobile') ? ' data-yatra-collapse-mobile="1"' : ''; ?>> |
| 168 |
<div class="yatra-filter-header"> |
| 169 |
<h2><?php esc_html_e('Filters', 'yatra'); ?></h2> |
| 170 |
<button type="button" class="yatra-clear-filters"><?php esc_html_e('Clear all', 'yatra'); ?></button> |
| 171 |
</div> |
| 172 |
|
| 173 |
<!-- Price Range --> |
| 174 |
<?php |
| 175 |
$price_stats = $filter_data['price_stats'] ?? $tripListingService->getPriceStats(); |
| 176 |
|
| 177 |
$min_price = $price_stats ? (int) floor($price_stats->min_price) : 0; |
| 178 |
$max_price = $price_stats ? (int) ceil($price_stats->max_price) : 10000; |
| 179 |
// Step 1 so the range slider can land EXACTLY on the true |
| 180 |
// maximum price. A larger "dynamic" step (max/100) only lets |
| 181 |
// the thumb stop on min + N*step, so unless (max - min) is a |
| 182 |
// whole multiple of that step the slider caps short of the |
| 183 |
// real max — e.g. min 9 / max 10000 / step 100 stops at |
| 184 |
// 9909, hiding the most expensive trips from the filter. |
| 185 |
// An integer step also keeps submitted price bounds whole. |
| 186 |
$step = 1; |
| 187 |
?> |
| 188 |
<div class="yatra-filter-section"> |
| 189 |
<div class="yatra-filter-title" data-toggle="price"> |
| 190 |
<div class="yatra-filter-title-content"> |
| 191 |
<svg class="yatra-filter-icon" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 192 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/> |
| 193 |
</svg> |
| 194 |
<span><?php esc_html_e('Price Range', 'yatra'); ?></span> |
| 195 |
</div> |
| 196 |
<div class="yatra-filter-actions"> |
| 197 |
<span class="yatra-clear-section" data-section="price" title="<?php esc_attr_e('Clear price filters', 'yatra'); ?>"> |
| 198 |
<svg width="14" height="14" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 199 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/> |
| 200 |
</svg> |
| 201 |
</span> |
| 202 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 203 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 204 |
</svg> |
| 205 |
</div> |
| 206 |
</div> |
| 207 |
<div class="yatra-filter-content"> |
| 208 |
<div class="yatra-price-range"> |
| 209 |
<div class="yatra-price-inputs"> |
| 210 |
<div class="yatra-price-input-group"> |
| 211 |
<label class="yatra-price-input-label"><?php esc_html_e('Min Price', 'yatra'); ?></label> |
| 212 |
<input type="number" name="price_min" placeholder="<?php echo $min_price; ?>" min="<?php echo $min_price; ?>" max="<?php echo $max_price; ?>" value="<?php echo !empty($active_filters['price_min']) ? esc_attr($active_filters['price_min']) : ''; ?>" id="priceMin"> |
| 213 |
</div> |
| 214 |
<div class="yatra-price-separator">—</div> |
| 215 |
<div class="yatra-price-input-group"> |
| 216 |
<label class="yatra-price-input-label"><?php esc_html_e('Max Price', 'yatra'); ?></label> |
| 217 |
<input type="number" name="price_max" placeholder="<?php echo $max_price; ?>" min="<?php echo $min_price; ?>" max="<?php echo $max_price; ?>" value="<?php echo !empty($active_filters['price_max']) ? esc_attr($active_filters['price_max']) : ''; ?>" id="priceMax"> |
| 218 |
</div> |
| 219 |
</div> |
| 220 |
<div class="yatra-price-slider"> |
| 221 |
<div class="yatra-price-slider-track" aria-hidden="true"></div> |
| 222 |
<div class="yatra-price-slider-range" aria-hidden="true"></div> |
| 223 |
<input type="range" min="<?php echo $min_price; ?>" max="<?php echo $max_price; ?>" step="<?php echo $step; ?>" value="<?php echo !empty($active_filters['price_min']) ? esc_attr($active_filters['price_min']) : $min_price; ?>" class="yatra-range-min" id="priceRangeMin" data-default="<?php echo $min_price; ?>" data-user-set="<?php echo !empty($active_filters['price_min']) ? 'true' : 'false'; ?>"> |
| 224 |
<input type="range" min="<?php echo $min_price; ?>" max="<?php echo $max_price; ?>" step="<?php echo $step; ?>" value="<?php echo !empty($active_filters['price_max']) ? esc_attr($active_filters['price_max']) : $max_price; ?>" class="yatra-range-max" id="priceRangeMax" data-default="<?php echo $max_price; ?>" data-user-set="<?php echo !empty($active_filters['price_max']) ? 'true' : 'false'; ?>"> |
| 225 |
</div> |
| 226 |
<div class="yatra-price-display"><?php echo yatra_format_price($min_price); ?> - <?php echo yatra_format_price($max_price); ?></div> |
| 227 |
</div> |
| 228 |
</div> |
| 229 |
</div> |
| 230 |
|
| 231 |
<!-- Trip Type Filter --> |
| 232 |
<div class="yatra-filter-section"> |
| 233 |
<div class="yatra-filter-title" data-toggle="trip-type"> |
| 234 |
<div class="yatra-filter-title-content"> |
| 235 |
<svg class="yatra-filter-icon" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 236 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/> |
| 237 |
</svg> |
| 238 |
<span><?php esc_html_e('Trip Type', 'yatra'); ?></span> |
| 239 |
</div> |
| 240 |
<div class="yatra-filter-actions"> |
| 241 |
<span class="yatra-clear-section" data-section="trip-type" title="<?php esc_attr_e('Clear trip type filter', 'yatra'); ?>"> |
| 242 |
<svg width="14" height="14" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 243 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/> |
| 244 |
</svg> |
| 245 |
</span> |
| 246 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 247 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 248 |
</svg> |
| 249 |
</div> |
| 250 |
</div> |
| 251 |
<div class="yatra-filter-content"> |
| 252 |
<div class="yatra-checkbox-group"> |
| 253 |
<?php |
| 254 |
// Get trip type options from service |
| 255 |
$trip_type_options = $filter_data['trip_types'] ?? []; |
| 256 |
|
| 257 |
foreach ($trip_type_options as $type_option) : |
| 258 |
?> |
| 259 |
<label class="yatra-checkbox-label"> |
| 260 |
<input type="radio" name="trip_type" value="<?php echo esc_attr($type_option->value); ?>" <?php echo ($active_filters['trip_type'] === $type_option->value) ? 'checked' : ''; ?>> |
| 261 |
<span><?php echo esc_html($type_option->label); ?></span> |
| 262 |
<span class="yatra-filter-count">(<?php echo (int)$type_option->count; ?>)</span> |
| 263 |
</label> |
| 264 |
<?php endforeach; ?> |
| 265 |
|
| 266 |
<!-- All Types Option --> |
| 267 |
<label class="yatra-checkbox-label"> |
| 268 |
<input type="radio" name="trip_type" value="" <?php echo empty($active_filters['trip_type']) ? 'checked' : ''; ?>> |
| 269 |
<span><?php esc_html_e('All Types', 'yatra'); ?></span> |
| 270 |
</label> |
| 271 |
</div> |
| 272 |
</div> |
| 273 |
</div> |
| 274 |
|
| 275 |
<!-- Difficulty Level --> |
| 276 |
<?php |
| 277 |
$difficulty_levels = $filter_data['difficulty_levels'] ?? []; |
| 278 |
if (!empty($difficulty_levels)) : |
| 279 |
?> |
| 280 |
<div class="yatra-filter-section"> |
| 281 |
<div class="yatra-filter-title" data-toggle="difficulty"> |
| 282 |
<div class="yatra-filter-title-content"> |
| 283 |
<svg class="yatra-filter-icon" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 284 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4M7.835 4.697a3.42 3.42 0 001.946-.806 3.42 3.42 0 014.438 0 3.42 3.42 0 001.946.806 3.42 3.42 0 013.138 3.138 3.42 3.42 0 00.806 1.946 3.42 3.42 0 010 4.438 3.42 3.42 0 00-.806 1.946 3.42 3.42 0 01-3.138 3.138 3.42 3.42 0 00-1.946.806 3.42 3.42 0 01-4.438 0 3.42 3.42 0 00-1.946-.806 3.42 3.42 0 01-3.138-3.138 3.42 3.42 0 00-.806-1.946 3.42 3.42 0 010-4.438 3.42 3.42 0 00.806-1.946 3.42 3.42 0 013.138-3.138z"/> |
| 285 |
</svg> |
| 286 |
<span><?php esc_html_e('Difficulty Level', 'yatra'); ?></span> |
| 287 |
</div> |
| 288 |
<div class="yatra-filter-actions"> |
| 289 |
<span class="yatra-clear-section" data-section="difficulty" title="<?php esc_attr_e('Clear difficulty filters', 'yatra'); ?>"> |
| 290 |
<svg width="14" height="14" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 291 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/> |
| 292 |
</svg> |
| 293 |
</span> |
| 294 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 295 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 296 |
</svg> |
| 297 |
</div> |
| 298 |
</div> |
| 299 |
<div class="yatra-filter-content"> |
| 300 |
<?php |
| 301 |
$yatra_sidebar_cb_rows = []; |
| 302 |
foreach ($difficulty_levels as $level) { |
| 303 |
$yatra_sidebar_cb_rows[] = [ |
| 304 |
'value' => $level->id, |
| 305 |
'label' => $level->name, |
| 306 |
'count' => (int) $level->count, |
| 307 |
]; |
| 308 |
} |
| 309 |
$yatra_sidebar_cb_input_name = 'difficulty[]'; |
| 310 |
$yatra_sidebar_cb_active = $active_filters['difficulty'] ?? []; |
| 311 |
include __DIR__ . '/partials/listing-sidebar-collapsible-checkboxes.php'; |
| 312 |
unset($yatra_sidebar_cb_rows, $yatra_sidebar_cb_input_name, $yatra_sidebar_cb_active); |
| 313 |
?> |
| 314 |
</div> |
| 315 |
</div> |
| 316 |
<?php endif; ?> |
| 317 |
|
| 318 |
<!-- Rating --> |
| 319 |
<div class="yatra-filter-section"> |
| 320 |
<div class="yatra-filter-title" data-toggle="rating"> |
| 321 |
<div class="yatra-filter-title-content"> |
| 322 |
<svg class="yatra-filter-icon" width="18" height="18" fill="#fbbf24" viewBox="0 0 24 24"> |
| 323 |
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/> |
| 324 |
</svg> |
| 325 |
<span><?php esc_html_e('Rating', 'yatra'); ?></span> |
| 326 |
</div> |
| 327 |
<div class="yatra-filter-actions"> |
| 328 |
<span class="yatra-clear-section" data-section="rating" title="<?php esc_attr_e('Clear rating filters', 'yatra'); ?>"> |
| 329 |
<svg width="14" height="14" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 330 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/> |
| 331 |
</svg> |
| 332 |
</span> |
| 333 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 334 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 335 |
</svg> |
| 336 |
</div> |
| 337 |
</div> |
| 338 |
<div class="yatra-filter-content"> |
| 339 |
<div class="yatra-rating-filter"> |
| 340 |
<?php |
| 341 |
$rating_options = $filter_data['ratings'] ?? []; |
| 342 |
|
| 343 |
foreach ($rating_options as $option) : |
| 344 |
// Show all rating options, even with 0 count for better UX |
| 345 |
?> |
| 346 |
<label class="yatra-rating-option"> |
| 347 |
<input type="checkbox" name="rating[]" value="<?php echo esc_attr($option->rating); ?>" <?php echo in_array($option->rating, $active_filters['rating'] ?? []) ? 'checked' : ''; ?>> |
| 348 |
<div class="yatra-stars-display"> |
| 349 |
<?php for ($i = 1; $i <= 5; $i++) : ?> |
| 350 |
<svg class="yatra-star <?php echo $i <= $option->rating ? 'filled' : 'empty'; ?>" width="16" height="16" viewBox="0 0 24 24"> |
| 351 |
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" fill="<?php echo $i <= $option->rating ? '#fbbf24' : '#e5e7eb'; ?>"/> |
| 352 |
</svg> |
| 353 |
<?php endfor; ?> |
| 354 |
<span class="yatra-rating-label"><?php echo esc_html($option->label); ?></span> |
| 355 |
<span class="yatra-filter-count">(<?php echo (int)$option->count; ?>)</span> |
| 356 |
</div> |
| 357 |
</label> |
| 358 |
<?php endforeach; ?> |
| 359 |
</div> |
| 360 |
</div> |
| 361 |
</div> |
| 362 |
|
| 363 |
<!-- Trip Categories --> |
| 364 |
<?php |
| 365 |
$categories = $filter_data['categories'] ?? []; |
| 366 |
if (!empty($categories)) : |
| 367 |
?> |
| 368 |
<div class="yatra-filter-section"> |
| 369 |
<div class="yatra-filter-title" data-toggle="categories"> |
| 370 |
<div class="yatra-filter-title-content"> |
| 371 |
<svg class="yatra-filter-icon" width="18" height="18" fill="currentColor" viewBox="0 0 20 20"> |
| 372 |
<path fill-rule="evenodd" d="M3 4a1 1 0 011-1h12a1 1 0 011 1v2a1 1 0 01-1 1H4a1 1 0 01-1-1V4zM3 10a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H4a1 1 0 01-1-1v-6zM14 9a1 1 0 00-1 1v6a1 1 0 001 1h2a1 1 0 001-1v-6a1 1 0 00-1-1h-2z" clip-rule="evenodd" /> |
| 373 |
</svg> |
| 374 |
<span><?php esc_html_e('Categories', 'yatra'); ?></span> |
| 375 |
</div> |
| 376 |
<div class="yatra-filter-actions"> |
| 377 |
<span class="yatra-clear-section" data-section="categories" title="<?php esc_attr_e('Clear category filters', 'yatra'); ?>"> |
| 378 |
<svg width="14" height="14" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 379 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/> |
| 380 |
</svg> |
| 381 |
</span> |
| 382 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 383 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 384 |
</svg> |
| 385 |
</div> |
| 386 |
</div> |
| 387 |
<div class="yatra-filter-content"> |
| 388 |
<?php |
| 389 |
$yatra_sidebar_cb_rows = []; |
| 390 |
foreach ($categories as $category) { |
| 391 |
$yatra_sidebar_cb_rows[] = [ |
| 392 |
'value' => $category->id, |
| 393 |
'label' => $category->name, |
| 394 |
'count' => (int) $category->count, |
| 395 |
]; |
| 396 |
} |
| 397 |
$yatra_sidebar_cb_input_name = 'categories[]'; |
| 398 |
$yatra_sidebar_cb_active = $active_filters['categories'] ?? []; |
| 399 |
include __DIR__ . '/partials/listing-sidebar-collapsible-checkboxes.php'; |
| 400 |
unset($yatra_sidebar_cb_rows, $yatra_sidebar_cb_input_name, $yatra_sidebar_cb_active); |
| 401 |
?> |
| 402 |
</div> |
| 403 |
</div> |
| 404 |
<?php endif; ?> |
| 405 |
|
| 406 |
<!-- Destinations --> |
| 407 |
<?php |
| 408 |
$destinations = $filter_data['destinations'] ?? []; |
| 409 |
if (!empty($destinations)) : |
| 410 |
?> |
| 411 |
<div class="yatra-filter-section"> |
| 412 |
<div class="yatra-filter-title" data-toggle="destinations"> |
| 413 |
<div class="yatra-filter-title-content"> |
| 414 |
<svg class="yatra-filter-icon" width="18" height="18" fill="currentColor" viewBox="0 0 20 20"> |
| 415 |
<path fill-rule="evenodd" d="M5.05 4.05a7 7 0 119.9 9.9L10 18.9l-4.95-4.95a7 7 0 010-9.9zM10 11a2 2 0 100-4 2 2 0 000 4z" clip-rule="evenodd" /> |
| 416 |
</svg> |
| 417 |
<span><?php esc_html_e('Destinations', 'yatra'); ?></span> |
| 418 |
</div> |
| 419 |
<div class="yatra-filter-actions"> |
| 420 |
<span class="yatra-clear-section" data-section="destinations" title="<?php esc_attr_e('Clear destination filters', 'yatra'); ?>"> |
| 421 |
<svg width="14" height="14" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 422 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/> |
| 423 |
</svg> |
| 424 |
</span> |
| 425 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 426 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 427 |
</svg> |
| 428 |
</div> |
| 429 |
</div> |
| 430 |
<div class="yatra-filter-content"> |
| 431 |
<?php |
| 432 |
$yatra_sidebar_cb_rows = []; |
| 433 |
foreach ($destinations as $destination) { |
| 434 |
$yatra_sidebar_cb_rows[] = [ |
| 435 |
'value' => $destination->id, |
| 436 |
'label' => $destination->name, |
| 437 |
'count' => (int) $destination->count, |
| 438 |
]; |
| 439 |
} |
| 440 |
$yatra_sidebar_cb_input_name = 'destinations[]'; |
| 441 |
$yatra_sidebar_cb_active = $active_filters['destinations'] ?? []; |
| 442 |
include __DIR__ . '/partials/listing-sidebar-collapsible-checkboxes.php'; |
| 443 |
unset($yatra_sidebar_cb_rows, $yatra_sidebar_cb_input_name, $yatra_sidebar_cb_active); |
| 444 |
?> |
| 445 |
</div> |
| 446 |
</div> |
| 447 |
<?php endif; ?> |
| 448 |
|
| 449 |
<!-- Activities --> |
| 450 |
<?php |
| 451 |
$activities = $filter_data['activities'] ?? []; |
| 452 |
if (!empty($activities)) : |
| 453 |
?> |
| 454 |
<div class="yatra-filter-section"> |
| 455 |
<div class="yatra-filter-title" data-toggle="activities"> |
| 456 |
<div class="yatra-filter-title-content"> |
| 457 |
<svg class="yatra-filter-icon" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 458 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/> |
| 459 |
</svg> |
| 460 |
<span><?php esc_html_e('Activities', 'yatra'); ?></span> |
| 461 |
</div> |
| 462 |
<div class="yatra-filter-actions"> |
| 463 |
<span class="yatra-clear-section" data-section="activities" title="<?php esc_attr_e('Clear activity filters', 'yatra'); ?>"> |
| 464 |
<svg width="14" height="14" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 465 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/> |
| 466 |
</svg> |
| 467 |
</span> |
| 468 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 469 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 470 |
</svg> |
| 471 |
</div> |
| 472 |
</div> |
| 473 |
<div class="yatra-filter-content"> |
| 474 |
<?php |
| 475 |
$yatra_sidebar_cb_rows = []; |
| 476 |
foreach ($activities as $activity) { |
| 477 |
$yatra_sidebar_cb_rows[] = [ |
| 478 |
'value' => $activity->id, |
| 479 |
'label' => $activity->name, |
| 480 |
'count' => (int) $activity->count, |
| 481 |
]; |
| 482 |
} |
| 483 |
$yatra_sidebar_cb_input_name = 'activities[]'; |
| 484 |
$yatra_sidebar_cb_active = $active_filters['activities'] ?? []; |
| 485 |
include __DIR__ . '/partials/listing-sidebar-collapsible-checkboxes.php'; |
| 486 |
unset($yatra_sidebar_cb_rows, $yatra_sidebar_cb_input_name, $yatra_sidebar_cb_active); |
| 487 |
?> |
| 488 |
</div> |
| 489 |
</div> |
| 490 |
<?php endif; ?> |
| 491 |
|
| 492 |
<!-- Accommodation Type --> |
| 493 |
<?php |
| 494 |
// Get accommodation types from service |
| 495 |
$accommodation_types = $filter_data['accommodations'] ?? []; |
| 496 |
|
| 497 |
if (!empty($accommodation_types)) : |
| 498 |
?> |
| 499 |
<div class="yatra-filter-section"> |
| 500 |
<div class="yatra-filter-title" data-toggle="accommodation"> |
| 501 |
<div class="yatra-filter-title-content"> |
| 502 |
<svg class="yatra-filter-icon" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 503 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/> |
| 504 |
</svg> |
| 505 |
<span><?php esc_html_e('Accommodation', 'yatra'); ?></span> |
| 506 |
</div> |
| 507 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 508 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 509 |
</svg> |
| 510 |
</div> |
| 511 |
<div class="yatra-filter-content"> |
| 512 |
<?php |
| 513 |
$yatra_sidebar_cb_rows = []; |
| 514 |
foreach ($accommodation_types as $accommodation) { |
| 515 |
$yatra_sidebar_cb_rows[] = [ |
| 516 |
'value' => $accommodation->name, |
| 517 |
'label' => ucwords(str_replace(['_', '-'], ' ', $accommodation->name)), |
| 518 |
'count' => (int) $accommodation->trip_count, |
| 519 |
]; |
| 520 |
} |
| 521 |
$yatra_sidebar_cb_input_name = 'accommodation[]'; |
| 522 |
$yatra_sidebar_cb_active = $active_filters['accommodation'] ?? []; |
| 523 |
include __DIR__ . '/partials/listing-sidebar-collapsible-checkboxes.php'; |
| 524 |
unset($yatra_sidebar_cb_rows, $yatra_sidebar_cb_input_name, $yatra_sidebar_cb_active); |
| 525 |
?> |
| 526 |
</div> |
| 527 |
</div> |
| 528 |
<?php endif; ?> |
| 529 |
|
| 530 |
<!-- Included Services --> |
| 531 |
<?php |
| 532 |
// Get included services from service |
| 533 |
$included_services = $filter_data['included_services'] ?? []; |
| 534 |
|
| 535 |
if (!empty($included_services)) : |
| 536 |
?> |
| 537 |
<div class="yatra-filter-section"> |
| 538 |
<div class="yatra-filter-title" data-toggle="services"> |
| 539 |
<div class="yatra-filter-title-content"> |
| 540 |
<svg class="yatra-filter-icon" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 541 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4M7.835 4.697a3.42 3.42 0 001.946-.806 3.42 3.42 0 014.438 0 3.42 3.42 0 001.946.806 3.42 3.42 0 013.138 3.138 3.42 3.42 0 00.806 1.946 3.42 3.42 0 010 4.438 3.42 3.42 0 00-.806 1.946 3.42 3.42 0 01-3.138 3.138 3.42 3.42 0 00-1.946.806 3.42 3.42 0 01-4.438 0 3.42 3.42 0 00-1.946-.806 3.42 3.42 0 01-3.138-3.138 3.42 3.42 0 00-.806-1.946 3.42 3.42 0 010-4.438 3.42 3.42 0 00.806-1.946 3.42 3.42 0 013.138-3.138z"/> |
| 542 |
</svg> |
| 543 |
<span><?php esc_html_e('Included Services', 'yatra'); ?></span> |
| 544 |
</div> |
| 545 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 546 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 547 |
</svg> |
| 548 |
</div> |
| 549 |
<div class="yatra-filter-content"> |
| 550 |
<?php |
| 551 |
$yatra_sidebar_cb_rows = []; |
| 552 |
foreach ($included_services as $service) { |
| 553 |
$yatra_sidebar_cb_rows[] = [ |
| 554 |
'value' => $service->service_name, |
| 555 |
'label' => $service->service_name, |
| 556 |
'count' => (int) $service->trip_count, |
| 557 |
]; |
| 558 |
} |
| 559 |
$yatra_sidebar_cb_input_name = 'services[]'; |
| 560 |
$yatra_sidebar_cb_active = $active_filters['services'] ?? []; |
| 561 |
include __DIR__ . '/partials/listing-sidebar-collapsible-checkboxes.php'; |
| 562 |
unset($yatra_sidebar_cb_rows, $yatra_sidebar_cb_input_name, $yatra_sidebar_cb_active); |
| 563 |
?> |
| 564 |
</div> |
| 565 |
</div> |
| 566 |
<?php endif; ?> |
| 567 |
|
| 568 |
<!-- Special Offers --> |
| 569 |
<?php |
| 570 |
// Get special offers from service |
| 571 |
$special_offers = $filter_data['special_offers'] ?? []; |
| 572 |
|
| 573 |
if (!empty($special_offers)) : |
| 574 |
?> |
| 575 |
<div class="yatra-filter-section"> |
| 576 |
<div class="yatra-filter-title" data-toggle="offers"> |
| 577 |
<div class="yatra-filter-title-content"> |
| 578 |
<svg class="yatra-filter-icon" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 579 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"/> |
| 580 |
</svg> |
| 581 |
<span><?php esc_html_e('Special Offers', 'yatra'); ?></span> |
| 582 |
</div> |
| 583 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 584 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 585 |
</svg> |
| 586 |
</div> |
| 587 |
<div class="yatra-filter-content"> |
| 588 |
<?php |
| 589 |
$yatra_sidebar_cb_rows = []; |
| 590 |
foreach ($special_offers as $offer) { |
| 591 |
$yatra_sidebar_cb_rows[] = [ |
| 592 |
'value' => $offer->value, |
| 593 |
'label' => $offer->label, |
| 594 |
'count' => (int) $offer->count, |
| 595 |
]; |
| 596 |
} |
| 597 |
$yatra_sidebar_cb_input_name = 'offers[]'; |
| 598 |
$yatra_sidebar_cb_active = $active_filters['offers'] ?? []; |
| 599 |
include __DIR__ . '/partials/listing-sidebar-collapsible-checkboxes.php'; |
| 600 |
unset($yatra_sidebar_cb_rows, $yatra_sidebar_cb_input_name, $yatra_sidebar_cb_active); |
| 601 |
?> |
| 602 |
</div> |
| 603 |
</div> |
| 604 |
<?php endif; ?> |
| 605 |
|
| 606 |
<!-- Booking Options --> |
| 607 |
<?php |
| 608 |
// Get booking options from service |
| 609 |
$booking_options = $filter_data['booking_options'] ?? []; |
| 610 |
|
| 611 |
if (!empty($booking_options)) : |
| 612 |
?> |
| 613 |
<div class="yatra-filter-section"> |
| 614 |
<div class="yatra-filter-title" data-toggle="booking"> |
| 615 |
<div class="yatra-filter-title-content"> |
| 616 |
<svg class="yatra-filter-icon" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 617 |
<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"/> |
| 618 |
</svg> |
| 619 |
<span><?php esc_html_e('Booking Options', 'yatra'); ?></span> |
| 620 |
</div> |
| 621 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 622 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 623 |
</svg> |
| 624 |
</div> |
| 625 |
<div class="yatra-filter-content"> |
| 626 |
<?php |
| 627 |
$yatra_sidebar_cb_rows = []; |
| 628 |
foreach ($booking_options as $option) { |
| 629 |
$yatra_sidebar_cb_rows[] = [ |
| 630 |
'value' => $option->value, |
| 631 |
'label' => $option->label, |
| 632 |
'count' => (int) $option->count, |
| 633 |
]; |
| 634 |
} |
| 635 |
$yatra_sidebar_cb_input_name = 'booking[]'; |
| 636 |
$yatra_sidebar_cb_active = $active_filters['booking'] ?? []; |
| 637 |
include __DIR__ . '/partials/listing-sidebar-collapsible-checkboxes.php'; |
| 638 |
unset($yatra_sidebar_cb_rows, $yatra_sidebar_cb_input_name, $yatra_sidebar_cb_active); |
| 639 |
?> |
| 640 |
</div> |
| 641 |
</div> |
| 642 |
<?php endif; ?> |
| 643 |
|
| 644 |
<!-- Age Suitability --> |
| 645 |
<?php |
| 646 |
// Get age restrictions from service |
| 647 |
$age_options = $filter_data['age_restrictions'] ?? []; |
| 648 |
|
| 649 |
if (!empty($age_options)) : |
| 650 |
?> |
| 651 |
<div class="yatra-filter-section"> |
| 652 |
<div class="yatra-filter-title" data-toggle="age"> |
| 653 |
<div class="yatra-filter-title-content"> |
| 654 |
<svg class="yatra-filter-icon" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 655 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/> |
| 656 |
</svg> |
| 657 |
<span><?php esc_html_e('Age Suitability', 'yatra'); ?></span> |
| 658 |
</div> |
| 659 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 660 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 661 |
</svg> |
| 662 |
</div> |
| 663 |
<div class="yatra-filter-content"> |
| 664 |
<?php |
| 665 |
$yatra_sidebar_cb_rows = []; |
| 666 |
foreach ($age_options as $option) { |
| 667 |
$yatra_sidebar_cb_rows[] = [ |
| 668 |
'value' => $option->value, |
| 669 |
'label' => $option->label, |
| 670 |
'count' => (int) $option->count, |
| 671 |
]; |
| 672 |
} |
| 673 |
$yatra_sidebar_cb_input_name = 'age[]'; |
| 674 |
$yatra_sidebar_cb_active = $active_filters['age'] ?? []; |
| 675 |
include __DIR__ . '/partials/listing-sidebar-collapsible-checkboxes.php'; |
| 676 |
unset($yatra_sidebar_cb_rows, $yatra_sidebar_cb_input_name, $yatra_sidebar_cb_active); |
| 677 |
?> |
| 678 |
</div> |
| 679 |
</div> |
| 680 |
<?php endif; ?> |
| 681 |
|
| 682 |
<!-- Trip Attributes Filter --> |
| 683 |
<?php if (is_array($yatra_trip_list) && !empty($yatra_trip_list['attributes'])) : ?> |
| 684 |
<div class="yatra-filter-section"> |
| 685 |
<div class="yatra-filter-title" data-toggle="trip-attributes"> |
| 686 |
<div class="yatra-filter-title-content"> |
| 687 |
<svg class="yatra-filter-icon" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 688 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"/> |
| 689 |
</svg> |
| 690 |
<span><?php esc_html_e('Trip Attributes', 'yatra'); ?></span> |
| 691 |
</div> |
| 692 |
<div class="yatra-filter-actions"> |
| 693 |
<span class="yatra-clear-section" data-section="trip-attributes" title="<?php esc_attr_e('Clear trip attribute filters', 'yatra'); ?>"> |
| 694 |
<svg width="14" height="14" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 695 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/> |
| 696 |
</svg> |
| 697 |
</span> |
| 698 |
<svg class="yatra-filter-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 699 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 700 |
</svg> |
| 701 |
</div> |
| 702 |
</div> |
| 703 |
<div class="yatra-filter-content"> |
| 704 |
<?php foreach ($yatra_trip_list['attributes'] as $attribute) : ?> |
| 705 |
<?php |
| 706 |
$attribute_filter_name = 'attributes[' . $attribute['id'] . ']'; |
| 707 |
$current_values = $active_filters['attributes'][$attribute['id']] ?? []; |
| 708 |
|
| 709 |
$field_options = []; |
| 710 |
if (!empty($attribute['field_options'])) { |
| 711 |
$field_options = is_array($attribute['field_options']) ? |
| 712 |
$attribute['field_options'] : |
| 713 |
(json_decode($attribute['field_options'], true) ?: []); |
| 714 |
} |
| 715 |
?> |
| 716 |
|
| 717 |
<div class="yatra-attribute-item"> |
| 718 |
<div class="yatra-attribute-label"> |
| 719 |
<?php if (!empty($attribute['icon'])) : ?> |
| 720 |
<?php |
| 721 |
$icon_data = maybe_unserialize($attribute['icon']); |
| 722 |
if (is_array($icon_data) && $icon_data['type'] === 'image' && !empty($icon_data['value'])) { |
| 723 |
$image_url = ''; |
| 724 |
if (is_numeric($icon_data['value'])) { |
| 725 |
$image_url = wp_get_attachment_image_url((int) $icon_data['value'], 'thumbnail'); |
| 726 |
} elseif (is_string($icon_data['value']) && filter_var($icon_data['value'], FILTER_VALIDATE_URL)) { |
| 727 |
$image_url = $icon_data['value']; |
| 728 |
} |
| 729 |
if (!empty($image_url)) { |
| 730 |
echo '<img class="yatra-attribute-icon" src="' . esc_url($image_url) . '" alt="' . esc_attr($attribute['name']) . '" width="16" height="16">'; |
| 731 |
} |
| 732 |
} elseif (is_array($icon_data) && $icon_data['type'] === 'icon' && !empty($icon_data['value'])) { |
| 733 |
echo '<span class="yatra-attribute-icon">' . yatra_svg_icon($icon_data['value'], '') . '</span>'; |
| 734 |
} |
| 735 |
?> |
| 736 |
<?php endif; ?> |
| 737 |
<span class="yatra-attribute-name"><?php echo esc_html($attribute['name']); ?></span> |
| 738 |
</div> |
| 739 |
<div class="yatra-attribute-content"> |
| 740 |
<?php if (($attribute['field_type'] === 'select' || $attribute['field_type'] === 'radio') && !empty($field_options)) : ?> |
| 741 |
<?php |
| 742 |
$yatra_sidebar_cb_rows = []; |
| 743 |
foreach ($field_options as $option) { |
| 744 |
$yatra_sidebar_cb_rows[] = [ |
| 745 |
'value' => $option['value'], |
| 746 |
'label' => $option['label'], |
| 747 |
]; |
| 748 |
} |
| 749 |
$yatra_sidebar_cb_input_name = $attribute_filter_name . '[]'; |
| 750 |
$yatra_sidebar_cb_active = $current_values; |
| 751 |
include __DIR__ . '/partials/listing-sidebar-collapsible-checkboxes.php'; |
| 752 |
unset($yatra_sidebar_cb_rows, $yatra_sidebar_cb_input_name, $yatra_sidebar_cb_active); |
| 753 |
?> |
| 754 |
|
| 755 |
<?php elseif ($attribute['field_type'] === 'checkbox' && !empty($field_options)) : ?> |
| 756 |
<?php |
| 757 |
$yatra_sidebar_cb_rows = []; |
| 758 |
foreach ($field_options as $option) { |
| 759 |
$yatra_sidebar_cb_rows[] = [ |
| 760 |
'value' => $option['value'], |
| 761 |
'label' => $option['label'], |
| 762 |
]; |
| 763 |
} |
| 764 |
$yatra_sidebar_cb_input_name = $attribute_filter_name . '[]'; |
| 765 |
$yatra_sidebar_cb_active = is_array($current_values) ? $current_values : []; |
| 766 |
include __DIR__ . '/partials/listing-sidebar-collapsible-checkboxes.php'; |
| 767 |
unset($yatra_sidebar_cb_rows, $yatra_sidebar_cb_input_name, $yatra_sidebar_cb_active); |
| 768 |
?> |
| 769 |
|
| 770 |
<?php elseif ($attribute['field_type'] === 'checkbox') : ?> |
| 771 |
<div class="yatra-checkbox-group"> |
| 772 |
<label class="yatra-checkbox-label"> |
| 773 |
<input |
| 774 |
type="checkbox" |
| 775 |
name="<?php echo esc_attr($attribute_filter_name); ?>" |
| 776 |
value="1" |
| 777 |
<?php echo in_array('1', (array) $current_values, true) ? 'checked' : ''; ?> |
| 778 |
> |
| 779 |
<span><?php _e('Yes', 'yatra'); ?></span> |
| 780 |
</label> |
| 781 |
</div> |
| 782 |
|
| 783 |
<?php elseif ($attribute['field_type'] === 'number') : ?> |
| 784 |
<div class="yatra-input-group"> |
| 785 |
<input |
| 786 |
type="number" |
| 787 |
name="<?php echo esc_attr($attribute_filter_name); ?>[min]" |
| 788 |
placeholder="<?php esc_attr_e('Min', 'yatra'); ?>" |
| 789 |
value="<?php echo esc_attr($current_values['min'] ?? ''); ?>" |
| 790 |
class="yatra-filter-input" |
| 791 |
> |
| 792 |
<input |
| 793 |
type="number" |
| 794 |
name="<?php echo esc_attr($attribute_filter_name); ?>[max]" |
| 795 |
placeholder="<?php esc_attr_e('Max', 'yatra'); ?>" |
| 796 |
value="<?php echo esc_attr($current_values['max'] ?? ''); ?>" |
| 797 |
class="yatra-filter-input" |
| 798 |
> |
| 799 |
</div> |
| 800 |
|
| 801 |
<?php elseif ($attribute['field_type'] === 'date') : ?> |
| 802 |
<div class="yatra-input-group"> |
| 803 |
<input |
| 804 |
type="date" |
| 805 |
name="<?php echo esc_attr($attribute_filter_name); ?>[from]" |
| 806 |
value="<?php echo esc_attr($current_values['from'] ?? ''); ?>" |
| 807 |
class="yatra-filter-input" |
| 808 |
> |
| 809 |
<input |
| 810 |
type="date" |
| 811 |
name="<?php echo esc_attr($attribute_filter_name); ?>[to]" |
| 812 |
value="<?php echo esc_attr($current_values['to'] ?? ''); ?>" |
| 813 |
class="yatra-filter-input" |
| 814 |
> |
| 815 |
</div> |
| 816 |
|
| 817 |
<?php else : ?> |
| 818 |
<input |
| 819 |
type="text" |
| 820 |
name="<?php echo esc_attr($attribute_filter_name); ?>" |
| 821 |
placeholder="<?php esc_attr_e('Type to filter…', 'yatra'); ?>" |
| 822 |
value="<?php echo esc_attr(implode(', ', $current_values)); ?>" |
| 823 |
class="yatra-filter-input" |
| 824 |
> |
| 825 |
<?php endif; ?> |
| 826 |
</div> |
| 827 |
</div> |
| 828 |
<?php endforeach; ?> |
| 829 |
</div> |
| 830 |
</div> |
| 831 |
<?php endif; ?> |
| 832 |
|
| 833 |
</aside> |
| 834 |
|
| 835 |
<!-- Main Content Area --> |
| 836 |
<main class="yatra-listing-content"> |
| 837 |
<?php if (count($trips_source) > 0) : ?> |
| 838 |
<div class="yatra-trip-grid" id="trip-grid"> |
| 839 |
<?php foreach ($trips_source as $trip) : ?> |
| 840 |
<!-- Use the reusable trip-listing-card.php component --> |
| 841 |
<?php include(dirname(__FILE__) . '/trip-listing-card.php'); ?> |
| 842 |
<?php endforeach; ?> |
| 843 |
</div> |
| 844 |
<?php else : ?> |
| 845 |
<div class="yatra-empty-state text-center py-12"> |
| 846 |
<svg class="mx-auto h-8 w-8 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true"> |
| 847 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.172 16.172a4 4 0 015.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /> |
| 848 |
</svg> |
| 849 |
<h3 class="mt-2 text-lg font-medium text-gray-900 dark:text-gray-100"><?php esc_html_e('No trips found', 'yatra'); ?></h3> |
| 850 |
<p class="mt-1 text-gray-500 dark:text-gray-400"><?php esc_html_e('Try adjusting your search or filter to find what you\'re looking for.', 'yatra'); ?></p> |
| 851 |
</div> |
| 852 |
<?php endif; ?> |
| 853 |
|
| 854 |
<div class="yatra-listing-pagination yatra-listing-pagination--trip-content"> |
| 855 |
<?php |
| 856 |
$prev_url = $yatra_pagination['prev_url'] ?? null; |
| 857 |
$next_url = $yatra_pagination['next_url'] ?? null; |
| 858 |
$prev_disabled = empty($prev_url); |
| 859 |
$next_disabled = empty($next_url); |
| 860 |
?> |
| 861 |
<a class="yatra-pagination-btn <?php echo $prev_disabled ? 'disabled' : ''; ?>" href="<?php echo $prev_disabled ? 'javascript:void(0);' : esc_url($prev_url); ?>"> |
| 862 |
<?php echo yatra_svg_icon('chevron-left', 'yatra-btn-icon'); ?> |
| 863 |
<span><?php esc_html_e('Previous', 'yatra'); ?></span> |
| 864 |
</a> |
| 865 |
<?php foreach (($yatra_pagination['items'] ?? []) as $pitem) : ?> |
| 866 |
<?php if (($pitem['type'] ?? '') === 'ellipsis') : ?> |
| 867 |
<span class="yatra-pagination-ellipsis">...</span> |
| 868 |
<?php elseif (($pitem['type'] ?? '') === 'page') : ?> |
| 869 |
<a class="yatra-pagination-btn <?php echo !empty($pitem['is_current']) ? 'active' : ''; ?>" href="<?php echo esc_url((string) ($pitem['url'] ?? '')); ?>"> |
| 870 |
<?php echo esc_html((string) ($pitem['page'] ?? '')); ?> |
| 871 |
</a> |
| 872 |
<?php endif; ?> |
| 873 |
<?php endforeach; ?> |
| 874 |
<a class="yatra-pagination-btn <?php echo $next_disabled ? 'disabled' : ''; ?>" href="<?php echo $next_disabled ? 'javascript:void(0);' : esc_url($next_url); ?>"> |
| 875 |
<span><?php esc_html_e('Next', 'yatra'); ?></span> |
| 876 |
<?php echo yatra_svg_icon('chevron-right', 'yatra-btn-icon'); ?> |
| 877 |
</a> |
| 878 |
</div> |
| 879 |
</main> |
| 880 |
</div> |
| 881 |
</div> |
| 882 |
</div> |
| 883 |
</div> |
| 884 |
|
| 885 |
<?php |
| 886 |
yatra_get_footer(); |
| 887 |
?> |
| 888 |
|