Updated the flow of search result page

This commit is contained in:
vishalsingh.qlo325
2025-02-05 11:48:53 +05:30
parent 950b37ed1c
commit 0c5ef158fb
11 changed files with 67 additions and 36 deletions

View File

@@ -140,12 +140,15 @@ class CategoryControllerCore extends FrontController
$id_category = Tools::getValue('id_category');
$displayAllRooms = false;
if (!($date_from = Tools::getValue('date_from'))) {
$date_from = date('Y-m-d');
$date_to = date('Y-m-d', strtotime($date_from) + 86400);
$displayAllRooms = true;
}
if (!($date_to = Tools::getValue('date_to'))) {
$date_to = date('Y-m-d', strtotime($date_from) + 86400);
$displayAllRooms = true;
}
// get occupancy of the search
@@ -180,6 +183,10 @@ class CategoryControllerCore extends FrontController
'id_guest' => $id_guest,
);
if ($displayAllRooms) {
$bookingParams['room_info_detailed'] = 1;
}
$booking_data = $objBookingDetail->dataForFrontSearch($bookingParams);
$num_days = $objBookingDetail->getNumberOfDays($date_from, $date_to);
@@ -206,7 +213,8 @@ class CategoryControllerCore extends FrontController
'booking_date_to' => $date_to,
'booking_data' => $booking_data,
'max_order_date' => $max_order_date,
'order_date_restrict' => $order_date_restrict
'order_date_restrict' => $order_date_restrict,
'display_all_rooms' => $displayAllRooms
));
} else {
Tools::redirect($this->context->link->getPageLink('pagenotfound'));
@@ -261,8 +269,18 @@ class CategoryControllerCore extends FrontController
$this->display_header = false;
$this->display_footer = false;
$date_from = Tools::getValue('date_from');
$date_to = Tools::getValue('date_to');
$displayAllRooms = false;
if (!($date_from = Tools::getValue('date_from'))) {
$date_from = date('Y-m-d H:i:s');
$date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400);
$displayAllRooms = true;
}
if (!($date_to = Tools::getValue('date_to'))) {
$date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400);
$displayAllRooms = true;
}
$htl_id_category = Tools::getValue('id_category');
// occupancy of the search
@@ -317,6 +335,10 @@ class CategoryControllerCore extends FrontController
'id_guest' => $this->context->cookie->id_guest,
);
if ($displayAllRooms) {
$bookingParams['room_info_detailed'] = 1;
}
$booking_data = $objBookingDetail->dataForFrontSearch($bookingParams);
// reset array keys from 0
$booking_data['rm_data'] = array_values($booking_data['rm_data']);

View File

@@ -395,6 +395,11 @@ class Blockcart extends Module
$this->context->controller->addCSS(($this->_path).'blockcart.css', 'all');
if ((int) (Configuration::get('PS_BLOCK_CART_AJAX'))) {
Media::addJsDef(
array(
'room_selection_error_message' => $this->l('You must check room availability before adding them to the cart.', null, true)
)
);
$this->context->controller->addJS(($this->_path).'ajax-cart.js');
$this->context->controller->addJqueryPlugin(array('scrollTo', 'serialScroll', 'bxslider'));
}

View File

