Fixed: added home page room type slider

This commit is contained in:
amit sharma
2026-10-23 15:27:35 +05:30
parent 50d48b9e46
commit d7731ebb3d
8 changed files with 383 additions and 56 deletions

View File

@@ -98,12 +98,206 @@ a.htlRoomTypeBookNow {
text-transform: capitalize;
}
.btn.htlRoomTypeBookNow:hover{
border: 1px solid #333333;
}
.room_type_old_price {
text-decoration: line-through;
color:#555555;
font-size:14px;
}
}
/* room type cards slider */
.htlRoom-owlCarousel .owl-carousel {
padding: 0 0 6px;
}
.htlRoomCard {
background: #fff;
border: 1px solid #E5E5E5;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}
.htlRoomCardImg {
display: block;
aspect-ratio: 4 / 3;
overflow: hidden;
}
.htlRoomCardImg img {
width: 100%;
height: 100%;
object-fit: cover;
}
.htlRoomCardBody {
padding: 16px;
}
.htlRoomCardBody .htlRoomTypeNameText {
float: none;
margin: 0 0 12px;
font-size: 22px;
}
.htlRoomCardFeatured {
display: flex;
flex-wrap: wrap;
gap: 6px 16px;
padding: 0 0 12px;
color: #555;
font-size: 15px;
}
.htlRoomCardFeatured img.htlRoomFeatureImg {
width: 16px;
height: 16px;
max-width: 16px;
flex: 0 0 16px;
margin-right: 0;
object-fit: contain;
}
.htlRoomCardAmen > span img.htlRoomAmenityImg {
width: 18px;
height: 18px;
max-width: 18px;
object-fit: contain;
}
.htlRoomCardFeatured > span {
display: inline-flex;
align-items: center;
gap: 4px;
white-space: nowrap;
}
.htlRoomCardFeatured i {
margin-right: 0;
color: #777;
}
.htlRoomCardMeta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 12px 0;
border-top: 1px solid #E5E5E5;
border-bottom: 1px solid #E5E5E5;
color: #555;
font-size: 15px;
}
.htlRoomCardGuests i {
margin-right: 4px;
color: #777;
}
.htlRoomCardAmen {
display: flex;
gap: 6px;
}
.htlRoomCardAmen > span {
display: inline-flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border: 1px solid #D6D6D6;
border-radius: 50%;
font-size: 14px;
color: #666;
}
.htlRoomCardFoot {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding-top: 14px;
}
.htlRoomCardFoot .htlRoomTypePriceText {
float: none;
margin: 0;
font-size: 22px;
font-weight: 700;
line-height: 1.2;
}
.htlRoomCardFoot .wk_roomType_price_type {
font-size: 14px;
font-weight: 400;
color: #777;
}
.htlRoomCardFoot .room_type_old_price {
display: block;
width: auto;
font-size: 14px;
font-weight: 400;
}
a.htlRoomTypeBookNow {
padding: 10px 20px;
border: 0;
border-radius: 3px;
background: #379BF0;
color: #fff;
font-weight: 700;
white-space: nowrap;
}
a.htlRoomTypeBookNow:hover {
background: #2d86d3;
color: #fff;
}
.htlRoom-owlCarousel .owl-nav .owl-prev,
.htlRoom-owlCarousel .owl-nav .owl-next {
position: absolute;
top: 38%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
width: 44px;
height: 44px;
border-radius: 50%;
background: #fff;
box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
font-size: 22px;
line-height: 1;
}
.htlRoom-owlCarousel .owl-nav .owl-prev {
left: -12px;
}
.htlRoom-owlCarousel .owl-nav .owl-next {
right: -12px;
}
.htlRoom-owlCarousel .owl-nav .disabled {
display: none;
}
@media (max-width: 767px) {
.htlRoom-owlCarousel .owl-nav .owl-prev {
left: 4px;
}
.htlRoom-owlCarousel .owl-nav .owl-next {
right: 4px;
}
.htlRoomCardBody .htlRoomTypeNameText {
font-size: 20px;
}
}
/* equal height cards: price row sits at the bottom, occupancy row keeps the same height with or without amenities */
.htlRoom-owlCarousel .owl-stage {
display: flex;
}
.htlRoom-owlCarousel .owl-item {
display: flex;
}
.htlRoomCard {
display: flex;
flex-direction: column;
width: 100%;
}
.htlRoomCardBody {
display: flex;
flex: 1;
flex-direction: column;
}
.htlRoomCardFoot {
margin-top: auto;
}
.htlRoomCardGuests {
display: inline-flex;
align-items: center;
min-height: 32px;
}
.htlRoomCard {
width: calc(100% - 4px);
margin: 2px;
}

