diff --git a/modules/blockcart/ajax-cart.js b/modules/blockcart/ajax-cart.js
index 01bb0f3a4..206d73215 100644
--- a/modules/blockcart/ajax-cart.js
+++ b/modules/blockcart/ajax-cart.js
@@ -478,23 +478,27 @@ var ajaxCart = {
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
- var error = "Impossible to add the room to the cart.
textStatus: '" + textStatus + "'
errorThrown: '" + errorThrown + "'
responseText:
" + XMLHttpRequest.responseText;
- if (!!$.prototype.fancybox)
- $.fancybox.open([{
- type: 'inline',
- autoScale: true,
- minHeight: 30,
- content: '
' + error + '
' - }], { - padding: 0 - }); - else - alert(error); - //reactive the button when adding has finished - if (addedFromProductPage) - $('#add_to_cart button').removeProp('disabled').removeClass('disabled'); - else - $(callerElement).removeProp('disabled'); + if (XMLHttpRequest.readyState == 0) { + showErrorMessage(no_internet_txt); + } else { + var error = "Impossible to add the room to the cart.' + error + '
' + }], { + padding: 0 + }); + else + alert(error); + //reactive the button when adding has finished + if (addedFromProductPage) + $('#add_to_cart button').removeProp('disabled').removeClass('disabled'); + else + $(callerElement).removeProp('disabled'); + } } }); }, @@ -612,23 +616,27 @@ var ajaxCart = { }, error: function(XMLHttpRequest, textStatus, errorThrown) { - var error = "Impossible to add the room to the cart.' + error + '
' - }], { - padding: 0 - }); - else - alert(error); - //reactive the button when adding has finished - if (addedFromProductPage) - $('#add_to_cart button').removeProp('disabled').removeClass('disabled'); - else - $(callerElement).removeProp('disabled'); + if (XMLHttpRequest.readyState == 0) { + showErrorMessage(no_internet_txt); + } else { + var error = "Impossible to add the room to the cart.' + error + '
' + }], { + padding: 0 + }); + else + alert(error); + //reactive the button when adding has finished + if (addedFromProductPage) + $('#add_to_cart button').removeProp('disabled').removeClass('disabled'); + else + $(callerElement).removeProp('disabled'); + } } }); }, @@ -675,19 +683,23 @@ var ajaxCart = { deleteProductFromSummary(idProduct + '_' + idCombination + '_' + customizationId + '_' + idAddressDelivery); }*/ }, - error: function() { - var error = 'ERROR: unable to delete the product'; - if (!!$.prototype.fancybox) { - $.fancybox.open([{ - type: 'inline', - autoScale: true, - minHeight: 30, - content: error - }], { - padding: 0 - }); - } else - alert(error); + error: function(jqXHR) { + if (jqXHR.readyState == 0) { + showErrorMessage(no_internet_txt); + } else { + var error = 'ERROR: unable to delete the product'; + if (!!$.prototype.fancybox) { + $.fancybox.open([{ + type: 'inline', + autoScale: true, + minHeight: 30, + content: error + }], { + padding: 0 + }); + } else + alert(error); + } } }); }, diff --git a/modules/blockcart/blockcart.tpl b/modules/blockcart/blockcart.tpl index bbeb68201..1c1552e3d 100644 --- a/modules/blockcart/blockcart.tpl +++ b/modules/blockcart/blockcart.tpl @@ -438,6 +438,7 @@ {addJsDefL name=duration_txt}{l s='Duration' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=capacity_txt}{l s='Capacity' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=remove_rm_title}{l s='Remove this room from my cart' mod='blockcart' js=1}{/addJsDefL} +{addJsDefL name=no_internet_txt}{l s='No internet. Please try later.' mod='blockcart' js=1}{/addJsDefL} {addJsDef rm_avail_process_lnk = $link->getModuleLink('blockcart', 'checkroomavailabilityajaxprocess')} {addJsDef pagename = $current_page} 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 01bb0f3a4..206d73215 100644 --- a/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js +++ b/themes/hotel-reservation-theme/js/modules/blockcart/ajax-cart.js @@ -478,23 +478,27 @@ var ajaxCart = { }, error: function(XMLHttpRequest, textStatus, errorThrown) { - var error = "Impossible to add the room to the cart.' + error + '
' - }], { - padding: 0 - }); - else - alert(error); - //reactive the button when adding has finished - if (addedFromProductPage) - $('#add_to_cart button').removeProp('disabled').removeClass('disabled'); - else - $(callerElement).removeProp('disabled'); + if (XMLHttpRequest.readyState == 0) { + showErrorMessage(no_internet_txt); + } else { + var error = "Impossible to add the room to the cart.' + error + '
' + }], { + padding: 0 + }); + else + alert(error); + //reactive the button when adding has finished + if (addedFromProductPage) + $('#add_to_cart button').removeProp('disabled').removeClass('disabled'); + else + $(callerElement).removeProp('disabled'); + } } }); }, @@ -612,23 +616,27 @@ var ajaxCart = { }, error: function(XMLHttpRequest, textStatus, errorThrown) { - var error = "Impossible to add the room to the cart.' + error + '
' - }], { - padding: 0 - }); - else - alert(error); - //reactive the button when adding has finished - if (addedFromProductPage) - $('#add_to_cart button').removeProp('disabled').removeClass('disabled'); - else - $(callerElement).removeProp('disabled'); + if (XMLHttpRequest.readyState == 0) { + showErrorMessage(no_internet_txt); + } else { + var error = "Impossible to add the room to the cart.' + error + '
' + }], { + padding: 0 + }); + else + alert(error); + //reactive the button when adding has finished + if (addedFromProductPage) + $('#add_to_cart button').removeProp('disabled').removeClass('disabled'); + else + $(callerElement).removeProp('disabled'); + } } }); }, @@ -675,19 +683,23 @@ var ajaxCart = { deleteProductFromSummary(idProduct + '_' + idCombination + '_' + customizationId + '_' + idAddressDelivery); }*/ }, - error: function() { - var error = 'ERROR: unable to delete the product'; - if (!!$.prototype.fancybox) { - $.fancybox.open([{ - type: 'inline', - autoScale: true, - minHeight: 30, - content: error - }], { - padding: 0 - }); - } else - alert(error); + error: function(jqXHR) { + if (jqXHR.readyState == 0) { + showErrorMessage(no_internet_txt); + } else { + var error = 'ERROR: unable to delete the product'; + if (!!$.prototype.fancybox) { + $.fancybox.open([{ + type: 'inline', + autoScale: true, + minHeight: 30, + content: error + }], { + padding: 0 + }); + } else + alert(error); + } } }); }, diff --git a/themes/hotel-reservation-theme/js/product.js b/themes/hotel-reservation-theme/js/product.js index c3ee9ae7f..06a213131 100644 --- a/themes/hotel-reservation-theme/js/product.js +++ b/themes/hotel-reservation-theme/js/product.js @@ -1458,6 +1458,11 @@ var BookingForm = { BookingForm.init(); } }, + error: function(jqXHR) { + if (jqXHR.readyState == 0) { + showErrorMessage(no_internet_txt); + } + }, complete: function() { $('.book_now_submit').prop('disabled', false).find('span:not(#booking_action_loader)').show(); $('#booking_action_block').find('#booking_action_loader').removeClass('active'); diff --git a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl index bbeb68201..1c1552e3d 100644 --- a/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl +++ b/themes/hotel-reservation-theme/modules/blockcart/blockcart.tpl @@ -438,6 +438,7 @@ {addJsDefL name=duration_txt}{l s='Duration' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=capacity_txt}{l s='Capacity' mod='blockcart' js=1}{/addJsDefL} {addJsDefL name=remove_rm_title}{l s='Remove this room from my cart' mod='blockcart' js=1}{/addJsDefL} +{addJsDefL name=no_internet_txt}{l s='No internet. Please try later.' mod='blockcart' js=1}{/addJsDefL} {addJsDef rm_avail_process_lnk = $link->getModuleLink('blockcart', 'checkroomavailabilityajaxprocess')} {addJsDef pagename = $current_page}