Author: jleroux
Date: Fri Dec 5 16:10:22 2014
New Revision: 1643341
URL:
http://svn.apache.org/r1643341Log:
This fixes <<"Please Select Your Shipping Method" error sometimes occurs when updating order items>> bugs
https://issues.apache.org/jira/browse/OFBIZ-5430Fixes a long standing issue in OrderServices.saveUpdatedCartToOrder() where an empty csi may be initially added to ShoppingCart.shipInfo() by ShoppingCart.setItemShipGroupQty() (called indirectly by ShoppingCart.setUserLogin() and then ProductPromoWorker.doPromotions(), etc.). Then shipGroupsSize > realShipGroupsSize are different (+1 for shipGroupsSize), so simply bypass the 1st empty csi. This prevents the "Please Select Your Shipping Method" error, pfew...
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1643341&r1=1643340&r2=1643341&view=diff==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Fri Dec 5 16:10:22 2014
@@ -4136,9 +4136,13 @@ public class OrderServices {
private static void saveUpdatedCartToOrder(LocalDispatcher dispatcher, Delegator delegator, ShoppingCart cart,
Locale locale, GenericValue userLogin, String orderId, Map<String, Object> changeMap, boolean calcTax,
boolean deleteItems) throws GeneralException {
- // get/set the shipping estimates. if it's a SALES ORDER, then return an error if there are no ship estimates
- int shipGroups = cart.getShipGroupSize();
- for (int gi = 0; gi < shipGroups; gi++) {
+ // get/set the shipping estimates. If it's a SALES ORDER, then return an error if there are no ship estimates
+ int shipGroupsSize = cart.getShipGroupSize();
+ int realShipGroupsSize = (new OrderReadHelper(delegator, orderId)).getOrderItemShipGroups().size();
+ // If an empty csi has initially been added to cart.shipInfo by ShoppingCart.setItemShipGroupQty() (called indirectly by ShoppingCart.setUserLogin() and then ProductPromoWorker.doPromotions(), etc.)
+ // shipGroupsSize > realShipGroupsSize are different (+1 for shipGroupsSize), then simply bypass the 1st empty csi!
+ int origin = realShipGroupsSize == shipGroupsSize ? 0 : 1;
+ for (int gi = origin; gi < shipGroupsSize; gi++) {
String shipmentMethodTypeId = cart.getShipmentMethodTypeId(gi);
String carrierPartyId = cart.getCarrierPartyId(gi);
Debug.logInfo("Getting ship estimate for group #" + gi + " [" + shipmentMethodTypeId + " / " + carrierPartyId + "]", module);