svn commit: r618606 - in /ofbiz/trunk/applications: ecommerce/widget/ order/src/org/ofbiz/order/shoppingcart/ order/webapp/ordermgr/WEB-INF/ order/webapp/ordermgr/entry/catalog/ order/widget/ordermgr/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r618606 - in /ofbiz/trunk/applications: ecommerce/widget/ order/src/org/ofbiz/order/shoppingcart/ order/webapp/ordermgr/WEB-INF/ order/webapp/ordermgr/entry/catalog/ order/widget/ordermgr/

bibryam
Author: bibryam
Date: Tue Feb  5 02:52:59 2008
New Revision: 618606

URL: http://svn.apache.org/viewvc?rev=618606&view=rev
Log:
A slightly modified patch for "dynamic price calculation for configurable product" - OFBIZ-995

Modified:
    ofbiz/trunk/applications/ecommerce/widget/CatalogScreens.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
    ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/configproductdetail.ftl
    ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCatalogScreens.xml

Modified: ofbiz/trunk/applications/ecommerce/widget/CatalogScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/widget/CatalogScreens.xml?rev=618606&r1=618605&r2=618606&view=diff
==============================================================================
--- ofbiz/trunk/applications/ecommerce/widget/CatalogScreens.xml (original)
+++ ofbiz/trunk/applications/ecommerce/widget/CatalogScreens.xml Tue Feb  5 02:52:59 2008
@@ -232,6 +232,7 @@
                 <set field="MainColumnStyle" value="center"/>
                 <set field="isEcommerceScreen" value="Y"/>
                 <set field="titleProperty" value="PageTitleProductPage"/>
+                <set field="layoutSettings.javaScripts[]" value="/images/prototypejs/prototype.js" global="true"/>                
                 <set field="configproductdetailScreen" value="component://ecommerce/widget/CatalogScreens.xml#configproductdetail"/>
                 <script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/catalog/product.bsh"/>
             </actions>

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=618606&r1=618605&r2=618606&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Tue Feb  5 02:52:59 2008
@@ -1653,4 +1653,25 @@
         }
         return "success";
     }
+    
+    public static String getConfigDetailsEvent(HttpServletRequest request, HttpServletResponse response) {
+
+        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
+        String productId = request.getParameter("product_id");
+        String currencyUomId = ShoppingCartEvents.getCartObject(request).getCurrency();
+        ProductConfigWrapper configWrapper = ProductConfigWorker.getProductConfigWrapper(productId, currencyUomId, request);
+        if (configWrapper == null) {
+            Debug.logWarning("configWrapper is null", module);
+            request.setAttribute("_ERROR_MESSAGE_", "configWrapper is null");
+            return "error";
+        }
+        ProductConfigWorker.fillProductConfigWrapper(configWrapper, request);
+        if (configWrapper.isCompleted()) {
+            ProductConfigWorker.storeProductConfigWrapper(configWrapper, delegator);
+            request.setAttribute("configId", configWrapper.getConfigId());
+        }
+        
+        request.setAttribute("totalPrice", org.ofbiz.base.util.UtilFormatOut.formatCurrency(configWrapper.getTotalPrice(), currencyUomId, UtilHttp.getLocale(request)));
+        return "success";
+    }    
 }

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml?rev=618606&r1=618605&r2=618606&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/controller.xml Tue Feb  5 02:52:59 2008
@@ -27,7 +27,7 @@
     <!-- event handlers -->
     <handler name="service-multi" type="request" class="org.ofbiz.webapp.event.ServiceMultiEventHandler"/>
     <handler name="bsf" type="request" class="org.ofbiz.webapp.event.BsfEventHandler"/>
-
+    <handler name="jsonjava" type="request" class="org.ofbiz.webapp.event.JSONJavaEventHandler"/>
     <!-- Events to run on every request before security (chains exempt) -->
     <!--
     <preprocessor>
@@ -253,6 +253,12 @@
         <response name="error" type="view" value="showcart"/>
     </request-map>
 
