Author: mor
Date: Mon Jul 14 07:17:06 2008 New Revision: 676598 URL: http://svn.apache.org/viewvc?rev=676598&view=rev Log: A better approach to get shipping options on Step 3 of One Page Checkout. Patch from Sumit Pandit Modified: ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js Modified: ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml?rev=676598&r1=676597&r2=676598&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml (original) +++ ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml Mon Jul 14 07:17:06 2008 @@ -1002,8 +1002,14 @@ <call-object-method obj-field-name="shoppingCart" method-name="setOrderPartyId"> <field field-name="partyId"/> </call-object-method> + </simple-method> - <!-- Preparing Shippping Options --> + <simple-method method-name="getShipOptions" short-description="Get shipping options" login-required="false"> + <set field="dispatcher" from-field="parameters.dispatcher" type="Object"/> + <set field="shoppingCart" from-field="parameters.shoppingCart"/> + <if-empty field="shoppingCart"> + <session-to-field field-name="shoppingCart"/> + </if-empty> <call-bsh> <![CDATA[ import org.ofbiz.order.shoppingcart.shipping.ShippingEstimateWrapper; Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml?rev=676598&r1=676597&r2=676598&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Mon Jul 14 07:17:06 2008 @@ -1604,7 +1604,12 @@ <response name="success" type="none"/> <response name="error" type="none"/> </request-map> - + <request-map uri="getShipOptions"> + <security https="true" auth="false"/> + <event type="jsonsimple" path="org/ofbiz/ecommerce/customer/CustomerEvents.xml" invoke="getShipOptions"/> + <response name="success" type="none"/> + <response name="error" type="none"/> + </request-map> <request-map uri="setShippingOption"> <security https="true" auth="false"/> <event type="jsonsimple" path="org/ofbiz/ecommerce/customer/CustomerEvents.xml" invoke="setShippingOption"/> 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=676598&r1=676597&r2=676598&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js (original) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js Mon Jul 14 07:17:06 2008 @@ -222,8 +222,11 @@ } function processShippingAddress() { - var shipOptions = null; - var optionList = []; + createUpdateCustomerAndShippingAddress(); + getShipOptions(); +} + +function createUpdateCustomerAndShippingAddress() { new Ajax.Request('/ecommerce/control/createUpdateShippingAddress', { asynchronous: false, onSuccess: function(transport) { @@ -236,11 +239,6 @@ } 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; @@ -252,6 +250,31 @@ }); } +function getShipOptions() { + var shipOptions = null; + var optionList = []; + new Ajax.Request('/ecommerce/control/getShipOptions', { + asynchronous: false, + onSuccess: function(transport) { + var data = transport.responseText.evalJSON(true); + 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); + } + }, requestHeaders: {Accept: 'application/json'} + }); +} + function setDataInShippingCompleted() { var fullName = $('firstName').value + " " +$('lastName').value; var shippingContactPhoneNumber = $F('shippingCountryCode')+ "-" + $F('shippingAreaCode') |
Free forum by Nabble | Edit this page |