View File

@@ -21,6 +21,19 @@
*/
$(document).ready(function() {
$('.htlRoom-owlCarousel .owl-carousel').owlCarousel({
loop: true,
nav: true,
navText: ['<i class="icon-angle-left"></i>', '<i class="icon-angle-right"></i>'],
dots: false,
margin: 24,
items: 1,
rtl: typeof language_is_rtl != 'undefined' && language_is_rtl,
responsive: {
768: { items: 2 },
992: { items: 3 }
}
});
applyChangesToDescription();
$(window).on('resize', function() {
resetDescriptionChanges();

View File

@@ -38,59 +38,67 @@
</div>
{/if}
{block name='hotel_room_block_content'}
<div class="row home_block_content">
<div class="row home_block_content htlRoom-owlCarousel">
<div class="col-sm-12 col-xs-12">
{assign var='htlRoomBlockIteration' value=0}
{foreach from=$hotelRoomDisplay item=roomDisplay name=htlRoom}
{if $smarty.foreach.htlRoom.iteration%2}
<div class="row">
{/if}
<div class="col-sm-12 col-md-6 margin-btm-30">
{block name='hotel_room_block_room_type_image'}
<a href="{$link->getProductLink($roomDisplay.id_product)|escape:'html':'UTF-8'}">
<img src="{$roomDisplay.image|escape:'htmlall':'UTF-8'}" alt="{$roomDisplay.name|escape:'htmlall':'UTF-8'}" class="img-responsive width-100">
</a>
{/block}
{block name='displayHotelRoomsBlockImageAfter'}
{hook h='displayHotelRoomsBlockImageAfter' room_type=$roomDisplay}
{/block}
<div class="hotelRoomDescContainer">
{block name='hotel_room_block_room_type_description'}
<div class="row margin-lr-0">
<p class="htlRoomTypeNameText pull-left">{$roomDisplay.name|escape:'htmlall':'UTF-8'}</p>
{if $roomDisplay.show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}
<p class="htlRoomTypePriceText pull-right">
{if $roomDisplay.feature_price_diff >= 0}
<span class="wk_roomType_price {if $roomDisplay.feature_price_diff>0}room_type_old_price{/if}">{convertPrice price = $roomDisplay.price_without_reduction}</span>
{/if}
{if $roomDisplay.feature_price_diff}
<span class="wk_roomType_price">{convertPrice price = $roomDisplay.feature_price}</span>
{/if}
<span class="wk_roomType_price_type">
/&nbsp;{l s='Per Night' mod='wkhotelroom'}
<div class="owl-carousel owl-theme">
{foreach from=$hotelRoomDisplay item=roomDisplay name=htlRoom}
<div class="htlRoomCard">
{block name='hotel_room_block_room_type_image'}
<a class="htlRoomCardImg" href="{$link->getProductLink($roomDisplay.id_product)|escape:'html':'UTF-8'}">
<img src="{$roomDisplay.image|escape:'htmlall':'UTF-8'}" alt="{$roomDisplay.name|escape:'htmlall':'UTF-8'}">
</a>
{/block}
{block name='displayHotelRoomsBlockImageAfter'}
{hook h='displayHotelRoomsBlockImageAfter' room_type=$roomDisplay}
{/block}
<div class="htlRoomCardBody">
{block name='hotel_room_block_room_type_description'}
<p class="htlRoomTypeNameText">{$roomDisplay.name|escape:'htmlall':'UTF-8'}</p>
{if $roomDisplay.feature}
<div class="htlRoomCardFeatured">
{foreach from=$roomDisplay.feature item=feat}
<span title="{$feat.name|escape:'htmlall':'UTF-8'}">
{if $feat.logo_type == 'icon'}<i class="{$feat.logo|escape:'htmlall':'UTF-8'}"></i>{else}<img class="htlRoomFeatureImg" src="{$smarty.const._PS_IMG_}rf/{$feat.logo_image|escape:'htmlall':'UTF-8'}" alt="{$feat.name|escape:'htmlall':'UTF-8'}" onerror="this.style.display='none'">{/if}
{$feat.value|escape:'htmlall':'UTF-8'}
</span>
</p>
{/foreach}
</div>
{/if}
<div class="htlRoomCardMeta">
<span class="htlRoomCardGuests"><i class="icon-group"></i> {$roomDisplay.max_adults|intval} {l s='Adults' mod='wkhotelroom'}{if $roomDisplay.max_children}, {$roomDisplay.max_children|intval} {if $roomDisplay.max_children > 1}{l s='Children' mod='wkhotelroom'}{else}{l s='Child' mod='wkhotelroom'}{/if}{/if}</span>
{if $roomDisplay.amenities}
<span class="htlRoomCardAmen">
{foreach from=$roomDisplay.amenities item=amenity}
{if $amenity.logo}
<span title="{$amenity.name|escape:'htmlall':'UTF-8'}">
{if $amenity.logo_type == 'icon'}<i class="{$amenity.logo|escape:'htmlall':'UTF-8'}"></i>{else}<img class="htlRoomAmenityImg" src="{$amenity_img_dir|escape:'htmlall':'UTF-8'}{$amenity.logo|escape:'htmlall':'UTF-8'}" alt="{$amenity.name|escape:'htmlall':'UTF-8'}">{/if}
</span>
{/if}
{/foreach}
</span>
{/if}
</div>
{/block}
<div class="htlRoomCardFoot">
{if $roomDisplay.show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE}
<p class="htlRoomTypePriceText">
{if $roomDisplay.feature_price_diff >= 0}
<span class="wk_roomType_price {if $roomDisplay.feature_price_diff>0}room_type_old_price{/if}">{convertPrice price = $roomDisplay.price_without_reduction}</span>
{/if}
</div>
<div class="row margin-lr-0 htlRoomTypeDescText htlRoomTypeDescTextContainer">{$roomDisplay.description|escape:'html':'UTF-8'}</div>
<div class="row htlRoomTypeDescOriginal" hidden>{$roomDisplay.description|escape:'html':'UTF-8'}</div>
<div class="htlRoomTypeDescExtras"><span class='htlRoomTypeDescReadmore'>...{l s='Read More.' mod='wkhotelroom'}</span><span class='htlRoomTypeDescReadless'>...{l s='Read Less.' mod='wkhotelroom'}</span></div>
{/block}
{if $roomDisplay.feature_price_diff}
<span class="wk_roomType_price">{convertPrice price = $roomDisplay.feature_price}</span>
{/if}
<span class="wk_roomType_price_type">/&nbsp;{l s='night' mod='wkhotelroom'}</span>
</p>
{/if}
{block name='hotel_room_block_action'}
<div class="row margin-lr-0">
<a class="btn htlRoomTypeBookNow" href="{$link->getProductLink($roomDisplay.id_product)|escape:'html':'UTF-8'}"><span>{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{l s='book now' mod='wkhotelroom'}{else}{l s='View' mod='wkhotelroom'}{/if}</span></a>
</div>
<a class="btn htlRoomTypeBookNow" href="{$link->getProductLink($roomDisplay.id_product)|escape:'html':'UTF-8'}"><span>{if !isset($restricted_country_mode) && !$PS_CATALOG_MODE}{l s='Book now' mod='wkhotelroom'}{else}{l s='View' mod='wkhotelroom'}{/if}</span></a>
{/block}
</div>
</div>
{if !($smarty.foreach.htlRoom.iteration%2)}
</div>
{/if}
{assign var='htlRoomBlockIteration' value=$smarty.foreach.htlRoom.iteration}
{/foreach}
{if $htlRoomBlockIteration%2}
</div>
{/if}
{/foreach}
</div>
</div>
</div>
{/block}

View File

@@ -51,6 +51,8 @@ class WkHotelRoom extends Module
$dateFrom = date('Y-m-d');
$dateTo = date('Y-m-d', strtotime($dateFrom) + 86400);
$useTax = HotelBookingDetail::useTax();
$maxAmenities = $this->getRoomCardLimit('WK_MAX_AMENITIES_ROOM_SEARCH');
$maxFeatures = $this->getRoomCardLimit('WK_MAX_ROOM_TYPE_FEATURE_VALUES');
foreach ($hotelRoomDisplay as &$htlRoom) {
$idProduct = $htlRoom['id_product'];
$product = new Product($idProduct, false, $idLang);
@@ -109,6 +111,28 @@ class WkHotelRoom extends Module
1,
array(array('adults' => 1, 'children' => 0, 'child_ages' => array()))
);
$objRoomType = new HotelRoomType();
$roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($idProduct);
$htlRoom['max_adults'] = $roomTypeInfo ? (int) $roomTypeInfo['max_adults'] : 0;
$htlRoom['max_children'] = $roomTypeInfo ? (int) $roomTypeInfo['max_children'] : 0;
$htlRoom['feature'] = array();
foreach (Product::getFrontFeaturesStatic($idLang, $idProduct) as $feature) {
if ($feature['is_featured'] && $feature['logo']) {
if (isset($htlRoom['feature'][$feature['id_feature']])) {
$htlRoom['feature'][$feature['id_feature']]['values'][] = $feature['value'];
} else {
$feature['values'] = array($feature['value']);
$htlRoom['feature'][$feature['id_feature']] = $feature;
}
}
}
$htlRoom['feature'] = array_values($htlRoom['feature']);
$htlRoom['feature'] = array_slice($htlRoom['feature'], 0, $maxFeatures);
$htlRoom['amenities'] = array_slice(
HotelRoomTypeAmenities::getAmenities($idProduct, $idLang, true),
0,
$maxAmenities
);
$htlRoom['feature_price'] = $featurePrice;
$htlRoom['feature_price_diff'] = (float)($priceWithoutReduction - $featurePrice);
}
@@ -123,16 +147,27 @@ class WkHotelRoom extends Module
'HOTEL_ROOM_DISPLAY_DESCRIPTION',
$this->context->language->id
),
'amenity_img_dir' => _MODULE_DIR_.'hotelreservationsystem/views/img/hotel_amenities/',
'hotelRoomDisplay' => $hotelRoomDisplay
)
);
$this->context->controller->addCSS(_PS_JS_DIR_.'owl-carousel/assets/owl.carousel.min.css');
$this->context->controller->addCSS(_PS_JS_DIR_.'owl-carousel/assets/owl.theme.default.min.css');
$this->context->controller->addJS(_PS_JS_DIR_.'owl-carousel/owl.carousel.min.js');
$this->context->controller->addJs($this->_path.'/views/js/WkHotelRoomBlockFront.js');
$this->context->controller->addCSS($this->_path.'/views/css/WkHotelRoomBlockFront.css');
return $this->display(__FILE__, 'hotelRoomDisplayBlock.tpl');
}
public function getRoomCardLimit($configKey)
{
$limit = (int) Configuration::get($configKey);
return ($limit < 1 || $limit > 5) ? 3 : $limit;
}
public function hookActionProductSave($params)
{
if (isset($params['id_product']) && $params['id_product']) {

View File

@@ -213,11 +213,19 @@ p.capa_txt {
color: #555555;
}
.room_featured_features {
display: flex;
flex-wrap: wrap;
gap: 8px 18px;
}
.room_featured_feature
{
display: inline-block;
margin: 0 10px 10px 0;
display: inline-flex;
align-items: center;
gap: 6px;
margin: 0;
color: #555;
white-space: nowrap;
}
.room_featured_feature i{
@@ -469,3 +477,30 @@ p.capa_txt {
vertical-align: top;
}
}
@media (max-width: 567px) {
.booking_room_fields > div,
.booking_room_fields .booking_guest_occupancy_conatiner,
.booking_room_fields .booking_guest_occupancy_conatiner > .form-group,
.booking_room_fields .booking_guest_occupancy_conatiner .booking_guest_occupancy,
.booking_room_fields .btn_book_now_with_occupancy {
width: 100%;
}
}
@media (min-width: 568px) and (max-width: 767px) {
.booking_room_fields > div {
width: calc(50% - 5px);
}
.booking_room_fields .booking_guest_occupancy_conatiner > .form-group,
.booking_room_fields .booking_guest_occupancy_conatiner .booking_guest_occupancy,
.booking_room_fields .btn_book_now_with_occupancy {
width: 100%;
}
}
@media (max-width: 767px) {
.booking_room_fields .btn_book_now_with_occupancy {
text-align: center;
}
}

View File

@@ -419,6 +419,9 @@
text-align: center; }
#layer_cart .layer_cart_cart .button-container span.exclusive-medium {
margin-right: 0; } }
@media (min-width: 576px) and (max-width: 991px) {
#layer_cart .layer_cart_cart .button-container {
text-align: center; } }
#layer_cart .cross {
position: absolute;
right: 7px;

