diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
index 5f6ff4de4b..984c88d024 100644
--- a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
+++ b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
@@ -627,6 +627,7 @@ public class CheckOutEvents {
Map paramMap = UtilHttp.getParameterMap(request);
Boolean offlinePayments;
+ String shipGroupIndexPar = null;
String shippingContactMechId = null;
String shippingMethod = null;
String shippingInstructions = null;
@@ -709,6 +710,16 @@ public class CheckOutEvents {
isAnonymousCheckout = true;
}
+ shipGroupIndexPar = request.getParameter("shipGroupIndex");
+ int shipGroupIndex = 0;
+ if (shipGroupIndexPar != null) {
+ try {
+ shipGroupIndex = Integer.parseInt(shipGroupIndexPar);
+ } catch(Exception exc) {
+ Debug.logWarning("Unable to parse shipGroupIndex [" + shipGroupIndexPar + "]: " + exc.getMessage(), module);
+ }
+ }
+
// get the shipping method
shippingContactMechId = request.getParameter("shipping_contact_mech_id");
if (shippingContactMechId == null) {
@@ -777,7 +788,7 @@ public class CheckOutEvents {
checkOutHelper.setCheckOutPayment(selectedPaymentMethods, null, billingAccountId, billingAccountAmt);
}
- Map callResult = checkOutHelper.finalizeOrderEntry(mode, shippingContactMechId, shippingMethod, shippingInstructions,
+ Map callResult = checkOutHelper.finalizeOrderEntry(mode, shipGroupIndex, shippingContactMechId, shippingMethod, shippingInstructions,
maySplit, giftMessage, isGift, methodType, checkOutPaymentId, isSingleUsePayment, doAppendPayment, paramMap,
internalCode, shipBeforeDate, shipAfterDate);
@@ -818,9 +829,9 @@ public class CheckOutEvents {
requireAdditionalParty = requireAdditionalPartyStr == null || requireAdditionalPartyStr.equalsIgnoreCase("true");
}
- String shipContactMechId = cart.getShippingContactMechId();
String customerPartyId = cart.getPartyId();
- String shipmentMethodTypeId = cart.getShipmentMethodTypeId();
+ String shipContactMechId = cart.getShippingContactMechId(shipGroupIndex);
+ String shipmentMethodTypeId = cart.getShipmentMethodTypeId(shipGroupIndex);
List paymentMethodIds = cart.getPaymentMethodIds();
List paymentMethodTypeIds = cart.getPaymentMethodTypeIds();
diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
index 464d0b55cc..9d1da18bc3 100644
--- a/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
+++ b/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
@@ -1231,18 +1231,19 @@ public class CheckOutHelper {
}
/**
- * Sets the shipping contact mechanism on the cart
+ * Sets the shipping contact mechanism for a given ship group on the cart
*
+ * @param shipGroupIndex The index of the ship group in the cart
* @param shippingContactMechId The identifier of the contact
* @return A Map conforming to the OFBiz Service conventions containing
* any error messages
*/
- public Map finalizeOrderEntryShip(String shippingContactMechId) {
+ public Map finalizeOrderEntryShip(int shipGroupIndex, String shippingContactMechId) {
Map result;
String errMsg=null;
//Verify the field is valid
if (UtilValidate.isNotEmpty(shippingContactMechId)) {
- this.cart.setShippingContactMechId(shippingContactMechId);
+ this.cart.setShippingContactMechId(shipGroupIndex, shippingContactMechId);
result = ServiceUtil.returnSuccess();
} else {
errMsg = UtilProperties.getMessage(resource,"checkhelper.enter_shipping_address", (cart != null ? cart.getLocale() : Locale.getDefault()));
@@ -1253,8 +1254,9 @@ public class CheckOutHelper {
}
/**
- * Sets the options associated with the order
+ * Sets the options associated with the order for a given ship group
*
+ * @param shipGroupIndex The index of the ship group in the cart
* @param shippingMethod The shipping method indicating the carrier and
* shipment type to use
* @param shippingInstructions Any additional handling instructions
@@ -1265,7 +1267,7 @@ public class CheckOutHelper {
* @return A Map conforming to the OFBiz Service conventions containing
* any error messages
*/
- public Map finalizeOrderEntryOptions(String shippingMethod, String shippingInstructions, String maySplit,
+ public Map finalizeOrderEntryOptions(int shipGroupIndex, String shippingMethod, String shippingInstructions, String maySplit,
String giftMessage, String isGift, String internalCode, String shipBeforeDate, String shipAfterDate) {
Map result;
@@ -1281,19 +1283,19 @@ public class CheckOutHelper {
carrierPartyId = shippingMethod.substring(delimiterPos + 1);
}
- this.cart.setShipmentMethodTypeId(shipmentMethodTypeId);
- this.cart.setCarrierPartyId(carrierPartyId);
+ this.cart.setShipmentMethodTypeId(shipGroupIndex, shipmentMethodTypeId);
+ this.cart.setCarrierPartyId(shipGroupIndex, carrierPartyId);
} else {
errMsg = UtilProperties.getMessage(resource,"checkhelper.select_shipping_method", (cart != null ? cart.getLocale() : Locale.getDefault()));
result = ServiceUtil.returnError(errMsg);
}
//Set the remaining order options
- this.cart.setShippingInstructions(shippingInstructions);
- this.cart.setGiftMessage(giftMessage);
- this.cart.setMaySplit(Boolean.valueOf(maySplit));
- this.cart.setIsGift(Boolean.valueOf(isGift));
- this.cart.setInternalCode(internalCode);
+ this.cart.setShippingInstructions(shipGroupIndex, shippingInstructions);
+ this.cart.setGiftMessage(shipGroupIndex, giftMessage);
+ this.cart.setMaySplit(shipGroupIndex, Boolean.valueOf(maySplit));
+ this.cart.setIsGift(shipGroupIndex, Boolean.valueOf(isGift));
+ this.cart.setInternalCode(internalCode); // FIXME: the internalCode is not a ship group field and should be moved outside of this method
// set ship before date
if ((shipBeforeDate != null) && (shipBeforeDate.length() > 8)) {
@@ -1303,7 +1305,7 @@ public class CheckOutHelper {
}
try {
- this.cart.setShipBeforeDate((Timestamp) ObjectType.simpleTypeConvert(shipBeforeDate, "Timestamp", null, null));
+ this.cart.setShipBeforeDate(shipGroupIndex, (Timestamp) ObjectType.simpleTypeConvert(shipBeforeDate, "Timestamp", null, null));
} catch (Exception e) {
errMsg = "Ship Before Date must be a valid date formed ";
result = ServiceUtil.returnError(errMsg);
@@ -1318,7 +1320,7 @@ public class CheckOutHelper {
}
try {
- this.cart.setShipAfterDate((Timestamp) ObjectType.simpleTypeConvert(shipAfterDate,"Timestamp", null, null));
+ this.cart.setShipAfterDate(shipGroupIndex, (Timestamp) ObjectType.simpleTypeConvert(shipAfterDate,"Timestamp", null, null));
} catch (Exception e) {
errMsg = "Ship After Date must be a valid date formed ";
result = ServiceUtil.returnError(errMsg);
@@ -1362,7 +1364,7 @@ public class CheckOutHelper {
* @see CheckOutHelper#finalizeOrderEntryPayment(String, Double, boolean, boolean)
* @see CheckOutHelper#finalizeOrderEntryShip(String)
*/
- public Map finalizeOrderEntry(String finalizeMode, String shippingContactMechId, String shippingMethod,
+ public Map finalizeOrderEntry(String finalizeMode, int shipGroupIndex, String shippingContactMechId, String shippingMethod,
String shippingInstructions, String maySplit, String giftMessage, String isGift, String methodType,
String checkOutPaymentId, boolean isSingleUsePayment, boolean appendPayment, Map params,
String internalCode, String shipBeforeDate, String shipAfterDate) {
@@ -1374,13 +1376,13 @@ public class CheckOutHelper {
// set the shipping method
if (finalizeMode != null && finalizeMode.equals("ship")) {
- callResult = this.finalizeOrderEntryShip(shippingContactMechId);
+ callResult = this.finalizeOrderEntryShip(shipGroupIndex, shippingContactMechId);
this.addErrors(errorMessages, errorMaps, callResult);
}
// set the options
if (finalizeMode != null && finalizeMode.equals("options")) {
- callResult = this.finalizeOrderEntryOptions(shippingMethod, shippingInstructions, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate);
+ callResult = this.finalizeOrderEntryOptions(shipGroupIndex, shippingMethod, shippingInstructions, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate);
this.addErrors(errorMessages, errorMaps, callResult);
}
diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
index 94df439b63..b524abc943 100644
--- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
+++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
@@ -1758,6 +1758,11 @@ public class ShoppingCart implements Serializable {
// Ship Group Methods
// ----------------------------------------
+ public int addShipInfo() {
+ shipInfo.add(new CartShipInfo());
+ return (shipInfo.size() - 1);
+ }
+
public List getShipGroups() {
return this.shipInfo;
}
diff --git a/applications/order/webapp/ordermgr/WEB-INF/actions/entry/optionsettings.bsh b/applications/order/webapp/ordermgr/WEB-INF/actions/entry/optionsettings.bsh
index 2813c141fd..d920a60151 100644
--- a/applications/order/webapp/ordermgr/WEB-INF/actions/entry/optionsettings.bsh
+++ b/applications/order/webapp/ordermgr/WEB-INF/actions/entry/optionsettings.bsh
@@ -27,6 +27,22 @@ cart = session.getAttribute("shoppingCart");
context.put("cart", cart);
productStoreId = ProductStoreWorker.getProductStoreId(request);
+String shipGroupIndexPar = request.getParameter("shipGroupIndex");
+String createNewShipGroup = request.getParameter("createNewShipGroup");
+int shipGroupIndex = 0;
+if (createNewShipGroup != null && createNewShipGroup.equals("Y")) {
+ shipGroupIndex = cart.addShipInfo();
+} else {
+ if (shipGroupIndexPar != null) {
+ try {
+ shipGroupIndex = Integer.parseInt(shipGroupIndexPar);
+ } catch(Exception exc) {
+ Debug.logWarning("Unable to parse shipGroupIndex [" + shipGroupIndexPar + "]: " + exc.getMessage());
+ }
+ }
+}
+context.put("shipGroupIndex", shipGroupIndex);
+
// nuke the event messages
request.removeAttribute("_EVENT_MESSAGE_");
@@ -40,8 +56,8 @@ if (orderPartyIdId != null) {
context.put("carrierShipmentMethodList", delegator.findByAndCache("ProductStoreShipmentMethView", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNumber")));
context.put("emailList", ContactHelper.getContactMechByType(orderPartyId, "EMAIL_ADDRESS", false));
-if (cart.getShipmentMethodTypeId() != null && cart.getCarrierPartyId() != null) {
- context.put("chosenShippingMethod", cart.getShipmentMethodTypeId() + '@' + cart.getCarrierPartyId());
+if (cart.getShipmentMethodTypeId(shipGroupIndex) != null && cart.getCarrierPartyId(shipGroupIndex) != null) {
+ context.put("chosenShippingMethod", cart.getShipmentMethodTypeId(shipGroupIndex) + '@' + cart.getCarrierPartyId(shipGroupIndex));
}
// create the beforeDate for calendar
diff --git a/applications/order/webapp/ordermgr/WEB-INF/actions/entry/shipsettings.bsh b/applications/order/webapp/ordermgr/WEB-INF/actions/entry/shipsettings.bsh
index 5392eb6537..d46e3f6c02 100644
--- a/applications/order/webapp/ordermgr/WEB-INF/actions/entry/shipsettings.bsh
+++ b/applications/order/webapp/ordermgr/WEB-INF/actions/entry/shipsettings.bsh
@@ -26,6 +26,23 @@ import javolution.util.FastList;
delegator = request.getAttribute("delegator");
cart = session.getAttribute("shoppingCart");
+
+String shipGroupIndexPar = request.getParameter("shipGroupIndex");
+String createNewShipGroup = request.getParameter("createNewShipGroup");
+int shipGroupIndex = 0;
+if (createNewShipGroup != null && createNewShipGroup.equals("Y")) {
+ shipGroupIndex = cart.addShipInfo();
+} else {
+ if (shipGroupIndexPar != null) {
+ try {
+ shipGroupIndex = Integer.parseInt(shipGroupIndexPar);
+ } catch(Exception exc) {
+ Debug.logWarning("Unable to parse shipGroupIndex [" + shipGroupIndexPar + "]: " + exc.getMessage());
+ }
+ }
+}
+context.put("shipGroupIndex", shipGroupIndex);
+
orderPartyId = cart.getPartyId();
context.put("cart", cart);
@@ -42,6 +59,8 @@ if ("SALES_ORDER".equals(cart.getOrderType())) {
context.put("orderPerson", orderPerson);
context.put("shippingContactMechList", shippingContactMechList);
}
+ String currShipContactMechId = cart.getShippingContactMechId(shipGroupIndex);
+ context.put("currShipContactMechId", currShipContactMechId);
}
} else {
// Purchase order
diff --git a/applications/order/webapp/ordermgr/entry/billsettings.ftl b/applications/order/webapp/ordermgr/entry/billsettings.ftl
index eff7c9cd07..455b3c94ae 100644
--- a/applications/order/webapp/ordermgr/entry/billsettings.ftl
+++ b/applications/order/webapp/ordermgr/entry/billsettings.ftl
@@ -49,7 +49,8 @@ function makeExpDate() {
- |
+ |
+ Create New Ship Group
${uiLabelMap.CommonCreateNew}
|
diff --git a/applications/order/webapp/ordermgr/entry/optionsettings.ftl b/applications/order/webapp/ordermgr/entry/optionsettings.ftl
index b7ead06d85..47193caa3d 100644
--- a/applications/order/webapp/ordermgr/entry/optionsettings.ftl
+++ b/applications/order/webapp/ordermgr/entry/optionsettings.ftl
@@ -19,11 +19,13 @@ under the License.