QloApps Forums
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Book Now button to add room to cart issue

    General Discussion
    book button add room cart
    2
    3
    1472
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      melamanehermanus last edited by

      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

      1 Reply Last reply Reply Quote 0
      • S
        Sumit Global Moderator last edited by

        @melamanehermanus

        The js file you are searching for is
        hotelcommerce/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js

        Please visit https://prnt.sc/qqv072 to find the function add of ajaxCart

        Hope it will help.

        1 Reply Last reply Reply Quote 0
        • M
          melamanehermanus last edited by melamanehermanus

          🙂 funny how I just found it now right before I check the forum, thanks @Sumit . this is much appriciated.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post