View File

@@ -133,9 +133,11 @@
width: 100%;}
.booking_occupancy_wrapper .occupancy_info_block .occupancy_count {
width: 80%;}
/* room list: keep adults and children side by side, same as desktop */
.booking_guest_occupancy_conatiner .booking_occupancy_wrapper .occupancy_info_block .occupancy_count_block {
/* room list and product page booking form: keep adults and children side by side, same as desktop */
.booking_guest_occupancy_conatiner .booking_occupancy_wrapper .occupancy_info_block .occupancy_count_block,
.booking-form .booking_occupancy_wrapper .occupancy_info_block .occupancy_count_block {
width: 50%;}
.booking_guest_occupancy_conatiner .booking_occupancy_wrapper .occupancy_info_block .occupancy_count {
.booking_guest_occupancy_conatiner .booking_occupancy_wrapper .occupancy_info_block .occupancy_count,
.booking-form .booking_occupancy_wrapper .occupancy_info_block .occupancy_count {
width: auto;}
}

View File

@@ -1336,12 +1336,12 @@ Quick View Styles
@media (min-width: 768px) and (max-width: 1199px) {
.num_avail_rooms_alert {
float: left!important;}
.booking_room_fields .form-group {
.booking_room_fields .form-group:not(.occupancy_count_block) {
width: 100%;}}
@media (max-width: 450px) {
.num_avail_rooms_alert {
float: left!important;}
.booking_room_fields .form-group {
.booking_room_fields .form-group:not(.occupancy_count_block) {
width: 100%;}}
/* booking form loading */
@@ -1827,3 +1827,40 @@ ul.service-product-nav > li:hover {
display: block;
}
}
/* mobile and tablet: show the booking form right after the images, before the service products */
@media (max-width: 991px) {
.primary_block {
display: flex;
flex-direction: column;
}
.primary_block:before,
.primary_block:after {
display: none;
}
.primary_block .pb-left-column,
.primary_block .pb-right-column {
display: contents;
}
.primary_block .room_type_img_containter {
order: 1;
}
.primary_block .booking-form {
order: 2;
margin-bottom: 20px;
}
/* the column wrappers are gone, so give the sections their side gutter back */
.primary_block .room_type_img_containter,
.primary_block .booking-form,
.primary_block #service_products_cont,
.primary_block .product_info_containter {
margin-left: 15px;
margin-right: 15px;
}
.primary_block #service_products_cont {
order: 3;
}
.primary_block .product_info_containter {
order: 4;
}
}