Author: jacopoc
Date: Tue Nov 28 02:23:52 2006
New Revision: 479978
URL:
http://svn.apache.org/viewvc?view=rev&rev=479978Log:
Applied patch from Scott Gray to always set a currency for the cart when the cart is loaded from a shopping list, even if the currency in the shopping list is null (the one set in the product store, or the one in the general.properties are used).
OFBIZ-497
Modified:
incubator/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
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?view=diff&rev=479978&r1=479977&r2=479978==============================================================================
--- 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 Tue Nov 28 02:23:52 2006
@@ -632,6 +632,22 @@
// initial required cart info
String productStoreId = shoppingList.getString("productStoreId");
String currency = shoppingList.getString("currencyUom");
+ // If no currency has been set in the ShoppingList, use the ProductStore default currency
+ if (currency == null) {
+ try {
+ GenericValue productStore = shoppingList.getRelatedOne("ProductStore");
+ if (productStore != null) {
+ currency = productStore.getString("defaultCurrencyUomId");
+ }
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ return ServiceUtil.returnError(e.getMessage());
+ }
+ }
+ // If we still have no currency, use the default from general.properties. Failing that, use USD
+ if (currency == null) {
+ currency = UtilProperties.getPropertyValue("general", "currency.uom.id.default", "USD");
+ }
// create the cart
ShoppingCart cart = new ShoppingCart(delegator, productStoreId, locale, currency);