Author: mor
Date: Sun Jul 13 23:52:25 2008 New Revision: 676494 URL: http://svn.apache.org/viewvc?rev=676494&view=rev Log: Handled server side errors at step level on One Page Checkout. Done by Sumit Pandit and Brajesh Patel Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js?rev=676494&r1=676493&r2=676494&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js (original) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js Sun Jul 13 23:52:25 2008 @@ -16,13 +16,13 @@ * specific language governing permissions and limitations * under the License. */ - +var isCartStepValidate = false; +var isShipStepValidate = false; +var isShipOptionStepValidate = false; +var isBillStepValidate = false; + Event.observe(window, 'load', function() { - // Cart - var isCartStepValidate = false; - var isShipStepValidate = false; - var isShipOptionStepValidate = false; - var isBillStepValidate = false; + // Cart var validateCart = new Validation('cartForm', {immediate: true, onSubmit: false}); var validateShip = new Validation('shippingForm', {immediate: true, onSubmit: false}); var validateShipOption = new Validation('shippingOptionForm', {immediate: true, onSubmit: false}); @@ -40,8 +40,8 @@ // Shipping Event.observe($('editShippingOptions'), 'click', function() { - if (isCartStepValidate) { - if (validateShip.validate()) { + if (isCartStepValidate) { + if (validateShip.validate()) { processShippingAddress(); displayShippingOptionPanel(); isShipStepValidate = true; @@ -50,11 +50,11 @@ }); Event.observe($('openShippingPanel'), 'click', function() { - if (isCartStepValidate) { + if (isCartStepValidate) { if (isShipStepValidate) { displayShippingPanel(); } - } + } }); // Shipping Options @@ -66,7 +66,7 @@ displayBillingPanel(); isShipOptionStepValidate = true; } - } + } }); Event.observe($('openShippingOptionPanel'), 'click', function() { @@ -77,14 +77,14 @@ // Billing Event.observe($('openBillingPanel'), 'click', function() { - if (isBillStepValidate) { + if (isBillStepValidate) { displayBillingPanel(); } }); Event.observe($('openOrderSubmitPanel'), 'click', function() { if (isCartStepValidate && isShipStepValidate && isShipOptionStepValidate) { - if (validateBill.validate()) { + if (validateBill.validate()) { processBillingAndPayment(); displayOrderSubmitPanel(); isBillStepValidate = true; @@ -92,7 +92,7 @@ } }); - // For Billing Address Same As Shipping + // For Billing Address Same As Shipping Event.observe('useShippingAddressForBilling', 'click', function() { getAssociatedBillingStateList(); useShippingAddressForBillingToggle(); @@ -114,6 +114,22 @@ Event.observe($('billToCountryGeoId'), 'change', getAssociatedBillingStateList); }); +// Check server side error +function getServerError(data) { + var servreErrorHash = []; + var serverError = ""; + if (data._ERROR_MESSAGE_LIST_ != undefined) { + servreErrorHash = data._ERROR_MESSAGE_LIST_; + servreErrorHash.each(function(error) { + serverError += error.message; + }); + } + if (data._ERROR_MESSAGE_ != undefined) { + serverError = data._ERROR_MESSAGE_; + } + return serverError; +} + // Cart function displayShippingPanel() { if (!$('editShippingPanel').visible()) { @@ -148,7 +164,7 @@ // Shipping function displayShippingOptionPanel() { - if (!$('editShippingOptionPanel').visible()) { + if (!$('editShippingOptionPanel').visible() && isShipStepValidate) { Effect.BlindDown('editShippingOptionPanel', {duration: 0.5}); Effect.BlindDown('shippingCompleted', {duration: 0.5}); Effect.BlindUp('editCartPanel', {duration: 0.5}); @@ -167,7 +183,7 @@ // Billing function displayBillingPanel() { - if (!$('editBillingPanel').visible()) { + if (!$('editBillingPanel').visible() && isShipOptionStepValidate) { Effect.BlindDown('editBillingPanel', {duration: 0.5}); Effect.BlindDown('shippingOptionCompleted', {duration: 0.5}); Effect.BlindUp('editCartPanel', {duration: 0.5}); @@ -186,7 +202,7 @@ // Order Submit function displayOrderSubmitPanel() { - if (!$('orderSubmitPanel').visible()) { + if (!$('orderSubmitPanel').visible() && isBillStepValidate) { Effect.BlindDown('orderSubmitPanel', {duration: 0.5}); Effect.BlindDown('billingCompleted', {duration: 0.5}); Effect.BlindUp('editCartPanel', {duration: 0.5}); @@ -201,7 +217,7 @@ Effect.Fade('processingOrderButton', {duration: 0.5}); Effect.Appear('processOrderButton', {duration: 0.5}); } - setDataInBillingCompleted(); + setDataInBillingCompleted(); } function processShippingAddress() { @@ -211,20 +227,19 @@ asynchronous: false, onSuccess: function(transport) { var data = transport.responseText.evalJSON(true); - shipOptions = data.shippingOptions; - shipOptions.each( function(shipOption) { - optionList.push("<option value = " + shipOption.shippingMethod + " > " + shipOption.shippingDesc + " </option>"); - }); - $('shipMethod').update(optionList); - if (data._ERROR_MESSAGE_LIST_ != undefined) { - $('shippingFormServerError').update(data._ERROR_MESSAGE_LIST_); - } else if (data._ERROR_MESSAGE_ != undefined) { - if (data._ERROR_MESSAGE_LIST_ == "SessionTimedOut") { - $('emptyCartCheckoutPanel').show(); - $('checkoutPanel').hide(); - } - $('shippingFormServerError').update(data._ERROR_MESSAGE_); + var serverError = getServerError(data); + if(serverError != "") { + Effect.Appear('shippingFormServerError'); + $('shippingFormServerError').update(serverError); + isShipStepValidate = false; } else { + Effect.Fade('shippingFormServerError'); + isShipStepValidate = true; + shipOptions = data.shippingOptions; + shipOptions.each( function(shipOption) { + optionList.push("<option value = " + shipOption.shippingMethod + " > " + shipOption.shippingDesc + " </option>"); + }); + $('shipMethod').update(optionList); // Process Shipping data response. $('shippingPartyId').value = data.partyId; $('shippingContactMechId').value = data.shippingContactMechId; @@ -259,19 +274,16 @@ asynchronous: false, onSuccess: function(transport) { var data = transport.responseText.evalJSON(true); - console.log(data); shipMethod = data.shippingDescription; shipTotal = data.shippingTotal; - if (data._ERROR_MESSAGE_LIST_ != undefined) { - $('shippingOptionFormServerError').update(data._ERROR_MESSAGE_LIST_); - - } else if (data._ERROR_MESSAGE_ != undefined) { - if (data._ERROR_MESSAGE_LIST_ == "SessionTimedOut") { - $('emptyCartCheckoutPanel').show(); - $('checkoutPanel').hide(); - } - $('shippingOptionFormServerError').update(data._ERROR_MESSAGE_); + var serverError = getServerError(data); + if(serverError != "") { + Effect.Appear('shippingOptionFormServerError'); + $('shippingOptionFormServerError').update(serverError); + isShipOptionStepValidate = false; } else { + Effect.Fade('shippingOptionFormServerError'); + isShipOptionStepValidate = true; $('shippingDescription').value = data.shippingDescription; $('shippingTotal').value = data.shippingTotal; $('cartGrandTotal').value = data.cartGrandTotal; @@ -306,16 +318,14 @@ asynchronous: false, onSuccess: function(transport) { var data = transport.responseText.evalJSON(true); - console.log(data); - if (data._ERROR_MESSAGE_LIST_ != undefined) { - $('billingFormServerError').update(data._ERROR_MESSAGE_LIST_); - } else if (data._ERROR_MESSAGE_ != undefined) { - if (data._ERROR_MESSAGE_LIST_="SessionTimedOut") { - $('emptyCartCheckoutPanel').show(); - $('checkoutPanel').hide(); - } - $('billingFormServerError').update(data._ERROR_MESSAGE_); + var serverError = getServerError(data); + if(serverError != "") { + Effect.Appear('billingFormServerError'); + $('billingFormServerError').update(serverError); + isBillStepValidate = false; } else { + Effect.Fade('billingFormServerError'); + isBillStepValidate = true; $('billToContactMechId').value = data.billToContactMechId; $('paymentMethodId').value = data.paymentMethodId; } @@ -362,9 +372,9 @@ onSuccess: function(transport) { var data = transport.responseText.evalJSON(true); if (data._ERROR_MESSAGE_LIST_ != undefined) { - $('cartFormServerError').update(data._ERROR_MESSAGE_LIST_); + $('cartFormServerError').update(data._ERROR_MESSAGE_LIST_); } else if (data._ERROR_MESSAGE_ != undefined) { - $('cartFormServerError').update(data._ERROR_MESSAGE_); + $('cartFormServerError').update(data._ERROR_MESSAGE_); } else { $('cartDiscountValue').update(data.displayDiscountTotalCurrencyFormatted); $('cartSubTotal').update(data.subTotalCurrencyFormatted); @@ -432,7 +442,7 @@ var formValues = $('cartForm').serialize(); updateCartData(elementId, formValues, qtyElement.value, itemIndex); } else { - qtyElement.value = ""; + qtyElement.value = ""; } } Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl?rev=676494&r1=676493&r2=676494&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl (original) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl Sun Jul 13 23:52:25 2008 @@ -113,7 +113,7 @@ <div id="editCartPanel" class="screenlet-body"> <form name="cartForm" id="cartForm" method="post" action="<@ofbizUrl></@ofbizUrl>"> <input type="hidden" name="removeSelected" value="false"> - <div id="cartFormServerError"></div> + <div id="cartFormServerError" class="errorMessage"></div> <table width="75%" cellspacing="0" cellpadding="1" border="0"> <thead> <tr> @@ -282,7 +282,7 @@ <input type="hidden" name="userLogin" value="${parameters.userLogin?if_exists}"/> <input type="hidden" id="phoneContactMechId" name="phoneContactMechId" value="${parameters.phoneContactMechId?if_exists}"/> <input type="hidden" id="emailContactMechId" name="emailContactMechId" value="${parameters.emailContactMechId?if_exists}"/> - <div id="shippingFormServerError" class="validation-advice"></div> + <div id="shippingFormServerError" class="errorMessage"></div> <table> <tr><td width="40%" valign="top"> <div class="form-row"> @@ -416,7 +416,7 @@ <div id="editShippingOptionPanel" class="screenlet-body" style="display: none;"> <form name="shippingOptionForm" id="shippingOptionForm" action="<@ofbizUrl></@ofbizUrl>" method="post"> - <div id="shippingOptionFormServerError" class="validation-advice"></div> + <div id="shippingOptionFormServerError" class="errorMessage"></div> <table> <tr><td> <div class="form-row"> @@ -482,7 +482,7 @@ <input type="hidden" name="userLogin" value="${parameters.userLogin?if_exists}"/> <input type="hidden" name="expireDate" value="${parameters.expireDate?if_exists}"/> <input type="hidden" id="cardType" name="cardType" value="Visa"/> - <div id="billingFormServerError" class="validation-advice"></div> + <div id="billingFormServerError" class="errorMessage"></div> <table> <tr><td valign="top"> <div class="form-row"> |
Free forum by Nabble | Edit this page |