From f56bfa186ff70ee516e09d3415182183cb5a7a47 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 12 Dec 2022 18:35:29 +0530 Subject: [PATCH] Reload page on guest info form submit --- .../hotel-reservation-theme/js/order-opc.js | 43 +++++-------------- 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/themes/hotel-reservation-theme/js/order-opc.js b/themes/hotel-reservation-theme/js/order-opc.js index c1f675717..5fa1f80be 100644 --- a/themes/hotel-reservation-theme/js/order-opc.js +++ b/themes/hotel-reservation-theme/js/order-opc.js @@ -269,32 +269,13 @@ $(document).ready(function() static_token = jsonData.token; // It's not a new customer - if (PS_CUSTOMER_ADDRESS_CREATION && $('#opc_id_customer').val() !== '0') - if (!saveAddress('delivery')) - return false; - - // update id_customer - $('#opc_id_customer').val(jsonData.id_customer); - - // if ($('#invoice_address:checked').length !== 0) - // { - // if (!saveAddress('invoice')) - // return false; - // } - - // update id_customer - $('#opc_id_customer').val(jsonData.id_customer); - - // force to refresh carrier list - if (isGuest) - { - isLogged = 1; - $('#opc_account_saved').fadeIn('slow'); - $('#submitAccount').hide(); - updateAddressSelection(advApiParam); + if (PS_CUSTOMER_ADDRESS_CREATION && $('#opc_id_customer').val() !== '0') { + saveAddress('delivery', function() { + location.reload(); + }); } - else - updateNewAccountToAddressBlock(advApiParam); + + location.reload(); } //$('#guest-info-block, #opc_new_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeIn('slow'); }, @@ -844,7 +825,7 @@ function confirmFreeOrder() }); } -function saveAddress(type) +function saveAddress(type, callback) { if (type !== 'delivery' && type !== 'invoice') return false; @@ -881,8 +862,6 @@ function saveAddress(type) // Clean the last & params = params.substr(0, params.length-1); - var result = false; - $.ajax({ type: 'POST', headers: { "cache-control": "no-cache" }, @@ -912,14 +891,16 @@ function saveAddress(type) }); }); $('#guest-info-block, #opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow'); - result = false; } else { // update addresses id $('input#opc_id_address_delivery').val(jsonData.id_address_delivery); $('input#opc_id_address_invoice').val(jsonData.id_address_invoice); - result = true; + + if (typeof callback === 'function') { + callback(); + } } }, error: function(XMLHttpRequest, textStatus, errorThrown) { @@ -943,8 +924,6 @@ function saveAddress(type) $('#guest-info-block, #opc_account-overlay, #opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow'); } }); - - return result; } function updateNewAccountToAddressBlock(is_adv_api)