From f2513b0f905c857a98dbc1a4c081ca64110050b5 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 14 Aug 2024 12:35:02 +0530 Subject: [PATCH 1/6] Updated: Optimized data for front search function --- classes/Product.php | 14 ++ .../classes/HotelBookingDetail.php | 152 +++++++----------- .../classes/HotelRoomType.php | 15 +- .../wkhotelfilterblock/wkhotelfilterblock.php | 2 +- .../_partials/room_type_list.tpl | 136 ++++++++-------- 5 files changed, 150 insertions(+), 169 deletions(-) diff --git a/classes/Product.php b/classes/Product.php index c47bb1f04..1cf2c0841 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3494,6 +3494,20 @@ public function getPriceWithoutReduct($notax = false, $id_product_attribute = fa return $price; } + public static function getPriceWithoutReductStatic($id_product, $notax = false, $id_product_attribute = false, $decimals = 6, $with_auto_add_services = 0) + { + $price = Product::getPriceStatic((int)$id_product, !$notax, $id_product_attribute, $decimals, null, false, false); + if ($with_auto_add_services) { + if ($services = RoomTypeServiceProduct::getAutoAddServices((int) $id_product, null, null, Product::PRICE_ADDITION_TYPE_WITH_ROOM, !$notax)) { + foreach($services as $service) { + $price += $service['price']; + } + } + } + + return $price; + } + /** * Display price with right format and currency * diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 77dafade5..8d0bfd22c 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -222,9 +222,6 @@ public function getBookingDataParams($params) $params['occupancy'] = array(); } - if (!isset($params['ratting'])) { - $params['ratting'] = -1; - } if (!isset($params['amenities'])) { $params['amenities'] = 0; } @@ -236,6 +233,10 @@ public function getBookingDataParams($params) $params['only_search_data'] = 0; } + if (!isset($params['full_detail'])) { + $params['full_detail'] = 0; + } + return $params; } @@ -386,7 +387,7 @@ public function getBookingData($params) } // Now we will formate the data after geting search result according to search type - $roomTypesDetail = $objRoomType->getRoomTypeDetailByRoomTypeIds($allowedIdRoomTypes); + $roomTypesDetail = $objRoomType->getRoomTypeDetailByRoomTypeIds($allowedIdRoomTypes, true, $full_detail); if ($roomTypesDetail) { // Formate data for response $finalSearchResponse = array( @@ -401,15 +402,12 @@ public function getBookingData($params) $finalSearchResponse['stats']['total_rooms'] += $roomTypeDetail['numberOfRooms']; $idProduct = $roomTypeDetail['id_product']; - $roomTypeSearchData = array( - 'name' => (new Product((int) $idProduct, false, $this->context->cookie->id_lang))->name, - 'id_product' => $idProduct, - 'adults' => $roomTypeDetail['adults'], - 'children' => $roomTypeDetail['children'], - 'max_adults' => $roomTypeDetail['max_adults'], - 'max_children' => $roomTypeDetail['max_children'], - 'max_guests' => $roomTypeDetail['max_guests'], - 'data' => array(), + $roomTypeSearchData = array_merge( + $roomTypeDetail, + array( + 'id_product' => $idProduct, + 'data' => array(), + ) ); if ($search_unavai) { @@ -1500,7 +1498,6 @@ public function updateBookingOrderStatusByOrderId( * @param [int] $only_search_data [used for product page and category page for block cart] * @param [int] $adults [] * @param [int] $children [] - * @param [] $ratting [description] * @param [] $amenities [description] * @param [] $price [description] * @param [int] $id_cart [Id of the cart] @@ -1511,10 +1508,6 @@ public function updateBookingOrderStatusByOrderId( */ public function dataForFrontSearch($bookingParams) { - // if (Module::isInstalled('productcomments')) { - // require_once _PS_MODULE_DIR_.'productcomments/ProductComment.php'; - // } - $this->context = Context::getContext(); $bookingParams['search_available'] = 1; @@ -1522,6 +1515,7 @@ public function dataForFrontSearch($bookingParams) $bookingParams['search_booked'] = 0; $bookingParams['search_unavai'] = 0; + $bookingParams['full_detail'] = 1; $bookingData = $this->getBookingData($bookingParams); extract($this->getBookingDataParams($bookingParams)); @@ -1531,25 +1525,8 @@ public function dataForFrontSearch($bookingParams) $objRoomType = new HotelRoomType(); foreach ($bookingData['rm_data'] as $key => $value) { - if (empty($value['data']['available'])) { - unset($bookingData['rm_data'][$key]); - } else { - $prod_ratting = 0; - // if (Module::isInstalled('productcomments')) { - // $prod_ratting = ProductComment::getAverageGrade($value['id_product'])['grade']; - // } - // if (empty($prod_ratting)) { - // $prod_ratting = 0; - // } - - // if ($prod_ratting < $ratting && $ratting != -1) { - // unset($bookingData['rm_data'][$key]); - // } else - // { - $product = new Product($value['id_product'], false, $this->context->language->id); - - $product_feature = $product->getFrontFeaturesStatic($this->context->language->id, $value['id_product']); - + if (count($value['data']['available'])) { + $product_feature = Product::getFrontFeaturesStatic($this->context->language->id, $value['id_product']); $prod_amen = array(); if (!empty($amenities) && $amenities) { $prod_amen = $amenities; @@ -1563,72 +1540,51 @@ public function dataForFrontSearch($bookingParams) } if (!empty($prod_amen)) { unset($bookingData['rm_data'][$key]); + continue; } } + $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax()); + if (!empty($price) && ($price['from'] > $productFeaturePrice || $price['to'] < $productFeaturePrice)) { + unset($bookingData['rm_data'][$key]); + continue; + } - if (empty($prod_amen)) { - $prod_price = Product::getPriceStatic($value['id_product'], self::useTax()); - $productPriceWithoutReduction = $product->getPriceWithoutReduct(!self::useTax()); - $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax()); - $productFeaturePriceWithoutAutoAdd = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 0); - - if (empty($price) || ($price['from'] <= $prod_price && $price['to'] >= $prod_price)) { - $cover_image_arr = $product->getCover($value['id_product']); - - if (!empty($cover_image_arr)) { - $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id.'-'.$cover_image_arr['id_image'], 'home_default'); - } else { - $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code.'-default', 'home_default'); - } - - $room_left = count($bookingData['rm_data'][$key]['data']['available']); - - $rm_dtl = $objRoomType->getRoomTypeInfoByIdProduct($value['id_product']); - - $bookingData['rm_data'][$key]['name'] = $product->name; - $bookingData['rm_data'][$key]['image'] = $cover_img; - $bookingData['rm_data'][$key]['description'] = $product->description_short; - $bookingData['rm_data'][$key]['feature'] = $product_feature; - $bookingData['rm_data'][$key]['price'] = $prod_price; - $bookingData['rm_data'][$key]['feature_price'] = $productFeaturePrice; - $bookingData['rm_data'][$key]['feature_price_withoout_auto_add'] = $productFeaturePriceWithoutAutoAdd; - $bookingData['rm_data'][$key]['price_without_reduction'] = $productPriceWithoutReduction; - $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] = $productPriceWithoutReduction + ($productFeaturePrice - $productFeaturePriceWithoutAutoAdd); - $bookingData['rm_data'][$key]['feature_price_diff'] = $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] - $productFeaturePrice; - - // if ($room_left <= (int)Configuration::get('WK_ROOM_LEFT_WARNING_NUMBER')) - $bookingData['rm_data'][$key]['room_left'] = $room_left; - - $bookingData['rm_data'][$key]['adults'] = $rm_dtl['adults']; - $bookingData['rm_data'][$key]['children'] = $rm_dtl['children']; - - $bookingData['rm_data'][$key]['ratting'] = $prod_ratting; - // if (Module::isInstalled('productcomments')) { - // $bookingData['rm_data'][$key]['num_review'] = ProductComment::getCommentNumber($value['id_product']); - // } - - // create URL with the parameters from URL - $urlData = array ('date_from' => $date_from, 'date_to' => $date_to); - if (!isset($occupancy)) { - $occupancy = Tools::getValue('occupancy'); - } - if ($occupancy) { - $urlData['occupancy'] = $occupancy; - } - if ($location = Tools::getValue('location')) { - $urlData['location'] = $location; - } + $prod_price = Product::getPriceStatic($value['id_product'], self::useTax()); + $productPriceWithoutReduction = Product::getPriceWithoutReductStatic($value['id_product'], !self::useTax()); + $productFeaturePriceWithoutAutoAdd = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 0); + $cover_image_arr = Product::getCover($value['id_product']); + if (!empty($cover_image_arr)) { + $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $value['id_product'].'-'.$cover_image_arr['id_image'], 'home_default'); + } else { + $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $this->context->language->iso_code.'-default', 'home_default'); + } + $bookingData['rm_data'][$key]['image'] = $cover_img; + $bookingData['rm_data'][$key]['feature'] = $product_feature; + $bookingData['rm_data'][$key]['price'] = $prod_price; + $bookingData['rm_data'][$key]['feature_price'] = $productFeaturePrice; + $bookingData['rm_data'][$key]['feature_price_withoout_auto_add'] = $productFeaturePriceWithoutAutoAdd; + $bookingData['rm_data'][$key]['price_without_reduction'] = $productPriceWithoutReduction; + $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] = $productPriceWithoutReduction + ($productFeaturePrice - $productFeaturePriceWithoutAutoAdd); + $bookingData['rm_data'][$key]['feature_price_diff'] = $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] - $productFeaturePrice; + $bookingData['rm_data'][$key]['room_left'] = count($bookingData['rm_data'][$key]['data']['available']); + + // create URL with the parameters from URL + $urlData = array ('date_from' => $date_from, 'date_to' => $date_to); + if (!isset($occupancy)) { + $occupancy = Tools::getValue('occupancy'); + } + if ($occupancy) { + $urlData['occupancy'] = $occupancy; + } + if ($location = Tools::getValue('location')) { + $urlData['location'] = $location; + } - if (Configuration::get('PS_REWRITING_SETTINGS')) { - $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($product).'?'.http_build_query($urlData); - } else { - $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($product).'&'.http_build_query($urlData); - } - } else { - unset($bookingData['rm_data'][$key]); - } + if (Configuration::get('PS_REWRITING_SETTINGS')) { + $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'?'.http_build_query($urlData); + } else { + $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'&'.http_build_query($urlData); } - // } } } } diff --git a/modules/hotelreservationsystem/classes/HotelRoomType.php b/modules/hotelreservationsystem/classes/HotelRoomType.php index 6c0a80fd4..83ced3591 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomType.php +++ b/modules/hotelreservationsystem/classes/HotelRoomType.php @@ -281,17 +281,26 @@ public function getRoomTypeByHotelId($hotel_id, $id_lang, $active = 2) /** * @param [int] $roomTypesList: string of idRoomTypes seperated by "," */ - public function getRoomTypeDetailByRoomTypeIds($roomTypesList, $position = true) + public function getRoomTypeDetailByRoomTypeIds($roomTypesList, $position = true, $fullDetail = false, $idLang = false) { - $sql = 'SELECT COUNT(hri.`id`) AS `numberOfRooms`, hrt.`id_product`, `adults`, `children`, `max_adults`, `max_children`, `max_guests`'. - ($position ? ', cp.`position`' : '').' + if (!$idLang) { + $idLang = Context::getContext()->language->id; + } + + $sql = 'SELECT pl.`name`, COUNT(hri.`id`) AS `numberOfRooms`, hrt.`id_product`, `adults`, `children`, `max_adults`, `max_children`, `max_guests` + '.($position ? ', cp.`position`' : '').' + '.($fullDetail ? ', pl.`link_rewrite`, pl.`description_short`' : '').' FROM `'._DB_PREFIX_.'htl_room_type` AS `hrt` INNER JOIN `'._DB_PREFIX_.'htl_room_information` AS `hri` ON (hri.`id_product` = hrt.`id_product`)'; + $sql .= ' INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (hrt.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$idLang.')'; if ($position) { $sql .= ' INNER JOIN `'._DB_PREFIX_.'htl_branch_info` hbi ON (hbi.`id` = hrt.`id_hotel`) INNER JOIN `'._DB_PREFIX_.'category_product` cp ON cp.`id_category` = hbi.`id_category` AND cp.`id_product` = hrt.`id_product`'; } + if ($fullDetail) { + + } $sql .= 'WHERE hrt.`id_product` IN ('.$roomTypesList.') GROUP BY hrt.`id_product`'. diff --git a/modules/wkhotelfilterblock/wkhotelfilterblock.php b/modules/wkhotelfilterblock/wkhotelfilterblock.php index 8aa730452..c4208f16b 100644 --- a/modules/wkhotelfilterblock/wkhotelfilterblock.php +++ b/modules/wkhotelfilterblock/wkhotelfilterblock.php @@ -199,7 +199,7 @@ public function hookDisplayLeftColumn() $prod_price = array(); if ($room_types) { foreach ($room_types as $key => $value) { - $prod_price[] = Product::getPriceStatic($value['id_product'], HotelBookingDetail::useTax()); + $prod_price[] = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, HotelBookingDetail::useTax()); } } diff --git a/themes/hotel-reservation-theme/_partials/room_type_list.tpl b/themes/hotel-reservation-theme/_partials/room_type_list.tpl index b13241709..b14413d7f 100644 --- a/themes/hotel-reservation-theme/_partials/room_type_list.tpl +++ b/themes/hotel-reservation-theme/_partials/room_type_list.tpl @@ -18,87 +18,89 @@ *} {hook h='displayRoomTypeListBefore'} -{if isset($booking_data['rm_data']) && $booking_data['rm_data']} +{if isset($booking_data['stats']) && $booking_data['stats']['num_avail']} {foreach from=$booking_data['rm_data'] key=room_k item=room_v} -
-
- -
-
-

{$room_v['name']|escape:'htmlall':'UTF-8'}

- {if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict} -

$warning_num} style="display:none"{/if}> - {l s='Hurry!'} {$room_v['room_left']|escape:'htmlall':'UTF-8'} {l s='rooms left'} -

