diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php
index 01b8d565a..0289e2803 100644
--- a/controllers/front/ProductController.php
+++ b/controllers/front/ProductController.php
@@ -1038,7 +1038,7 @@ class ProductControllerCore extends FrontController
public function displayAjaxRefreshBookingForm()
{
- $response = array('status' => 'ko');
+ $response = array('status' => false);
$idProduct = (int) Tools::getValue('id_product');
$dateFrom = Tools::getValue('date_from');
$dateTo = Tools::getValue('date_to');
@@ -1056,7 +1056,7 @@ class ProductControllerCore extends FrontController
$roomTypeDemands
)) {
$html = $this->context->smarty->fetch('_partials/booking-form.tpl');
- $response['status'] = 'ok';
+ $response['status'] = true;
$response['html_booking_form'] = $html;
}
diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js
index 11f7b90fc..f4c04381c 100644
--- a/modules/blockcart/ajax-cart.js
+++ b/modules/blockcart/ajax-cart.js
@@ -523,6 +523,7 @@ var ajaxCart = {
$('.unvail_rooms_cond_display').hide();
}
}
+ BookingForm.refresh();
}
if (pagename == 'category') {
@@ -538,9 +539,56 @@ var ajaxCart = {
if (jsonData.avail_rooms == 0) {
$(".cat_remain_rm_qty_" + idProduct).closest('.room_cont').hide();
}
+ //$('#cat_quantity_wanted_'+idProduct).val(1);
}
ajaxCart.updateCart(jsonData);
+
+
+ // // add appliance to whishlist module
+ // if (whishlist && !jsonData.errors)
+ // WishlistAddProductCart(whishlist[0], idProduct, idCombination, whishlist[1]);
+
+ // if (!jsonData.hasError) {
+ // if (contentOnly)
+ // window.parent.ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
+ // else
+ // ajaxCart.updateCartInformation(jsonData, addedFromProductPage);
+
+ // if (jsonData.crossSelling)
+ // $('.crossseling').html(jsonData.crossSelling);
+
+ // if (idCombination)
+ // $(jsonData.products).each(function() {
+ // if (this.id != undefined && this.id == parseInt(idProduct) && this.idCombination == parseInt(idCombination))
+ // if (contentOnly)
+ // window.parent.ajaxCart.updateLayer(this);
+ // else
+ // ajaxCart.updateLayer(this);
+ // });
+ // else
+ // $(jsonData.products).each(function() {
+ // if (this.id != undefined && this.id == parseInt(idProduct))
+ // if (contentOnly)
+ // window.parent.ajaxCart.updateLayer(this);
+ // else
+ // ajaxCart.updateLayer(this);
+ // });
+ // if (contentOnly)
+ // parent.$.fancybox.close();
+ // } else {
+ // if (contentOnly)
+ // window.parent.ajaxCart.updateCart(jsonData);
+ // else
+ // ajaxCart.updateCart(jsonData);
+ // if (addedFromProductPage)
+ // $('#add_to_cart button').removeProp('disabled').removeClass('disabled');
+ // else
+ // $(callerElement).removeProp('disabled');
+ // }
+
+ // emptyCustomizations();
+
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
var error = "Impossible to add the room to the cart.
textStatus: '" + textStatus + "'
errorThrown: '" + errorThrown + "'
responseText:
" + XMLHttpRequest.responseText;
diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js
index 880716b28..12a4ed4d8 100644
--- a/themes/hotel-reservation-theme/js/product.js
+++ b/themes/hotel-reservation-theme/js/product.js
@@ -294,31 +294,37 @@ if (typeof(contentOnly) != 'undefined' && contentOnly) {
});
}
-// The button to increment the product value
+// The button to increase the number of rooms value
$(document).on('click', '.product_quantity_up', function(e) {
e.preventDefault();
- fieldName = $(this).data('field-qty');
- var currentVal = parseInt($('input[name=' + fieldName + ']').val());
- if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
- quantityAvailableT = quantityAvailable;
- else
- quantityAvailableT = 100000000;
- if (!isNaN(currentVal) && currentVal < quantityAvailableT)
- $('input[name=' + fieldName + ']').val(currentVal + 1).trigger('focusout');
- else
- $('input[name=' + fieldName + ']').val(quantityAvailableT);
+ let numRoomsWanted = parseInt($('#quantity_wanted').val());
+ let numRoomsMaxAvailable = parseInt($('#max_avail_type_qty').val());
+
+ if (numRoomsWanted <= numRoomsMaxAvailable) {
+ if (numRoomsWanted < numRoomsMaxAvailable) {
+ $('#quantity_wanted').val(numRoomsWanted + 1);
+ }
+ BookingForm.refresh();
+ } else if ((numRoomsWanted < 1 || numRoomsWanted > numRoomsMaxAvailable) && numRoomsMaxAvailable > 0) {
+ $('#quantity_wanted').val(numRoomsMaxAvailable);
+ setTimeout(function() {
+ $('.room_unavailability_qty_error_div').hide();
+ }, 2000);
+ }
});
-// The button to decrement the product value
+// The button to decrease the number of rooms value
$(document).on('click', '.product_quantity_down', function(e) {
e.preventDefault();
- fieldName = $(this).data('field-qty');
- var currentVal = parseInt($('input[name=' + fieldName + ']').val());
- if (!isNaN(currentVal) && currentVal > 1)
- $('input[name=' + fieldName + ']').val(currentVal - 1).trigger('focusout');
- else
- $('input[name=' + fieldName + ']').val(1);
+
+ let numRoomsWanted = parseInt($('#quantity_wanted').val());
+ let numRoomsMaxAvailable = parseInt($('#max_avail_type_qty').val());
+
+ if (numRoomsWanted > 1) {
+ $('#quantity_wanted').val(numRoomsWanted - 1);
+ BookingForm.refresh();
+ }
});
if (typeof minimalQuantity != 'undefined' && minimalQuantity) {
@@ -1192,6 +1198,7 @@ var BookingForm = {
selectedDate.setDate(selectedDate.getDate() + 1);
$("#room_check_out").datepicker("option", "minDate", selectedDate);
$("#room_check_out").val($.datepicker.formatDate('dd-mm-yy', selectedDate));
+ $('#room_check_out').datepicker('show');
}
BookingForm.refresh();
}
@@ -1258,13 +1265,9 @@ var BookingForm = {
action: 'refreshBookingForm',
}, BookingForm.getFormData()),
success: function(response) {
- if (response.status == 'ok') {
- $('.booking-form').animate({opacity: 0}, 250, 'linear', function() {
- $('.booking-form').replaceWith(response.html_booking_form);
- $('.booking-form').animate({opacity: 1}, 250, 'linear', function() {
- BookingForm.init();
- });
- })
+ if (response.status == true) {
+ $('.booking-form').replaceWith(response.html_booking_form);
+ BookingForm.init();
}
}
});