svn commit: r1708742 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1708742 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java

Arun Patidar-4
Author: arunpatidar
Date: Thu Oct 15 09:11:53 2015
New Revision: 1708742

URL: http://svn.apache.org/viewvc?rev=1708742&view=rev
Log:
[OFBIZ-6674] In addToCart() method, reset shipment method information in cart only if shipping applies on product.

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

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=1708742&r1=1708741&r2=1708742&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Thu Oct 15 09:11:53 2015
@@ -644,11 +644,19 @@ public class ShoppingCartEvents {
         if (UtilValidate.isNotEmpty(itemId)) {
             request.setAttribute("itemId", itemId);
         }
-        for (int shipGroupIndex = 0; shipGroupIndex < cart.getShipGroupSize(); shipGroupIndex++) {
-            String shipContactMechId = cart.getShippingContactMechId(shipGroupIndex);
-            if (UtilValidate.isNotEmpty(shipContactMechId)) {
-                cart.setShipmentMethodTypeId(shipGroupIndex, null);
+        try {
+            GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
+            //Reset shipment method information in cart only if shipping applies on product.
+            if (ProductWorker.shippingApplies(product)) {
+                for (int shipGroupIndex = 0; shipGroupIndex < cart.getShipGroupSize(); shipGroupIndex++) {
+                    String shipContactMechId = cart.getShippingContactMechId(shipGroupIndex);
+                    if (UtilValidate.isNotEmpty(shipContactMechId)) {
+                        cart.setShipmentMethodTypeId(shipGroupIndex, null);
+                    }
+                }
             }
+        } catch (GenericEntityException e) {
+            Debug.logError(e, "Error getting product"+e.getMessage(), module);
         }
         // Determine where to send the browser
         if (controlDirective.equals(ERROR)) {