Author: jacopoc
Date: Mon Aug 21 01:51:11 2006 New Revision: 433199 URL: http://svn.apache.org/viewvc?rev=433199&view=rev Log: Added optional input parameter to the cart service that assigns items to ship groups to make optional the removal of empty groups. Modified: incubator/ofbiz/trunk/applications/order/servicedef/services_cart.xml incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Modified: incubator/ofbiz/trunk/applications/order/servicedef/services_cart.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/servicedef/services_cart.xml?rev=433199&r1=433198&r2=433199&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/order/servicedef/services_cart.xml (original) +++ incubator/ofbiz/trunk/applications/order/servicedef/services_cart.xml Mon Aug 21 01:51:11 2006 @@ -30,6 +30,7 @@ <attribute name="toGroupIndex" type="Integer" mode="IN" optional="false"/> <attribute name="itemIndex" type="Integer" mode="IN" optional="false"/> <attribute name="quantity" type="Double" mode="IN" optional="false"/> + <attribute name="clearEmptyGroups" type="Boolean" mode="IN" optional="true"/> </service> <service name="setCartShippingOptions" engine="java" auth="false" Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=433199&r1=433198&r2=433199&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original) +++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Mon Aug 21 01:51:11 2006 @@ -1900,11 +1900,11 @@ return this.getItemShipGroupQty(this.findCartItem(itemIndex), idx); } - public void positionItemToGroup(int itemIndex, double quantity, int fromIndex, int toIndex) { - this.positionItemToGroup(this.findCartItem(itemIndex), quantity, fromIndex, toIndex); + public void positionItemToGroup(int itemIndex, double quantity, int fromIndex, int toIndex, boolean clearEmptyGroups) { + this.positionItemToGroup(this.findCartItem(itemIndex), quantity, fromIndex, toIndex, clearEmptyGroups); } - public void positionItemToGroup(ShoppingCartItem item, double quantity, int fromIndex, int toIndex) { + public void positionItemToGroup(ShoppingCartItem item, double quantity, int fromIndex, int toIndex, boolean clearEmptyGroups) { if (fromIndex == toIndex || quantity <= 0) { // do nothing return; @@ -1935,8 +1935,10 @@ this.setItemShipGroupQty(item, toQty, toIndex); } - // remove any empty ship groups - this.cleanUpShipGroups(); + if (clearEmptyGroups) { + // remove any empty ship groups + this.cleanUpShipGroups(); + } } } Modified: incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=433199&r1=433198&r2=433199&view=diff ============================================================================== --- incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (original) +++ incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Mon Aug 21 01:51:11 2006 @@ -60,8 +60,13 @@ Integer toGroupIndex = (Integer) context.get("toGroupIndex"); Integer itemIndex = (Integer) context.get("itemIndex"); Double quantity = (Double) context.get("quantity"); + Boolean clearEmptyGroups = (Boolean) context.get("clearEmptyGroups"); Locale locale = (Locale) context.get("locale"); + if (clearEmptyGroups == null) { + clearEmptyGroups = new Boolean(true); + } + Debug.log("From Group - " + fromGroupIndex + " To Group - " + toGroupIndex + "Item - " + itemIndex + "(" + quantity + ")", module); if (fromGroupIndex.equals(toGroupIndex)) { // nothing to do @@ -69,7 +74,7 @@ } cart.positionItemToGroup(itemIndex.intValue(), quantity.doubleValue(), - fromGroupIndex.intValue(), toGroupIndex.intValue()); + fromGroupIndex.intValue(), toGroupIndex.intValue(), clearEmptyGroups.booleanValue()); Debug.log("Called cart.positionItemToGroup()", module); return ServiceUtil.returnSuccess(); |
Free forum by Nabble | Edit this page |