svn commit: r941109 - in /ofbiz/trunk/applications/order/src/org/ofbiz/order: order/OrderReadHelper.java shoppingcart/ShoppingCartServices.java

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

svn commit: r941109 - in /ofbiz/trunk/applications/order/src/org/ofbiz/order: order/OrderReadHelper.java shoppingcart/ShoppingCartServices.java

doogie-3
Author: doogie
Date: Tue May  4 23:44:35 2010
New Revision: 941109

URL: http://svn.apache.org/viewvc?rev=941109&view=rev
Log:
Add reading of promo use and promo code from the database into the
shopping cart.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?rev=941109&r1=941108&r2=941109&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java Tue May  4 23:44:35 2010
@@ -2198,6 +2198,29 @@ public class OrderReadHelper {
         return EntityUtil.filterByCondition(getOrderItems(), entityCondition);
     }
 
+    public Set<String> getProductPromoCodesEntered() {
+        Delegator delegator = orderHeader.getDelegator();
+        Set<String> productPromoCodesEntered = FastSet.newInstance();
+        try {
+            for (GenericValue orderProductPromoCode: delegator.findByAndCache("OrderProductPromoCode", UtilMisc.toMap("orderId", orderHeader.get("orderId")))) {
+                productPromoCodesEntered.add(orderProductPromoCode.getString("productPromoCodeId"));
+            }
+        } catch (GenericEntityException e) {
+            Debug.logError(e, module);
+        }
+        return productPromoCodesEntered;
+    }
+
+    public List<GenericValue> getProductPromoUse() {
+        Delegator delegator = orderHeader.getDelegator();
+        try {
+            return delegator.findByAndCache("ProductPromoUse", UtilMisc.toMap("orderId", orderHeader.get("orderId")));
+        } catch (GenericEntityException e) {
+            Debug.logError(e, module);
+        }
+        return FastList.newInstance();
+    }
+
     /**
      * Checks to see if this user has read permission on this order
      * @param userLogin The UserLogin value object to check

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=941109&r1=941108&r2=941109&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Tue May  4 23:44:35 2010
@@ -581,6 +581,15 @@ public class ShoppingCartServices {
             }
         }
 
+        if (includePromoItems) {
+            for (String productPromoCode: orh.getProductPromoCodesEntered()) {
+                cart.addProductPromoCode(productPromoCode, dispatcher);
+            }
+            for (GenericValue productPromoUse: orh.getProductPromoUse()) {
+                cart.addProductPromoUse(productPromoUse.getString("productPromoId"), productPromoUse.getString("productPromoCodeId"), productPromoUse.getBigDecimal("totalDiscountAmount"), productPromoUse.getBigDecimal("quantityLeftInActions"));
+            }
+        }
+
         List adjustments = orh.getOrderHeaderAdjustments();
         // If applyQuoteAdjustments is set to false then standard cart adjustments are used.
         if (!adjustments.isEmpty()) {