You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2011/09/08 11:54:48 UTC

svn commit: r1166591 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java

Author: jleroux
Date: Thu Sep  8 09:54:48 2011
New Revision: 1166591

URL: http://svn.apache.org/viewvc?rev=1166591&view=rev
Log:
A slightly modified patch from Dimitri Unruh "cartNotEmpty returns wrong results" https://issues.apache.org/jira/browse/OFBIZ-4397

The cartNotEmpty method return "success" if I got a cart object in my session, but with no items.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?rev=1166591&r1=1166590&r2=1166591&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java Thu Sep  8 09:54:48 2011
@@ -65,14 +65,12 @@ public class CheckOutEvents {
     public static final String resource_error = "OrderErrorUiLabels";
 
     public static String cartNotEmpty(HttpServletRequest request, HttpServletResponse response) {
-        ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("shoppingCart");
-        //Locale locale = UtilHttp.getLocale(request);
-        String errMsg = null;
+        ShoppingCart cart = ShoppingCartEvents.getCartObject(request);
 
-        if (UtilValidate.isNotEmpty(cart)) {
+        if (cart != null && UtilValidate.isNotEmpty(cart.items())) {
             return "success";
         } else {
-            errMsg = UtilProperties.getMessage(resource_error, "checkevents.cart_empty", (cart != null ? cart.getLocale() : Locale.getDefault()));
+            String errMsg = UtilProperties.getMessage(resource_error, "checkevents.cart_empty", (cart != null ? cart.getLocale() : UtilHttp.getLocale(request)));
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }