String productStoreId = (String) context.get("productStoreId");
String currency = (String) context.get("currency");
String partyId = (String) context.get("partyId");
Map itemMap = (Map) context.get("itemMap");
ShoppingCart cart = new ShoppingCart(delegator, productStoreId, null, locale, currency);
try {
cart.setUserLogin(userLogin, dispatcher);
} catch (CartItemModifyException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
}
cart.setOrderType("SALES_ORDER");
cart.setOrderPartyId(partyId);
Iterator i = itemMap.keySet().iterator();
while (i.hasNext()) {
String item = (String) i.next();
BigDecimal price = (BigDecimal) itemMap.get(item);
try {
cart.addNonProductItem("BULK_ORDER_ITEM", item, null, price, BigDecimal.ONE, null, null, null, dispatcher);
} catch (CartItemModifyException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());
}
}
// set the payment method
try {
cart.addPayment(paymentMethodId);
} catch (IllegalArgumentException e) {
return ServiceUtil.returnError(e.getMessage());
}
// save the order (new tx)