+    <request-map uri="getConfigDetailsEvent">
+        <security https="true" auth="false"/>
+        <event type="jsonjava" path="org.ofbiz.order.shoppingcart.ShoppingCartEvents" invoke="getConfigDetailsEvent"/>
+        <response name="success" type="none"/>
+        <response name="error" type="none"/>
+    </request-map>
     <request-map uri="updateTrackingNumber">
         <security https="true" auth="true"/>
         <event type="service" invoke="updateTrackingNumber"/>

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/configproductdetail.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/configproductdetail.ftl?rev=618606&r1=618605&r2=618606&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/configproductdetail.ftl (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/configproductdetail.ftl Tue Feb  5 02:52:59 2008
@@ -134,10 +134,44 @@
 
 <script language="JavaScript" type="text/javascript">
 <!--
-     function resetTotalPrice(name) {
-     }
+
+Event.observe(window, 'load', function() {
+  Event.observe($('configFormId'),'click',getConfigDetails);
+});
+
+function getConfigDetails(event) {
+        new Ajax.Request('/ordermgr/control/getConfigDetailsEvent',{parameters: $('configFormId').serialize(),  requestHeaders: {Accept: 'application/json'},
+        
+           onSuccess: function(transport){    
+                var data = transport.responseText.evalJSON(true);
+                
+                if (data._ERROR_MESSAGE_LIST_ != undefined) {
+                   //console.log(data._ERROR_MESSAGE_LIST_);
+                   //alert(data._ERROR_MESSAGE_LIST_);
+                }else if (data._ERROR_MESSAGE_ != undefined) {
+                   //console.log(data._ERROR_MESSAGE_);
+                   //alert(data._ERROR_MESSAGE_);
+                }else {
+                  //console.log(data.totalPrice);
+                  //console.log(data.configId);
+                  var totalPrice = data.totalPrice;
+                  var configId = data.configId;
+                  document.getElementById('totalPrice').innerHTML = totalPrice;
+                  document.addToShoppingList.configId.value = configId;
+                  event.stop();
+                }
+            },
+            
+           onFailure: function(transport) {
+             var data = transport.responseText.evalJSON(true);
+             //console.log('Failure');
+           }
+        });
+}
+
 -->
 </script>
+
 <table border="0" cellpadding="2" cellspacing='0'>
 
   <#-- Category next/previous -->
@@ -195,7 +229,7 @@
               - if isSale show price with salePrice style and print "On Sale!"
       -->
       <#if totalPrice?exists>
-        <div class="tabletext">${uiLabelMap.ProductAggregatedPrice}: <span class='basePrice'><@ofbizCurrency amount=totalPrice isoCode=totalPrice.currencyUsed/></span></div>
+        <div class="tabletext">${uiLabelMap.ProductAggregatedPrice}: <span id='totalPrice' class='basePrice'><@ofbizCurrency amount=totalPrice isoCode=totalPrice.currencyUsed/></span></div>
       <#else>
       <#if price.competitivePrice?exists && price.price?exists && price.price?double < price.competitivePrice?double>
         <div class="tabletext">${uiLabelMap.ProductCompareAtPrice}: <span class='basePrice'><@ofbizCurrency amount=price.competitivePrice isoCode=price.currencyUsed/></span></div>
@@ -407,7 +441,7 @@
   <#-- Product Configurator -->
   <tr>
     <td colspan="2">
-      <form name="configform" method="post" action="<@ofbizUrl>product<#if requestAttributes._CURRENT_VIEW_?exists>/${requestAttributes._CURRENT_VIEW_}</#if></@ofbizUrl>">
+      <form name="configform" id="configFormId" method="post" action="<@ofbizUrl>product<#if requestAttributes._CURRENT_VIEW_?exists>/${requestAttributes._CURRENT_VIEW_}</#if></@ofbizUrl>">
         <input type='hidden' name='add_product_id' value='${product.productId}'>
         <input type='hidden' name='add_category_id' value=''>
         <input type='hidden' name='quantity' value='1'>

Modified: ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCatalogScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCatalogScreens.xml?rev=618606&r1=618605&r2=618606&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCatalogScreens.xml (original)
+++ ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCatalogScreens.xml Tue Feb  5 02:52:59 2008
@@ -131,7 +131,7 @@
 <!--                <set field="leftbarScreenName" value="leftbar"/>
                 <set field="rightbarScreenName" value="rightbar"/>
                 <set field="MainColumnStyle" value="center"/>-->
-                
+                <set field="layoutSettings.javaScripts[]" value="/images/prototypejs/prototype.js" global="true"/>
                 <set field="title-property" value="PageTitleProductPage"/>
                 <set field="configproductdetailScreen" value="component://order/widget/ordermgr/OrderEntryCatalogScreens.xml#configproductdetail"/>
                 <script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/catalog/product.bsh"/>