You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/10/23 15:17:46 UTC

svn commit: r587496 - in /ofbiz/trunk/applications/order: src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java webapp/ordermgr/WEB-INF/actions/entry/showcart.bsh widget/ordermgr/OrderEntryCartScreens.xml

Author: jacopoc
Date: Tue Oct 23 06:17:45 2007
New Revision: 587496

URL: http://svn.apache.org/viewvc?rev=587496&view=rev
Log:
Added logic to automatically run the store's promotions that are not set as manualOnly.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
    ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/showcart.bsh
    ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCartScreens.xml

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=587496&r1=587495&r2=587496&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java Tue Oct 23 06:17:45 2007
@@ -108,6 +108,11 @@
                 Iterator productStorePromoAppls = UtilMisc.toIterator(EntityUtil.filterByDate(productStore.getRelatedCache("ProductStorePromoAppl", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNum")), true));
                 while (productStorePromoAppls != null && productStorePromoAppls.hasNext()) {
                     GenericValue productStorePromoAppl = (GenericValue) productStorePromoAppls.next();
+                    if (UtilValidate.isNotEmpty(productStorePromoAppl.getString("manualOnly")) && "Y".equals(productStorePromoAppl.getString("manualOnly"))) {
+                        // manual only promotions are not automatically evaluated (they must be explicitly selected by the user)
+                        if (Debug.verboseOn()) Debug.logVerbose("Skipping promotion with id [" + productStorePromoAppl.getString("productPromoId") + "] because it is applied to the store with ID " + productStoreId + " as a manual only promotion.", module);
+                        continue;
+                    }
                     GenericValue productPromo = productStorePromoAppl.getRelatedOneCache("ProductPromo");
                     List productPromoRules = productPromo.getRelatedCache("ProductPromoRule", null, null);
 
@@ -174,6 +179,11 @@
             Iterator prodCatalogPromoAppls = UtilMisc.toIterator(productStorePromoApplsList);
             while (prodCatalogPromoAppls != null && prodCatalogPromoAppls.hasNext()) {
                 GenericValue prodCatalogPromoAppl = (GenericValue) prodCatalogPromoAppls.next();
+                if (UtilValidate.isNotEmpty(prodCatalogPromoAppl.getString("manualOnly")) && "Y".equals(prodCatalogPromoAppl.getString("manualOnly"))) {
+                    // manual only promotions are not automatically evaluated (they must be explicitly selected by the user)
+                    if (Debug.verboseOn()) Debug.logVerbose("Skipping promotion with id [" + prodCatalogPromoAppl.getString("productPromoId") + "] because it is applied to the store with ID " + productStoreId + " as a manual only promotion.", module);
+                    continue;
+                }
                 GenericValue productPromo = prodCatalogPromoAppl.getRelatedOneCache("ProductPromo");
                 productPromoList.add(productPromo);
             }

Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/showcart.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/showcart.bsh?rev=587496&r1=587495&r2=587496&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/showcart.bsh (original)
+++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/showcart.bsh Tue Oct 23 06:17:45 2007
@@ -51,6 +51,10 @@
 
 context.put("contentPathPrefix", CatalogWorker.getContentPathPrefix(request));
 
+// retrieve the product store id from the cart
+productStoreId = shoppingCart.getProductStoreId();
+context.put("productStoreId", productStoreId);
+
 partyId = shoppingCart.getPartyId();
 if (partyId != null && partyId.equals("_NA_")) partyId = null;
 context.put("partyId", partyId);
@@ -76,7 +80,7 @@
 }
 
 // get product inventory summary for each shopping cart item
-productStore = delegator.findByPrimaryKeyCache("ProductStore", UtilMisc.toMap("productStoreId", shoppingCart.getProductStoreId()));
+productStore = delegator.findByPrimaryKeyCache("ProductStore", UtilMisc.toMap("productStoreId", productStoreId));
 productStoreFacilityId = null;
 if (productStore != null) {
     productStoreFacilityId = productStore.getString("inventoryFacilityId");

Modified: ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCartScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCartScreens.xml?rev=587496&r1=587495&r2=587496&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCartScreens.xml (original)
+++ ofbiz/trunk/applications/order/widget/ordermgr/OrderEntryCartScreens.xml Tue Oct 23 06:17:45 2007
@@ -68,7 +68,11 @@
                 <set field="promoUseDetailsInlineScreen" value="component://order/widget/ordermgr/OrderEntryCartScreens.xml#promoUseDetailsInline"/>
                 <script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/showcart.bsh"/>
                 <script location="component://order/webapp/ordermgr/WEB-INF/actions/entry/showpromotext.bsh"/>
-                <entity-condition entity-name="ProductPromo" list-name="allProductPromos">
+                <entity-condition entity-name="ProductStorePromoAndAppl" list-name="allProductPromos" filter-by-date="true">
+                    <condition-list combine="and">
+                        <condition-expr field-name="manualOnly" value="Y"/>
+                        <condition-expr field-name="productStoreId" env-name="productStoreId"/>
+                    </condition-list>
                     <order-by field-name="productPromoId"/>
                 </entity-condition>
             </actions>