- {/if} + {if $room_v['data']['available']|count} +
+
+ -
{$room_v['description']|truncate:190:"":true} {l s='View More'}....
-
+
-
- {if !empty($room_v['feature'])} -

- {foreach from=$room_v['feature'] key=feat_k item=feat_v} - - {/foreach} -

- {/if} -
- -
- {if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict} - -

- {if $room_v['feature_price_diff'] >= 0} - - {displayPrice price = $room_v['price_without_reduction_with_auto_add']|round:2|floatVal} - - {/if} - {if $room_v['feature_price_diff']} - - {displayPrice price = $room_v['feature_price']|round:2|floatVal} - - {/if} - /{l s='Per Night'} -

- {/if} -
+

{$room_v['name']|escape:'htmlall':'UTF-8'}

+ {if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict} +

$warning_num} style="display:none"{/if}> + {l s='Hurry!'} {$room_v['room_left']|escape:'htmlall':'UTF-8'} {l s='rooms left'} +

+ {/if}
-
-
-
{$room_v['max_guests']|escape:'htmlall':'UTF-8'} {l s='Max guests:'}
{$room_v['max_adults']|escape:'htmlall':'UTF-8'} {l s='Adults'}, {$room_v['max_children']|escape:'htmlall':'UTF-8'} {if $room_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}
-
-
-
+
{$room_v['description_short']|truncate:190:"":true} {l s='View More'}....
+
+
+
+ {if !empty($room_v['feature'])} +

