svn commit: r936467 - in /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart: ShoppingCart.java ShoppingCartServices.java product/ProductPromoWorker.java

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

svn commit: r936467 - in /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart: ShoppingCart.java ShoppingCartServices.java product/ProductPromoWorker.java

doogie-3
Author: doogie
Date: Wed Apr 21 19:46:01 2010
New Revision: 936467

URL: http://svn.apache.org/viewvc?rev=936467&view=rev
Log:
Add ability to have a cart that doesn't do any promotions, and when
loading the cart from the database, and promotional items are being
included, the flag gets set.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=936467&r1=936466&r2=936467&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Wed Apr 21 19:46:01 2010
@@ -140,6 +140,7 @@ public class ShoppingCart implements Ite
     private String delegatorName = null;
 
     protected String productStoreId = null;
+    protected boolean doPromotions = true;
     protected String transactionId = null;
     protected String facilityId = null;
     protected String webSiteId = null;
@@ -177,6 +178,7 @@ public class ShoppingCart implements Ite
         this.delegator = cart.getDelegator();
         this.delegatorName = delegator.getDelegatorName();
         this.productStoreId = cart.getProductStoreId();
+        this.doPromotions = cart.getDoPromotions();
         this.poNumber = cart.getPoNumber();
         this.orderId = cart.getOrderId();
         this.orderName = "Copy of " + cart.getOrderName();
@@ -287,6 +289,14 @@ public class ShoppingCart implements Ite
         return this.productStoreId;
     }
 
+    public boolean getDoPromotions() {
+        return this.doPromotions;
+    }
+
+    public void setDoPromotions(boolean doPromotions) {
+        this.doPromotions = doPromotions;
+    }
+
     /**
      * This is somewhat of a dangerous method, changing the productStoreId changes a lot of stuff including:
      * - some items in the cart may not be valid in any catalog in the new store

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=936467&r1=936466&r2=936467&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 Wed Apr 21 19:46:01 2010
@@ -190,6 +190,7 @@ public class ShoppingCartServices {
 
         // create the cart
         ShoppingCart cart = new ShoppingCart(delegator, productStoreId, website, locale, currency);
+        cart.setDoPromotions(!includePromoItems);
         cart.setOrderType(orderTypeId);
         cart.setChannelType(orderHeader.getString("salesChannelEnumId"));
         cart.setInternalCode(orderHeader.getString("internalCode"));

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=936467&r1=936466&r2=936467&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java Wed Apr 21 19:46:01 2010
@@ -258,6 +258,9 @@ public class ProductPromoWorker {
         // limits sub total for promos to not use gift cards (products with a don't use in promo indicator), also exclude gift cards from all other promotion considerations including subTotals for discounts, etc
         // TODO: (not done, delay, still considering...) add code to check ProductPromoUse limits per promo (customer, promo), and per code (customer, code) to avoid use of promos or codes getting through due to multiple carts getting promos applied at the same time, possibly on totally different servers
 
+        if (!cart.getDoPromotions()) {
+            return;
+        }
         Delegator delegator = cart.getDelegator();
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();