From b4c79b484401adc41ece573eb060ae0719310a2e Mon Sep 17 00:00:00 2001 From: aradhana kumari Date: Fri, 20 Feb 2026 16:19:06 +0530 Subject: [PATCH] Added : Los info in the Product page in front-office --- controllers/front/ProductController.php | 36 +++++++++++++++++++ .../_partials/booking-form.tpl | 14 +++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php index e9fb16151..4865a8fa5 100644 --- a/controllers/front/ProductController.php +++ b/controllers/front/ProductController.php @@ -675,6 +675,7 @@ class ProductControllerCore extends FrontController 'id_room_type' => $idProduct, 'id_cart' => $idCart, 'id_guest' => $idGuest, + 'search_unavai' => 1, // Need to search unavailable rooms to check LOS restriction ); if (Configuration::get('PS_FRONT_ROOM_UNIT_SELECTION_TYPE') == HotelBookingDetail::PS_ROOM_UNIT_SELECTION_TYPE_OCCUPANCY) { $bookingParams['occupancy'] = $occupancy; @@ -693,9 +694,40 @@ class ProductControllerCore extends FrontController } $totalAvailableRooms = 0; + $losRestrictionFailed = false; + $losMinDays = 0; + $losMaxDays = 0; + $losFailedType = ''; // 'min' or 'max' to indicate which restriction failed if ($hotelRoomData = $objBookingDetail->dataForFrontSearch($bookingParams)) { $totalAvailableRooms = $hotelRoomData['stats']['num_avail']; $quantity = ($quantity > $totalAvailableRooms) ? $totalAvailableRooms : $quantity; + + // Check if rooms are unavailable due to LOS restriction + if ($totalAvailableRooms <= 0 && isset($hotelRoomData['rm_data'][$idProduct]['data']['unavailable'])) { + foreach ($hotelRoomData['rm_data'][$idProduct]['data']['unavailable'] as $unavailableRoom) { + if (isset($unavailableRoom['detail'])) { + foreach ($unavailableRoom['detail'] as $detail) { + if (isset($detail['id_status']) && $detail['id_status'] == HotelRoomInformation::STATUS_SEARCH_LOS_UNSATISFIED) { + $losRestrictionFailed = true; + // Get LOS restrictions for the room type + $objRoomTypeRestrictionDateRange = new HotelRoomTypeRestrictionDateRange(); + $losRestriction = $objRoomTypeRestrictionDateRange->getRoomTypeLengthOfStay($idProduct, $dateFrom); + if ($losRestriction) { + $losMinDays = isset($losRestriction['min_los']) ? $losRestriction['min_los'] : 0; + $losMaxDays = isset($losRestriction['max_los']) ? $losRestriction['max_los'] : 0; + // Determine which restriction failed + if ($losMinDays > 0 && $numDays < $losMinDays) { + $losFailedType = 'min'; + } elseif ($losMaxDays > 0 && $numDays > $losMaxDays) { + $losFailedType = 'max'; + } + } + break 2; + } + } + } + } + } } // calculate room type price first @@ -863,6 +895,10 @@ class ProductControllerCore extends FrontController $smartyVars['num_days'] = $numDays; $smartyVars['warning_count'] = $warningCount; $smartyVars['total_available_rooms'] = $totalAvailableRooms; + $smartyVars['los_restriction_failed'] = $losRestrictionFailed; + $smartyVars['los_min_days'] = $losMinDays; + $smartyVars['los_max_days'] = $losMaxDays; + $smartyVars['los_failed_type'] = $losFailedType; $smartyVars['has_room_type_demands'] = $roomTypeDemands ? true : false; // whether to show price breakup $smartyVars['rooms_price'] = $totalRoomPrice; $smartyVars['demands_price_per_room'] = $demandsPricePerRoom; diff --git a/themes/hotel-reservation-theme/_partials/booking-form.tpl b/themes/hotel-reservation-theme/_partials/booking-form.tpl index 0647736f3..c32760230 100644 --- a/themes/hotel-reservation-theme/_partials/booking-form.tpl +++ b/themes/hotel-reservation-theme/_partials/booking-form.tpl @@ -212,7 +212,19 @@ {/block} {else}
- {l s='All rooms sold out!'} + {if isset($los_restriction_failed) && $los_restriction_failed} + + {if isset($los_failed_type) && $los_failed_type == 'min'} + {l s='At least %d nights required.' sprintf=[$los_min_days]} + {elseif isset($los_failed_type) && $los_failed_type == 'max'} + {l s='Up to %d nights allowed.' sprintf=[$los_max_days]} + {else} + {l s='LOS is not match'} + {/if} + + {else} + {l s='All rooms sold out!'} + {/if}
{/if} {/if}