svn commit: r606792 - in /ofbiz/trunk/applications: order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java product/servicedef/services_pricepromo.xml product/src/org/ofbiz/product/price/PriceServices.java

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

svn commit: r606792 - in /ofbiz/trunk/applications: order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java product/servicedef/services_pricepromo.xml product/src/org/ofbiz/product/price/PriceServices.java

bibryam
Author: bibryam
Date: Tue Dec 25 06:56:44 2007
New Revision: 606792

URL: http://svn.apache.org/viewvc?rev=606792&view=rev
Log:
A patch from Sumit Pandit "When survey products are added to the cart then displaying survey price in the cart and adding it to the cart total." - OFBIZ-1499
It's now possible to pass surveyResponseId to "calculateProductPrice" service.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
    ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=606792&r1=606791&r2=606792&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java Tue Dec 25 06:56:44 2007
@@ -1044,6 +1044,24 @@
                     this.setDisplayPrice(this.basePrice);
                     this.orderItemPriceInfos = (List) priceResult.get("orderItemPriceInfos");
                 } else {
+                    if (productId != null) {
+                        String productStoreId = cart.getProductStoreId();
+                        List productSurvey = ProductStoreWorker.getProductSurveys(delegator, productStoreId, productId, "CART_ADD", parentProductId);
+                        if (UtilValidate.isNotEmpty(productSurvey) && UtilValidate.isNotEmpty(attributes)) {
+                            List surveyResponses = (List) attributes.get("surveyResponses");
+                            if (UtilValidate.isNotEmpty(surveyResponses)) {
+                                Iterator surveyItr = surveyResponses.iterator();
+                                while(surveyItr.hasNext()) {
+                                    String surveyResponseId = (String)surveyItr.next();
+                                    // TODO: implement multiple survey per product
+                                    if (UtilValidate.isNotEmpty(surveyResponseId)) {
+                                        priceContext.put("surveyResponseId", surveyResponseId);
+                                        break;
+                                    }
+                                }
+                            }
+                        }
+                    }
                     priceContext.put("prodCatalogId", this.getProdCatalogId());
                     priceContext.put("webSiteId", cart.getWebSiteId());
                     priceContext.put("productStoreId", cart.getProductStoreId());

Modified: ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml?rev=606792&r1=606791&r2=606792&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml (original)
+++ ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml Tue Dec 25 06:56:44 2007
@@ -43,7 +43,7 @@
         <attribute name="autoUserLogin" type="GenericValue" mode="IN" optional="true"/>
         <attribute name="checkIncludeVat" type="String" mode="IN" optional="true"><!-- can be Y or N, defaults to N --></attribute>
         <attribute name="findAllQuantityPrices" type="String" mode="IN" optional="true"><!-- can be Y or N, defaults to N; see the allQuantityPrices attribute for more details --></attribute>
-        
+        <attribute name="surveyResponseId" type="String" mode="IN" optional="true"/>
         <attribute name="basePrice" type="Double" mode="OUT" optional="false"><!-- will only be different from price if there is a display price adjustment, for example: checkIncludeVat=Y and a VAT amount was found --></attribute>
         <attribute name="price" type="Double" mode="OUT" optional="false"/>
         <attribute name="listPrice" type="Double" mode="OUT" optional="true"/>

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java?rev=606792&r1=606791&r2=606792&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java Tue Dec 25 06:56:44 2007
@@ -96,6 +96,7 @@
         String prodCatalogId = (String) context.get("prodCatalogId");
         String webSiteId = (String) context.get("webSiteId");
         String checkIncludeVat = (String) context.get("checkIncludeVat");
+        String surveyResponseId = (String) context.get("surveyResponseId");
         
         String findAllQuantityPricesStr = (String) context.get("findAllQuantityPrices");
         boolean findAllQuantityPrices = "Y".equals(findAllQuantityPricesStr);
@@ -498,6 +499,9 @@
                     inMap.put("currencyUomId", currencyUomId);
                     inMap.put("quantity", quantityDbl);
                     inMap.put("amount", amountDbl);
+                    if (UtilValidate.isNotEmpty(surveyResponseId)) {
+                        inMap.put("surveyResponseId", surveyResponseId);
+                    }
                     try {
                         Map outMap = dispatcher.runSync(customMethod.getString("customMethodName"), inMap);
                         if (!ServiceUtil.isError(outMap)) {