From fceefbb6e5773c3f98811b642064ef1bf1d93b76 Mon Sep 17 00:00:00 2001 From: Shreesh Arora Date: Wed, 5 Apr 2023 10:51:57 +0530 Subject: [PATCH] disable services adding option when rooms are unavailable --- modules/blockcart/ajax-cart.js | 10 ++++++++++ .../js/modules/blockcart/ajax-cart.js | 10 ++++++++++ themes/hotel-reservation-theme/js/product.js | 2 ++ 3 files changed, 22 insertions(+) diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js index b23f26b68..f025f4c6c 100644 --- a/modules/blockcart/ajax-cart.js +++ b/modules/blockcart/ajax-cart.js @@ -1255,6 +1255,16 @@ function disableRoomTypeDemands(show) { } } +function disableRoomTypeServices(disable) { + if (disable) { + $('#service_products_cont').find('button.add_roomtype_product').attr('disabled', 'disabled'); + $('#service_products_cont').find('.qty_container .qty_direction a').attr('disabled', 'disabled'); + } else { + $('#service_products_cont').find('button.add_roomtype_product').removeAttr('disabled'); + $('#service_products_cont').find('.qty_container .qty_direction a').removeAttr('disabled'); + } +} + function getRoomsExtraDemands() { var roomDemands = []; diff --git a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js index b23f26b68..f025f4c6c 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -1255,6 +1255,16 @@ function disableRoomTypeDemands(show) { } } +function disableRoomTypeServices(disable) { + if (disable) { + $('#service_products_cont').find('button.add_roomtype_product').attr('disabled', 'disabled'); + $('#service_products_cont').find('.qty_container .qty_direction a').attr('disabled', 'disabled'); + } else { + $('#service_products_cont').find('button.add_roomtype_product').removeAttr('disabled'); + $('#service_products_cont').find('.qty_container .qty_direction a').removeAttr('disabled'); + } +} + function getRoomsExtraDemands() { var roomDemands = []; diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index d2b8bb6fc..cb4da6dbc 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1350,8 +1350,10 @@ var BookingForm = { } if (!$('.max_avail_type_qty').length || $('.max_avail_type_qty').val() < 1) { disableRoomTypeDemands(1); + disableRoomTypeServices(1); } else { disableRoomTypeDemands(0); + disableRoomTypeServices(0); } }, initDatepicker: function(max_order_date, preparation_time, dateFrom, dateTo) {