@@ -240,6 +240,10 @@ class HotelBookingDetail extends ObjectModel
$params['full_detail'] = 0;
}
if (!isset($params['room_info_detailed'])) {
$params['room_info_detailed'] = 0;
}
Hook::exec('actionBookingDataParamsModifier', array('params' => &$params));
return $params;
@@ -1704,7 +1708,7 @@ class HotelBookingDetail extends ObjectModel
unset($bookingData['rm_data'][$key]);
continue;
}
if (count($value['data']['available'])) {
if (count($value['data']['available']) || $room_info_detailed) {
$prod_price = Product::getPriceStatic($value['id_product'], self::useTax());
$productPriceWithoutReduction = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 1, 0);
$cover_image_arr = Product::getCover($value['id_product']);

View File

@@ -167,7 +167,6 @@ class wkhotelfilterblock extends Module
public function hookDisplayLeftColumn()
{
if ($this->context->controller->php_self == 'category') {
$htl_id_category = Tools::getValue('id_category');
if (Validate::isLoadedObject($objCategory = new Category((int) $htl_id_category))
&& ($id_hotel = HotelBranchInformation::getHotelIdByIdCategory($htl_id_category))
@@ -184,13 +183,22 @@ class wkhotelfilterblock extends Module
$max_child = HotelRoomType::getMaxChild($id_hotel);
$category = new Category($htl_id_category);
$urlData = array ();
if (!($date_from = Tools::getValue('date_from'))) {
$date_from = date('Y-m-d');
$date_to = date('Y-m-d', strtotime($date_from) + 86400);
$date_from = date('Y-m-d H:i:s');
$date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400);
} else {
$urlData['date_from'] = $date_from;
}
if (!($date_to = Tools::getValue('date_to'))) {
$date_to = date('Y-m-d', strtotime($date_from) + 86400);
$date_to = date('Y-m-d H:i:s', strtotime($date_from) + 86400);
} else {
$urlData['date_from'] = $date_to;
}
if ($occupancy = Tools::getValue('occupancy')) {
$urlData['occupancy'] = $occupancy;
}
$obj_rm_type = new HotelRoomType();
@@ -204,13 +212,6 @@ class wkhotelfilterblock extends Module
}
// Create URL of category
$occupancy = Tools::getValue('occupancy');
$urlData = array (
'date_from' => $date_from,
'date_to' => $date_to,
'occupancy' => $occupancy,
);
if (Configuration::get('PS_REWRITING_SETTINGS')) {
$categoryUrl = $this->context->link->getCategoryLink(
new Category($htl_id_category, $this->context->language->id),

View File

@@ -176,17 +176,8 @@ class WkRoomSearchHelper
if ($locationCategoryId) {
$objLocationCategory = new Category($locationCategoryId, $context->language->id);
$searchedData['location'] = $objLocationCategory->name;
} else {
$locationCategoryId = $objCategory->id_parent;
if ($searchedData['htl_dtl']) {
$searchedData['location'] = $searchedData['htl_dtl']['city'];
if (isset($searchedData['htl_dtl']['state_name'])) {
$searchedData['location'] .= ', '.$searchedData['htl_dtl']['state_name'];
}
$searchedData['location'] .= ', '.$searchedData['htl_dtl']['country_name'];
}
$searchedData['location_category_id'] = $locationCategoryId;
}
$searchedData['location_category_id'] = $locationCategoryId;
$searchedData['order_date_restrict'] = false;
$max_order_date = HotelOrderRestrictDate::getMaxOrderDate($idHotel);
@@ -224,7 +215,7 @@ class WkRoomSearchHelper
}
// if location is enabled the send hotels of the selected location only
if ($locationEnabled) {
if ($locationEnabled && $locationCategoryId) {
$hotelsInfo = Category::getAllCategoriesName($locationCategoryId);
}
}

View File

@@ -115,6 +115,8 @@ const BookingSearchManager = {
}
}
});
} else {
$('#location_category_id').val('');
}
}
},

View File

@@ -25,8 +25,8 @@
{if isset($location_enabled) && $location_enabled}
<div class="form-group grid-item area-4">
<div class="dropdown">
<input type="text" class="form-control header-rmsearch-input input-location" id="hotel_location" name="hotel_location" autocomplete="off" placeholder="{l s='Hotel Location' mod='wkroomsearchblock'}" {if isset($search_data)}value="{$search_data['location']|escape:'htmlall':'UTF-8'}"{/if}>
<input hidden="hidden" name="location_category_id" id="location_category_id" {if isset($search_data)}value="{$search_data['location_category_id']|escape:'htmlall':'UTF-8'}"{/if}>
<input type="text" class="form-control header-rmsearch-input input-location" id="hotel_location" name="hotel_location" autocomplete="off" placeholder="{l s='Hotel Location' mod='wkroomsearchblock'}" {if isset($search_data['location'])}value="{$search_data['location']|escape:'htmlall':'UTF-8'}"{/if}>
<input hidden="hidden" name="location_category_id" id="location_category_id" {if isset($search_data['location_category_id'])}value="{$search_data['location_category_id']|escape:'htmlall':'UTF-8'}"{/if}>
<ul class="location_search_results_ul dropdown-menu"></ul>
</div>
</div>

View File