+ {foreach from=$room_v['feature'] key=feat_k item=feat_v} + + {/foreach} +

+ {/if} +
+ +
{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict} - {if isset($occupancy_required_for_booking) && $occupancy_required_for_booking} -
- {include file="./occupancy_field.tpl" room_type_info=$room_v total_available_rooms=$room_v['room_left']} -
- {else} + +

+ {if $room_v['feature_price_diff'] >= 0} + + {displayPrice price = $room_v['price_without_reduction_with_auto_add']|round:2|floatVal} + + {/if} + {if $room_v['feature_price_diff']} + + {displayPrice price = $room_v['feature_price']|round:2|floatVal} + + {/if} + /{l s='Per Night'} +

+ {/if} +
+
+
+
+
{$room_v['max_guests']|escape:'htmlall':'UTF-8'} {l s='Max guests:'}
{$room_v['max_adults']|escape:'htmlall':'UTF-8'} {l s='Adults'}, {$room_v['max_children']|escape:'htmlall':'UTF-8'} {if $room_v['children'] > 1}{l s='Children'}{else}{l s='Child'}{/if}
+
+
+
+ {if !isset($restricted_country_mode) && !$PS_CATALOG_MODE && !$order_date_restrict} + {if isset($occupancy_required_for_booking) && $occupancy_required_for_booking} +
+ {include file="./occupancy_field.tpl" room_type_info=$room_v total_available_rooms=$room_v['room_left']} +
+ {else} +
+ + {include file="./quantity_field.tpl" total_available_rooms=$room_v['room_left']} +
+ {/if}
- - {include file="./quantity_field.tpl" total_available_rooms=$room_v['room_left']} + {l s='Book Now'}
{/if} - - {/if} +
-
+ {/if} {/foreach} {else}
From 3728d59b47cf726ab68e443c844265a4a45b8a65 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 21 Aug 2024 20:11:09 +0530 Subject: [PATCH 2/6] update data for all search params --- .../classes/HotelBookingDetail.php | 102 +++++++++--------- .../classes/HotelRoomType.php | 3 - 2 files changed, 50 insertions(+), 55 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 8d0bfd22c..fb7bbde27 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1525,66 +1525,64 @@ public function dataForFrontSearch($bookingParams) $objRoomType = new HotelRoomType(); foreach ($bookingData['rm_data'] as $key => $value) { - if (count($value['data']['available'])) { - $product_feature = Product::getFrontFeaturesStatic($this->context->language->id, $value['id_product']); - $prod_amen = array(); - if (!empty($amenities) && $amenities) { - $prod_amen = $amenities; - foreach ($product_feature as $a_key => $a_val) { - if (($pa_key = array_search($a_val['id_feature'], $prod_amen)) !== false) { - unset($prod_amen[$pa_key]); - if (empty($prod_amen)) { - break; - } + $product_feature = Product::getFrontFeaturesStatic($this->context->language->id, $value['id_product']); + $prod_amen = array(); + if (!empty($amenities) && $amenities) { + $prod_amen = $amenities; + foreach ($product_feature as $a_key => $a_val) { + if (($pa_key = array_search($a_val['id_feature'], $prod_amen)) !== false) { + unset($prod_amen[$pa_key]); + if (empty($prod_amen)) { + break; } } - if (!empty($prod_amen)) { - unset($bookingData['rm_data'][$key]); - continue; - } } - $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax()); - if (!empty($price) && ($price['from'] > $productFeaturePrice || $price['to'] < $productFeaturePrice)) { + if (!empty($prod_amen)) { unset($bookingData['rm_data'][$key]); continue; } + } + $productFeaturePrice = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax()); + if (!empty($price) && ($price['from'] > $productFeaturePrice || $price['to'] < $productFeaturePrice)) { + unset($bookingData['rm_data'][$key]); + continue; + } - $prod_price = Product::getPriceStatic($value['id_product'], self::useTax()); - $productPriceWithoutReduction = Product::getPriceWithoutReductStatic($value['id_product'], !self::useTax()); - $productFeaturePriceWithoutAutoAdd = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 0); - $cover_image_arr = Product::getCover($value['id_product']); - if (!empty($cover_image_arr)) { - $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $value['id_product'].'-'.$cover_image_arr['id_image'], 'home_default'); - } else { - $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $this->context->language->iso_code.'-default', 'home_default'); - } - $bookingData['rm_data'][$key]['image'] = $cover_img; - $bookingData['rm_data'][$key]['feature'] = $product_feature; - $bookingData['rm_data'][$key]['price'] = $prod_price; - $bookingData['rm_data'][$key]['feature_price'] = $productFeaturePrice; - $bookingData['rm_data'][$key]['feature_price_withoout_auto_add'] = $productFeaturePriceWithoutAutoAdd; - $bookingData['rm_data'][$key]['price_without_reduction'] = $productPriceWithoutReduction; - $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] = $productPriceWithoutReduction + ($productFeaturePrice - $productFeaturePriceWithoutAutoAdd); - $bookingData['rm_data'][$key]['feature_price_diff'] = $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] - $productFeaturePrice; - $bookingData['rm_data'][$key]['room_left'] = count($bookingData['rm_data'][$key]['data']['available']); - - // create URL with the parameters from URL - $urlData = array ('date_from' => $date_from, 'date_to' => $date_to); - if (!isset($occupancy)) { - $occupancy = Tools::getValue('occupancy'); - } - if ($occupancy) { - $urlData['occupancy'] = $occupancy; - } - if ($location = Tools::getValue('location')) { - $urlData['location'] = $location; - } + $prod_price = Product::getPriceStatic($value['id_product'], self::useTax()); + $productPriceWithoutReduction = Product::getPriceWithoutReductStatic($value['id_product'], !self::useTax()); + $productFeaturePriceWithoutAutoAdd = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 0); + $cover_image_arr = Product::getCover($value['id_product']); + if (!empty($cover_image_arr)) { + $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $value['id_product'].'-'.$cover_image_arr['id_image'], 'home_default'); + } else { + $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $this->context->language->iso_code.'-default', 'home_default'); + } + $bookingData['rm_data'][$key]['image'] = $cover_img; + $bookingData['rm_data'][$key]['feature'] = $product_feature; + $bookingData['rm_data'][$key]['price'] = $prod_price; + $bookingData['rm_data'][$key]['feature_price'] = $productFeaturePrice; + $bookingData['rm_data'][$key]['feature_price_withoout_auto_add'] = $productFeaturePriceWithoutAutoAdd; + $bookingData['rm_data'][$key]['price_without_reduction'] = $productPriceWithoutReduction; + $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] = $productPriceWithoutReduction + ($productFeaturePrice - $productFeaturePriceWithoutAutoAdd); + $bookingData['rm_data'][$key]['feature_price_diff'] = $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] - $productFeaturePrice; + $bookingData['rm_data'][$key]['room_left'] = count($bookingData['rm_data'][$key]['data']['available']); + + // create URL with the parameters from URL + $urlData = array ('date_from' => $date_from, 'date_to' => $date_to); + if (!isset($occupancy)) { + $occupancy = Tools::getValue('occupancy'); + } + if ($occupancy) { + $urlData['occupancy'] = $occupancy; + } + if ($location = Tools::getValue('location')) { + $urlData['location'] = $location; + } - if (Configuration::get('PS_REWRITING_SETTINGS')) { - $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'?'.http_build_query($urlData); - } else { - $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'&'.http_build_query($urlData); - } + if (Configuration::get('PS_REWRITING_SETTINGS')) { + $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'?'.http_build_query($urlData); + } else { + $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'&'.http_build_query($urlData); } } } diff --git a/modules/hotelreservationsystem/classes/HotelRoomType.php b/modules/hotelreservationsystem/classes/HotelRoomType.php index 83ced3591..9d8bf89e8 100644 --- a/modules/hotelreservationsystem/classes/HotelRoomType.php +++ b/modules/hotelreservationsystem/classes/HotelRoomType.php @@ -298,9 +298,6 @@ public function getRoomTypeDetailByRoomTypeIds($roomTypesList, $position = true, $sql .= ' INNER JOIN `'._DB_PREFIX_.'htl_branch_info` hbi ON (hbi.`id` = hrt.`id_hotel`) INNER JOIN `'._DB_PREFIX_.'category_product` cp ON cp.`id_category` = hbi.`id_category` AND cp.`id_product` = hrt.`id_product`'; } - if ($fullDetail) { - - } $sql .= 'WHERE hrt.`id_product` IN ('.$roomTypesList.') GROUP BY hrt.`id_product`'. From 113b9ebcd535e55242cef01bbe7c7abe3ff61e82 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 29 Aug 2024 16:31:30 +0530 Subject: [PATCH 3/6] used feature price without reduction for showing price on serch result page --- classes/Product.php | 14 -------------- .../classes/HotelBookingDetail.php | 7 ++----- .../_partials/room_type_list.tpl | 2 +- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/classes/Product.php b/classes/Product.php index 84d36d0c2..862dd457d 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -3538,20 +3538,6 @@ public function getPriceWithoutReduct($notax = false, $id_product_attribute = fa return $price; } - public static function getPriceWithoutReductStatic($id_product, $notax = false, $id_product_attribute = false, $decimals = 6, $with_auto_add_services = 0) - { - $price = Product::getPriceStatic((int)$id_product, !$notax, $id_product_attribute, $decimals, null, false, false); - if ($with_auto_add_services) { - if ($services = RoomTypeServiceProduct::getAutoAddServices((int) $id_product, null, null, Product::PRICE_ADDITION_TYPE_WITH_ROOM, !$notax)) { - foreach($services as $service) { - $price += $service['price']; - } - } - } - - return $price; - } - /** * Display price with right format and currency * diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 93d6faa63..537aa3412 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1691,8 +1691,7 @@ public function dataForFrontSearch($bookingParams) } $prod_price = Product::getPriceStatic($value['id_product'], self::useTax()); - $productPriceWithoutReduction = Product::getPriceWithoutReductStatic($value['id_product'], !self::useTax()); - $productFeaturePriceWithoutAutoAdd = HotelRoomTypeFeaturePricing::getRoomTypeFeaturePricesPerDay($value['id_product'], $date_from, $date_to, self::useTax(), 0, 0, 0, 0, 0); + $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']); if (!empty($cover_image_arr)) { $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $value['id_product'].'-'.$cover_image_arr['id_image'], 'home_default'); @@ -1703,10 +1702,8 @@ public function dataForFrontSearch($bookingParams) $bookingData['rm_data'][$key]['feature'] = $product_feature; $bookingData['rm_data'][$key]['price'] = $prod_price; $bookingData['rm_data'][$key]['feature_price'] = $productFeaturePrice; - $bookingData['rm_data'][$key]['feature_price_withoout_auto_add'] = $productFeaturePriceWithoutAutoAdd; $bookingData['rm_data'][$key]['price_without_reduction'] = $productPriceWithoutReduction; - $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] = $productPriceWithoutReduction + ($productFeaturePrice - $productFeaturePriceWithoutAutoAdd); - $bookingData['rm_data'][$key]['feature_price_diff'] = $bookingData['rm_data'][$key]['price_without_reduction_with_auto_add'] - $productFeaturePrice; + $bookingData['rm_data'][$key]['feature_price_diff'] = $productPriceWithoutReduction - $productFeaturePrice; $bookingData['rm_data'][$key]['room_left'] = count($bookingData['rm_data'][$key]['data']['available']); // create URL with the parameters from URL diff --git a/themes/hotel-reservation-theme/_partials/room_type_list.tpl b/themes/hotel-reservation-theme/_partials/room_type_list.tpl index 34beec0fa..f72075d89 100644 --- a/themes/hotel-reservation-theme/_partials/room_type_list.tpl +++ b/themes/hotel-reservation-theme/_partials/room_type_list.tpl @@ -59,7 +59,7 @@

