Book Now button to add room to cart issue
-
Hi guys,
I am trying to find out where ajaxCart.add method is. When I click Book Now button I get this error "Uncaught TypeError: Cannot read property 'length' of undefined"
It looks like I am passing object id that does not exist. I did print the output of ajaxCart.add on hotelcommerce/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js and I get the above error.I would like to know where is function add from ajaxCart.add coming from so I can debug even further. I have removed the hotel dropdown and only using the location search textbox to get the hotels for the location. I have a feeling that it's caused by that but I get the hotel rooms fine, the problem starts when I click on "Book Now" button.
Below is the function I am on:
$(document).off('click', '.ajax_add_to_cart_button').on('click', '.ajax_add_to_cart_button', function(e) {
e.preventDefault();
var idProduct = parseInt($(this).data('id-product'));
var idProductAttribute = parseInt($(this).data('id-product-attribute'));var dateFrom = $(this).attr('cat_rm_check_in'); var dateTo = $(this).attr('cat_rm_check_out'); /* By Webkul * Note : In our case minimalQuantity is taken from Qty. field */ // var minimalQuantity = parseInt($(this).data('minimal_quantity')); var minimalQuantity = parseInt($(this).data('minimal_quantity')); var minimalQuantity = $("#cat_quantity_wanted_" + idProduct).val(); if (!minimalQuantity) minimalQuantity = 1; console.log("datefrom:" + dateFrom); console.log("dateTo: " + dateTo ); console.log("Produict ID: " + idProduct ); console.log("minimal Quantity: " + minimalQuantity ); if ($(this).prop('disabled') != 'disabled') **ajaxCart.add(idProduct, idProductAttribute, false, this, minimalQuantity, null, dateFrom, dateTo);** AjaxVariable = ajaxCart.add(idProduct, idProductAttribute, false, this, minimalQuantity, null, dateFrom, dateTo); console.log("p**rinting ajax") console.log(AjaxVariable);
});
Thanks
-
The js file you are searching for is
hotelcommerce/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.jsPlease visit https://prnt.sc/qqv072 to find the function add of ajaxCart
Hope it will help.
-
funny how I just found it now right before I check the forum, thanks @Sumit . this is much appriciated.