@@ -181,7 +181,7 @@
{block name='occupancy_field_actions'}
<div class="occupancy_block_actions">
<span class="add_occupancy_block">
<a class="add_new_occupancy_btn{if isset($occupancies) && $occupancies && isset($total_available_rooms) && $total_available_rooms <= count($occupancies)} disabled{/if}" data-title-available="{l s='Click to add more rooms.'}" data-title-unavailable="{l s='No more rooms available.'}" href="#">
<a class="add_new_occupancy_btn {if isset($occupancies) && $occupancies && isset($total_available_rooms) && $total_available_rooms <= count($occupancies) || isset($display_all_rooms) && $display_all_rooms} disabled{/if}" data-title-available="{l s='Click to add more rooms.'}" data-title-unavailable="{l s='No more rooms available.'}" href="#">
<i class="icon-plus"></i>
<span>{l s='Add Room'}</span>
</a>

View File

@@ -20,9 +20,9 @@
{block name='displayRoomTypeListBefore'}
{hook h='displayRoomTypeListBefore'}
{/block}
{if isset($booking_data['stats']) && $booking_data['stats']['num_avail']}
{if isset($booking_data['stats']) && $booking_data['stats']['num_avail'] || isset($display_all_rooms) && $display_all_rooms}
{foreach from=$booking_data['rm_data'] key=room_k item=room_v}
{if $room_v['data']['available']|count}
{if $room_v['data']['available']|count || isset($display_all_rooms) && $display_all_rooms }
<div class="col-sm-12 room_cont" data-id-product="{$room_v['id_product']|escape:'htmlall':'UTF-8'}">
<div class="row">
{block name='room_type_list_room_image'}
@@ -41,7 +41,7 @@
<div class="row">
<p class="rm_heading col-sm-12 col-md-7">{$room_v['name']|escape:'htmlall':'UTF-8'}</p>
{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict}
<p class="rm_left col-sm-12 col-md-5" {if $room_v['room_left'] > $warning_num} style="display:none"{/if}>
<p class="rm_left col-sm-12 col-md-5" {if isset($display_all_rooms) && $display_all_rooms || $room_v['room_left'] > $warning_num} style="display:none"{/if}>
{l s='Hurry!'} <span class="remain_rm_qty">{$room_v['room_left']|escape:'htmlall':'UTF-8'}</span> {l s='rooms left'}
</p>
{/if}
@@ -115,7 +115,7 @@
{/if}
{block name='room_type_list_room_book_now_button'}
<div>
<a cat_rm_check_in="{$booking_date_from|escape:'htmlall':'UTF-8'}" cat_rm_check_out="{$booking_date_to|escape:'htmlall':'UTF-8'}" href="" rm_product_id="{$room_v['id_product']}" cat_rm_book_nm_days="{$num_days|escape:'htmlall':'UTF-8'}" data-id-product-attribute="0" data-id-product="{$room_v['id_product']|intval}" class="btn btn-default button button-medium ajax_add_to_cart_button"><span>{l s='Book Now'}</span></a>
<a cat_rm_check_in="{$booking_date_from|escape:'htmlall':'UTF-8'}" cat_rm_check_out="{$booking_date_to|escape:'htmlall':'UTF-8'}" href="" rm_product_id="{$room_v['id_product']}" cat_rm_book_nm_days="{$num_days|escape:'htmlall':'UTF-8'}" data-id-product-attribute="0" data-id-product="{$room_v['id_product']|intval}" class="btn btn-default button button-medium ajax_add_to_cart_button {if isset($display_all_rooms) && $display_all_rooms} display_type_room_list {/if}"><span>{l s='Book Now'}</span></a>
</div>
{/block}
{/if}

View File

@@ -146,8 +146,11 @@ var ajaxCart = {
// var minimalQuantity = $("#quantity_wanted_" + idProduct).val();
// if (!minimalQuantity)
// minimalQuantity = 1;
if ($(this).prop('disabled') != 'disabled' && occupancy)
if ($(this).prop('disabled') != 'disabled' && occupancy && !$(this).hasClass('display_type_room_list')) {
ajaxCart.add(idProduct, idProductAttribute, false, this, occupancy, null, dateFrom, dateTo);
} else if ($(this).hasClass('display_type_room_list') && occupancy) {
showErrorMessage(room_selection_error_message);
}
});
//for product page 'add' button...
if ($('.cart_block').length) {
@@ -1366,4 +1369,4 @@ function getBookingOccupancyDetails(bookingform)
}
return occupancy;
}
}

View File

@@ -235,6 +235,9 @@ $(document).ready(function(){
$(document).on('click', '.booking_occupancy_wrapper .add_new_occupancy_btn', function(e) {
e.preventDefault();
if ($(this).hasClass('disabled')) {
return;
}
var booking_occupancy_wrapper = $(this).closest('.booking_occupancy_wrapper');
var occupancy_block = '';