{if $room_v['feature_price_diff'] >= 0} - {displayPrice price = $room_v['price_without_reduction_with_auto_add']|round:2|floatVal} + {displayPrice price = $room_v['price_without_reduction']|round:2|floatVal} {/if} {if $room_v['feature_price_diff']} From 89b445fd5ee417b510c17e4e9946cbe22eb9ef4f Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 29 Aug 2024 16:41:58 +0530 Subject: [PATCH 4/6] in dataForFrontSearch only assign data when rooms are available --- .../classes/HotelBookingDetail.php | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index 537aa3412..e51d33789 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1689,39 +1689,40 @@ public function dataForFrontSearch($bookingParams) unset($bookingData['rm_data'][$key]); continue; } + if (count($value['data']['available'])) { + $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']); + if (!empty($cover_image_arr)) { + $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $value['id_product'].'-'.$cover_image_arr['id_image'], 'home_default'); + } else { + $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $this->context->language->iso_code.'-default', 'home_default'); + } + $bookingData['rm_data'][$key]['image'] = $cover_img; + $bookingData['rm_data'][$key]['feature'] = $product_feature; + $bookingData['rm_data'][$key]['price'] = $prod_price; + $bookingData['rm_data'][$key]['feature_price'] = $productFeaturePrice; + $bookingData['rm_data'][$key]['price_without_reduction'] = $productPriceWithoutReduction; + $bookingData['rm_data'][$key]['feature_price_diff'] = $productPriceWithoutReduction - $productFeaturePrice; + $bookingData['rm_data'][$key]['room_left'] = count($bookingData['rm_data'][$key]['data']['available']); + + // create URL with the parameters from URL + $urlData = array ('date_from' => $date_from, 'date_to' => $date_to); + if (!isset($occupancy)) { + $occupancy = Tools::getValue('occupancy'); + } + if ($occupancy) { + $urlData['occupancy'] = $occupancy; + } + if ($location = Tools::getValue('location')) { + $urlData['location'] = $location; + } - $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']); - if (!empty($cover_image_arr)) { - $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $value['id_product'].'-'.$cover_image_arr['id_image'], 'home_default'); - } else { - $cover_img = $this->context->link->getImageLink($value['link_rewrite'], $this->context->language->iso_code.'-default', 'home_default'); - } - $bookingData['rm_data'][$key]['image'] = $cover_img; - $bookingData['rm_data'][$key]['feature'] = $product_feature; - $bookingData['rm_data'][$key]['price'] = $prod_price; - $bookingData['rm_data'][$key]['feature_price'] = $productFeaturePrice; - $bookingData['rm_data'][$key]['price_without_reduction'] = $productPriceWithoutReduction; - $bookingData['rm_data'][$key]['feature_price_diff'] = $productPriceWithoutReduction - $productFeaturePrice; - $bookingData['rm_data'][$key]['room_left'] = count($bookingData['rm_data'][$key]['data']['available']); - - // create URL with the parameters from URL - $urlData = array ('date_from' => $date_from, 'date_to' => $date_to); - if (!isset($occupancy)) { - $occupancy = Tools::getValue('occupancy'); - } - if ($occupancy) { - $urlData['occupancy'] = $occupancy; - } - if ($location = Tools::getValue('location')) { - $urlData['location'] = $location; - } - - if (Configuration::get('PS_REWRITING_SETTINGS')) { - $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'?'.http_build_query($urlData); - } else { - $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'&'.http_build_query($urlData); + if (Configuration::get('PS_REWRITING_SETTINGS')) { + $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'?'.http_build_query($urlData); + } else { + $bookingData['rm_data'][$key]['product_link'] = $this->context->link->getProductLink($value['id_product']).'&'.http_build_query($urlData); + } } } } From a7fe0eeff3fd6c765c0687b6de8b4cfe67d36c94 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 4 Sep 2024 12:49:02 +0530 Subject: [PATCH 5/6] unset roomDetail variable to clear variable reference --- modules/hotelreservationsystem/classes/HotelBookingDetail.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/hotelreservationsystem/classes/HotelBookingDetail.php b/modules/hotelreservationsystem/classes/HotelBookingDetail.php index e51d33789..bfb80f511 100644 --- a/modules/hotelreservationsystem/classes/HotelBookingDetail.php +++ b/modules/hotelreservationsystem/classes/HotelBookingDetail.php @@ -1193,6 +1193,7 @@ protected function getSearchPartiallyAvailRooms($params) } } unset($datetimeObj); + unset($roomDetail); // If all dates are covered if (!$datesToCover) { From 52c5ea54536d3079510fe634897e2a1e8de988ff Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Thu, 5 Sep 2024 16:45:43 +0530 Subject: [PATCH 6/6] updated room price filter currency formating issue --- modules/wkhotelfilterblock/views/js/wkhotelfilterblock.js | 4 ++-- .../views/templates/hook/htlfilterblock.tpl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/wkhotelfilterblock/views/js/wkhotelfilterblock.js b/modules/wkhotelfilterblock/views/js/wkhotelfilterblock.js index e8d25630b..14aa1b5ec 100644 --- a/modules/wkhotelfilterblock/views/js/wkhotelfilterblock.js +++ b/modules/wkhotelfilterblock/views/js/wkhotelfilterblock.js @@ -87,8 +87,8 @@ $(document).ready(function() values: [min_price, max_price], slide: function(event, ui) { - $("#filter_price_from").html(ui.values[0]); - $("#filter_price_to").html(ui.values[1]); + $("#filter_price_from").html(formatCurrency(ui.values[0], currencyFormat, currencySign, currencyBlank)); + $("#filter_price_to").html(formatCurrency(ui.values[1], currencyFormat, currencySign, currencyBlank)); }, change: function(event, ui) { diff --git a/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl b/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl index edd16b240..ca6236150 100644 --- a/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl +++ b/modules/wkhotelfilterblock/views/templates/hook/htlfilterblock.tpl @@ -54,8 +54,8 @@

- {$currency->prefix} {$min_price} {$currency->suffix} - {$currency->prefix} {$max_price} {$currency->suffix} + {displayPrice price=$min_price} + {displayPrice price=$max_price}