svn commit: r921087 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

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

svn commit: r921087 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

doogie-3
Author: doogie
Date: Tue Mar  9 19:53:25 2010
New Revision: 921087

URL: http://svn.apache.org/viewvc?rev=921087&view=rev
Log:
Add helper method for determining whether a ship group contains only
digital goods.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.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=921087&r1=921086&r2=921087&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 Tue Mar  9 19:53:25 2010
@@ -818,6 +818,28 @@ public class ShoppingCart implements Ser
         return true;
     }
 
+    /**
+     * Check to see if the ship group contains only Digital Goods, ie no Finished Goods and no Finished/Digital Goods, et cetera.
+     * This is determined by making sure no Product has a type where ProductType.isPhysical!=N.
+     */
+    public boolean containOnlyDigitalGoods(int shipGroupIdx) {
+        CartShipInfo shipInfo = getShipInfo(shipGroupIdx);
+        for (ShoppingCartItem cartItem: shipInfo.getShipItems()) {
+            GenericValue product = cartItem.getProduct();
+            try {
+                GenericValue productType = product.getRelatedOneCache("ProductType");
+                if (productType == null || !"N".equals(productType.getString("isPhysical"))) {
+                    return false;
+                }
+            } catch (GenericEntityException e) {
+                Debug.logError(e, "Error looking up ProductType: " + e.toString(), module);
+                // consider this not a digital good if we don't have "proof"
+                return false;
+            }
+        }
+        return true;
+    }
+
     /** Returns this item's index. */
     public int getItemIndex(ShoppingCartItem item) {
         return cartLines.indexOf(item);