Author: mor
Date: Thu Jul 3 03:27:32 2008 New Revision: 673646 URL: http://svn.apache.org/viewvc?rev=673646&view=rev Log: Now Shipping options are coming in Step 3 Panel of One Page Checkout Process Patch from Sumit Pandit Modified: ofbiz/trunk/applications/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl 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=673646&r1=673645&r2=673646&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 Thu Jul 3 03:27:32 2008 @@ -1001,11 +1001,114 @@ <call-object-method obj-field-name="shoppingCart" method-name="setOrderPartyId"> <field field-name="partyId"/> </call-object-method> + + <!-- Preparing Shippping Options --> + <call-bsh> + <![CDATA[ + import org.ofbiz.order.shoppingcart.shipping.ShippingEstimateWrapper; + shippingEstWpr = ShippingEstimateWrapper.getWrapper(dispatcher, shoppingCart, 0); + parameters.put("shippingEstWpr", shippingEstWpr); + ]]> + </call-bsh> + <set field="shippingEstWpr" from-field="parameters.shippingEstWpr"/> + <call-object-method obj-field-name="shippingEstWpr" method-name="getShippingMethods" ret-field-name="carrierShipmentMethodList"/> + <call-object-method obj-field-name="shoppingCart" method-name="getShipmentMethodTypeId" ret-field-name="shipmentMethodTypeId"/> + <call-object-method obj-field-name="shoppingCart" method-name="getCarrierPartyId" ret-field-name="carrierPartyId"/> + <call-object-method obj-field-name="shoppingCart" method-name="getCurrency" ret-field-name="currency"/> + <if-not-empty field="shipmentMethodTypeId"> + <if-not-empty field="carrierPartyId"> + <set field="chosenShippingMethod" value="${shipmentMethodTypeId}@${carrierPartyId}"/> + </if-not-empty> + </if-not-empty> + <iterate list-name="carrierShipmentMethodList" entry-name="carrierShipmentMethod"> + <call-object-method obj-field-name="shippingEstWpr" method-name="getShippingEstimate" ret-field-name="shippingEst"> + <field field-name="carrierShipmentMethod" type="org.ofbiz.entity.GenericValue"/> + </call-object-method> + <if-empty field="shippingEst"> + <set field="shippingEst" value="-1" type="Integer"/> + </if-empty> + <set field="negValue" value="-1" type="Integer"/> + <set field="shippingMethod" value="${carrierShipmentMethod.shipmentMethodTypeId}@${carrierShipmentMethod.partyId}"/> + + <if-compare-field field="shippingEst" operator="greater" to-field="negValue"> + <set field="shippingDesc" value="${carrierShipmentMethod.description} - ${currency}${shippingEst}"/> + <else> + <set field="shippingDesc" value="${carrierShipmentMethod.description} - ${currency}+${uiLabelMap.OrderCalculatedOffline}"/> + </else> + </if-compare-field> + <set field="shippingOptionMap.shippingMethod" from-field="shippingMethod"/> + <set field="shippingOptionMap.shippingDesc" from-field="shippingDesc"/> + <field-to-list field-name="shippingOptionMap" list-name="shippingOptions"/> + <clear-field field-name="shippingOptionMap"/> + </iterate> + <set field="parameters.shippingOptions" from-field="shippingOptions"/> + <field-to-request field-name="parameters.shippingOptions" request-name="shippingOptions"/> </simple-method> - - <simple-method method-name="setShippingOption" - short-description="Set shipping method" login-required="false"> + <simple-method method-name="setShippingOption" short-description="Set shipping method" login-required="false"> + <call-bsh><![CDATA[ + shippingMethod = parameters.get("shipMethod"); + if(shippingMethod != null) { + shipmentMethodTypeId = shippingMethod.substring(0, shippingMethod.indexOf("@")); + carrierPartyId = shippingMethod.substring(shippingMethod.indexOf("@")+1); + parameters.put("shipmentMethodTypeId", shipmentMethodTypeId); + parameters.put("carrierPartyId", carrierPartyId); + } + ]]></call-bsh> + <set field="shipmentMethodTypeId" from-field="parameters.shipmentMethodTypeId"/> + <set field="carrierPartyId" from-field="parameters.carrierPartyId"/> + <log level="info" message=" shipmentMethodTypeId is ${shipmentMethodTypeId} "/> + <log level="info" message=" carrierPartyId is ${carrierPartyId}"/> + + <entity-one entity-name="CarrierAndShipmentMethod" value-name="shipmentMethod"> + <field-map field-name="shipmentMethodTypeId" env-name="shipmentMethodTypeId"/> + <field-map field-name="partyId" env-name="carrierPartyId"/> + <field-map field-name="roleTypeId" value="CARRIER"/> + </entity-one> + <field-to-request field-name="shipmentMethod.shippingDescription" request-name="shippingDescription"/> + + <set field="shoppingCart" from-field="parameters.shoppingCart"/> + <if-empty field="shoppingCart"> + <session-to-field field-name="shoppingCart"/> + </if-empty> + <call-object-method obj-field-name="shoppingCart" method-name="setShipmentMethodTypeId"> + <field field-name="shipmentMethodTypeId"/> + </call-object-method> + <call-object-method obj-field-name="shoppingCart" method-name="setCarrierPartyId"> + <field field-name="carrierPartyId"/> + </call-object-method> + <call-object-method obj-field-name="shoppingCart" method-name="getCurrency" ret-field-name="isoCode"/> + <set field="dispatcher" from-field="parameters.dispatcher" type="Object"/> + <set field="delegator" from-field="parameters.delegator" type="Object"/> + <set field="locale" from-field="parameters.locale" type="Object"/> + + <call-bsh><![CDATA[ + Map shipCost = org.ofbiz.order.shoppingcart.shipping.ShippingEvents.getShipGroupEstimate(dispatcher, delegator, shoppingCart, 0); + Double shippingTotal = (Double) shipCost.get("shippingTotal"); + if (shippingTotal == null) { + shippingTotal = new Double(0.00); + } + shoppingCart.setItemShipGroupEstimate(shippingTotal.doubleValue(), 0); + parameters.put("shippingTotal", org.ofbiz.base.util.UtilFormatOut.formatCurrency(shippingTotal.doubleValue(), isoCode, locale)); + + checkOutHelper = new org.ofbiz.order.shoppingcart.CheckOutHelper(dispatcher, delegator, shoppingCart); + // Calculate and add the tax adjustments + checkOutHelper.calcAndAddTax(); + + double salesTax = shoppingCart.getTotalSalesTax(); + totalSalesTax = org.ofbiz.base.util.UtilFormatOut.formatCurrency(salesTax, isoCode, locale); + parameters.put("totalSalesTax", totalSalesTax); + + cartGrandTotal = org.ofbiz.base.util.UtilFormatOut.formatCurrency(shoppingCart.getGrandTotal(), isoCode, locale); + parameters.put("cartGrandTotal", cartGrandTotal); + + ]]></call-bsh> + <field-to-request field-name="parameters.shippingTotal" request-name="shippingTotal"/> + <field-to-request field-name="parameters.cartGrandTotal" request-name="cartGrandTotal"/> + <field-to-request field-name="parameters.totalSalesTax" request-name="totalSalesTax"/> + <log level="info" message="Shipping total is : ${parameters.shippingTotal}"/> + <log level="info" message="Cart Grand total is : ${parameters.cartGrandTotal}"/> + <log level="info" message="Total sale tax is : ${parameters.totalSalesTax}"/> </simple-method> <simple-method method-name="createUpdateBillingAndPayment" short-description="Create/update billing address and payment information" login-required="false"> 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=673646&r1=673645&r2=673646&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js (original) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/images/checkoutProcess.js Thu Jul 3 03:27:32 2008 @@ -39,8 +39,7 @@ // Shipping Options Event.observe($('editBilling'), 'click', function() { - // TODO : Will be uncomment soon. - //setShippingOption(); + setShippingOption(); displayBillingPanel(); }); @@ -154,11 +153,18 @@ } function processShippingAddress() { + var shipOptions = null; + var optionList = []; new Ajax.Request('/ecommerce/control/createUpdateShippingAddress', { asynchronous: false, onSuccess: function(transport) { var data = transport.responseText.evalJSON(true); console.log(data); + shipOptions = data.shippingOptions; + shipOptions.each( function(shipOption) { + optionList.push("<option value = " + shipOption.shippingMethod + " > " + shipOption.shippingDesc + " </option>"); + }); + $('shipMethod').innerHTML = optionList; if (data._ERROR_MESSAGE_LIST_ != undefined) { console.log(data._ERROR_MESSAGE_LIST_); } else if (data._ERROR_MESSAGE_ != undefined) { @@ -219,6 +225,7 @@ } }, parameters: $('shippingOptionForm').serialize(), requestHeaders: {Accept: 'application/json'} }); + updateCartData(); } function setDataInShippingOptionCompleted() { 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=673646&r1=673645&r2=673646&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl (original) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/order/OnePageCheckoutProcess.ftl Thu Jul 3 03:27:32 2008 @@ -423,7 +423,6 @@ </div> <div id="editShippingOptionPanel" style="display: none;"> - <#if shoppingCart.getPartyId()?exists> <form name="shippingOptionForm" id="shippingOptionForm" action="<@ofbizUrl></@ofbizUrl>" method="post"> <table id="shippingTable"> <tr><td> @@ -432,40 +431,12 @@ <div class="field-label"> <label for="shipmethod">${uiLabelMap.FormFieldTitleShippingMethod}<span class="requiredLabel"> *</span><span id="advice-required-shipping_method" class="custom-advice" style="display:none">(required)</span></label> </div> - <#if shoppingCart?exists> - <#assign shippingEstWpr = Static["org.ofbiz.order.shoppingcart.shipping.ShippingEstimateWrapper"].getWrapper(dispatcher, shoppingCart, 0)> - <#assign carrierShipmentMethodList = shippingEstWpr.getShippingMethods()> - <#if shoppingCart.getShipmentMethodTypeId()?exists && shoppingCart.getCarrierPartyId()?exists> - <#assign chosenShippingMethod = shoppingCart.getShipmentMethodTypeId() + '@' + shoppingCart.getCarrierPartyId()> - </#if> - </#if> - <div class="field-widget"> - <select id="shipMethod" name="shipMethod" class="required"> - <#list carrierShipmentMethodList as carrierShipmentMethod> - <#assign shippingEst = shippingEstWpr.getShippingEstimate(carrierShipmentMethod)?default(-1)> - <#if (shippingEst > -1)> - <#assign shippingMethod = carrierShipmentMethod.shipmentMethodTypeId + "@" + carrierShipmentMethod.partyId> - <option value="${shippingMethod}" - <#if ((chosenShippingMethod)?exists && chosenShippingMethod == shippingMethod)>SELECTED</#if>> - ${carrierShipmentMethod.description?if_exists} - <#if shippingEst?has_content> - - <#if (shippingEst > -1)?exists> - <@ofbizCurrency amount=shippingEst isoCode=shoppingCart.getCurrency()/> - <#else> - ${uiLabelMap.OrderCalculatedOffline} - </#if> - </#if> - </option> - </#if> - </#list> - </select> - </div> + <select id="shipMethod" name="shipMethod" class="required"></select> </div> </fieldset> </td></tr> </table> </form> - </#if> <div align="right"><h3><span class="editStep"><a href="javascript:void(0);" id="editBilling"><h3>Continue for step 4</h3></a></span></h3></div> </div> </div> |
Free forum by Nabble | Edit this page |