Re: svn commit: r776581 - in /ofbiz/trunk: applications/order/src/org/ofbiz/order/shoppingcart/ applications/order/src/org/ofbiz/order/shoppingcart/product/ applications/order/src/org/ofbiz/order/shoppingcart/shipping/ applications/product/data/ applicatio

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

Re: svn commit: r776581 - in /ofbiz/trunk: applications/order/src/org/ofbiz/order/shoppingcart/ applications/order/src/org/ofbiz/order/shoppingcart/product/ applications/order/src/org/ofbiz/order/shoppingcart/shipping/ applications/product/data/ applicatio

Jacques Le Roux
Administrator
Does this allow for free-shipping ?

Jacques

From: <[hidden email]>

> Author: mor
> Date: Wed May 20 06:25:23 2009
> New Revision: 776581
>
> URL: http://svn.apache.org/viewvc?rev=776581&view=rev
> Log:
> Now Shipping Total adjustments can be applied using promotion. User can specify percentage discount on a specific shipping method.
> Applied patch from Arun Patidar, part of OFBIZ-2488 (https://issues.apache.org/jira/browse/OFBIZ-2488)
>
> Modified:
>    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
>    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java
>    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java
>    ofbiz/trunk/applications/product/data/ProductTypeData.xml
>    ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml
>    ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
>    ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl
>    ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml
>    ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml
>
> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=776581&r1=776580&r2=776581&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java (original)
> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java Wed May 20 06:25:23 2009
> @@ -53,6 +53,7 @@
> import org.ofbiz.order.finaccount.FinAccountHelper;
> import org.ofbiz.order.order.OrderChangeHelper;
> import org.ofbiz.order.order.OrderReadHelper;
> +import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;
> import org.ofbiz.order.shoppingcart.shipping.ShippingEvents;
> import org.ofbiz.party.contact.ContactHelper;
> import org.ofbiz.product.store.ProductStoreWorker;
> @@ -407,6 +408,7 @@
>                 shippingTotal = BigDecimal.ZERO;
>             }
>             cart.setItemShipGroupEstimate(shippingTotal, 0);
> +            ProductPromoWorker.doPromotions(cart, dispatcher);
>
>             //Recalc tax before setting payment
>             try {
>
> 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=776581&r1=776580&r2=776581&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 Wed May 20 06:25:23 2009
> @@ -763,7 +763,12 @@
>         String otherValue = productPromoCond.getString("otherValue");
>         String inputParamEnumId = productPromoCond.getString("inputParamEnumId");
>         String operatorEnumId = productPromoCond.getString("operatorEnumId");
> +        String shippingMethod = "";
>
> +        if (otherValue != null && otherValue.contains("@")) {
> +            shippingMethod = otherValue.substring(otherValue.indexOf("@")+1);
> +            otherValue = "";
> +        }
>         String partyId = cart.getPartyId();
>         GenericValue userLogin = cart.getUserLogin();
>         if (userLogin == null) {
> @@ -1121,6 +1126,10 @@
>                     }
>                 }
>             }
> +        } else if ("PPIP_ORDER_SHIPTOTAL".equals(inputParamEnumId) && shippingMethod.equals(cart.getShipmentMethodTypeId())) {
> +            BigDecimal orderTotalShipping = cart.getTotalShipping();
> +            if (Debug.verboseOn()) { Debug.logVerbose("Doing order total Shipping compare: ordertotalShipping=" +
> orderTotalShipping, module); }
> +            compareBase = new Integer(orderTotalShipping.compareTo(new BigDecimal(condValue)));
>         } else {
>             Debug.logWarning(UtilProperties.getMessage(resource_error,"OrderAnUnSupportedProductPromoCondInputParameterLhs",
> UtilMisc.toMap("inputParamEnumId",productPromoCond.getString("inputParamEnumId")), cart.getLocale()), module);
>             return false;
> @@ -1494,6 +1503,14 @@
>                     }
>                 }
>             }
> +        } else if ("PROMO_SHIP_CHARGE".equals(productPromoActionEnumId)) {
> +            BigDecimal percentage = (productPromoAction.get("amount") == null ? BigDecimal.ZERO :
> (productPromoAction.getBigDecimal("amount").movePointLeft(2))).negate();
> +            BigDecimal amount = cart.getTotalShipping().multiply(percentage);
> +            if (amount.compareTo(BigDecimal.ZERO) != 0) {
> +                doOrderPromoAction(productPromoAction, cart, amount, "amount", delegator);
> +                actionResultInfo.ranAction = true;
> +                actionResultInfo.totalDiscountAmount = amount;
> +            }
>         } else {
>             Debug.logError("An un-supported productPromoActionType was used: " + productPromoActionEnumId + ", not performing any
> action", module);
>             actionResultInfo.ranAction = false;
>
> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java?rev=776581&r1=776580&r2=776581&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java (original)
> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java Wed May 20 06:25:23 2009
> @@ -52,6 +52,7 @@
> import java.util.HashMap;
> import java.util.List;
> import java.util.Map;
> +import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;
>
> /**
>  * ShippingEvents - Events used for processing shipping fees
> @@ -84,6 +85,7 @@
>             cart.setItemShipGroupEstimate(shippingTotal, i);
>         }
>
> +        ProductPromoWorker.doPromotions(cart, dispatcher);
>         // all done
>         return "success";
>     }
>
> Modified: ofbiz/trunk/applications/product/data/ProductTypeData.xml
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?rev=776581&r1=776580&r2=776581&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/product/data/ProductTypeData.xml (original)
> +++ ofbiz/trunk/applications/product/data/ProductTypeData.xml Wed May 20 06:25:23 2009
> @@ -377,6 +377,7 @@
>     <Enumeration description="Promotion Recurrence" enumCode="PROMO_RECURRENCE" enumId="PPIP_RECURRENCE" sequenceId="11"
> enumTypeId="PROD_PROMO_IN_PARAM"/>
>     <Enumeration description="Order sub-total X since beginning of current year" enumCode="ORST_YEAR" enumId="PPIP_ORST_YEAR"
> sequenceId="12" enumTypeId="PROD_PROMO_IN_PARAM"/>
>     <Enumeration description="Order sub-total X last year" enumCode="ORST_LAST_YEAR" enumId="PPIP_ORST_LAST_YEAR" sequenceId="13"
> enumTypeId="PROD_PROMO_IN_PARAM"/>
> +    <Enumeration description="Shipping Total" enumCode="ORDER_SHIP_TOTAL" enumId="PPIP_ORDER_SHIPTOTAL" sequenceId="14"
> enumTypeId="PROD_PROMO_IN_PARAM"/>
>
>     <EnumerationType description="Product Promotion Condition" enumTypeId="PROD_PROMO_COND" hasTable="N"
> parentTypeId="PROD_PROMO"/>
>     <!-- old style very technical ...
> @@ -408,6 +409,7 @@
>     <Enumeration description="Order Percent Discount" enumCode="ORDER_PERCENT" enumId="PROMO_ORDER_PERCENT" sequenceId="06"
> enumTypeId="PROD_PROMO_ACTION"/>
>     <Enumeration description="Order Amount Flat" enumCode="ORDER_AMOUNT" enumId="PROMO_ORDER_AMOUNT" sequenceId="07"
> enumTypeId="PROD_PROMO_ACTION"/>
>     <Enumeration description="Product for [Special Promo] Price" enumCode="PROD_SPPRC" enumId="PROMO_PROD_SPPRC" sequenceId="08"
> enumTypeId="PROD_PROMO_ACTION"/>
> +    <Enumeration description="Shipping X% discount" enumCode="SHIP_CHARGE" enumId="PROMO_SHIP_CHARGE" sequenceId="09"
> enumTypeId="PROD_PROMO_ACTION"/>
>
>     <EnumerationType description="Product Rating Field Type" enumTypeId="PROD_RATING_TYPE" hasTable="N" parentTypeId=""/>
>     <Enumeration description="Min Rating" enumCode="MIN" enumId="PRDR_MIN" sequenceId="01" enumTypeId="PROD_RATING_TYPE"/>
>
> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml?rev=776581&r1=776580&r2=776581&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml (original)
> +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml Wed May 20 06:25:23 2009
> @@ -251,6 +251,9 @@
>
>         <make-value value-field="newEntity" entity-name="ProductPromoCond"/>
>         <set-nonpk-fields map="parameters" value-field="newEntity"/>
> +        <if-not-empty field="parameters.carrierShipmentMethod">
> +            <set field="newEntity.otherValue" from-field="parameters.carrierShipmentMethod"/>
> +        </if-not-empty>
>         <set-pk-fields map="parameters" value-field="newEntity"/>
>         <make-next-seq-id value-field="newEntity" seq-field-name="productPromoCondSeqId" numeric-padding="2"/>
>         <field-to-result field="newEntity.productPromoCondSeqId" result-name="productPromoCondSeqId"/>
> @@ -266,6 +269,9 @@
>         <set-pk-fields map="parameters" value-field="lookupPKMap"/>
>         <find-by-primary-key entity-name="ProductPromoCond" map="lookupPKMap" value-field="lookedUpValue"/>
>         <set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
> +        <if-not-empty field="parameters.carrierShipmentMethod">
> +            <set field="lookedUpValue.otherValue" from-field="parameters.carrierShipmentMethod"/>
> +        </if-not-empty>
>         <store-value value-field="lookedUpValue"/>
>     </simple-method>
>     <simple-method method-name="deleteProductPromoCond" short-description="Delete an ProductPromoCond">
>
> Modified: ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml?rev=776581&r1=776580&r2=776581&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml (original)
> +++ ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml Wed May 20 06:25:23 2009
> @@ -273,6 +273,7 @@
>         <description>Create a ProductPromo</description>
>         <auto-attributes include="pk" mode="IN" optional="false"/>
>         <auto-attributes include="nonpk" mode="IN" optional="true"/>
> +        <attribute name="carrierShipmentMethod" type="String" mode="IN" optional="true"/>
>         <override name="productPromoCondSeqId" mode="OUT"/>
>     </service>
>     <service name="updateProductPromoCond" default-entity-name="ProductPromoCond" engine="simple"
> @@ -280,6 +281,7 @@
>         <description>Update a ProductPromo</description>
>         <auto-attributes include="pk" mode="IN" optional="false"/>
>         <auto-attributes include="nonpk" mode="IN" optional="true"/>
> +        <attribute name="carrierShipmentMethod" type="String" mode="IN" optional="true"/>
>     </service>
>     <service name="deleteProductPromoCond" default-entity-name="ProductPromoCond" engine="simple"
>                 location="component://product/script/org/ofbiz/product/promo/PromoServices.xml" invoke="deleteProductPromoCond"
> auth="true">
>
> Modified: ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl?rev=776581&r1=776580&r2=776581&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl (original)
> +++ ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl Wed May 20 06:25:23 2009
> @@ -98,7 +98,27 @@
>                                             </#list>
>                                         </select>
>                                         <input type="text" size="25" name="condValue"
> value="${(productPromoCond.condValue)?if_exists}">
> -                                        ${uiLabelMap.CommonOther}:<input type="text" size="10" name="otherValue"
> value="${(productPromoCond.otherValue)?if_exists}">
> +                                        <#assign otherValue = productPromoCond.otherValue?if_exists>
> +                                        <label>${uiLabelMap.CommonOther}:</label><input type="text" size="10" name="otherValue"
> <#if otherValue?has_content && !otherValue.contains("@")> value="${(productPromoCond.otherValue)?if_exists}"</#if> >
> +                                        <#if otherValue?has_content && otherValue.contains("@")>
> +                                            <#assign carrierShippingMethod = productPromoCond.otherValue?if_exists>
> +                                        </#if>
> +                                        <#if carrierShippingMethod?has_content>
> +                                            <#assign carrierParty = carrierShippingMethod.substring(0,
> carrierShippingMethod.indexOf("@"))>
> +                                            <#assign shippingMethodTypeId =
> carrierShippingMethod.substring(carrierShippingMethod.indexOf("@")+1)>
> +                                            <#assign description = (delegator.findOne("ShipmentMethodType",
> {"shipmentMethodTypeId":shippingMethodTypeId}, false)).description>
> +                                        <#else>
> +                                            <#assign description = "">
> +                                        </#if>
> +                                        <label>${uiLabelMap.OrderSelectShippingMethod}:</label>
> +                                        <select name = "carrierShipmentMethod">
> +                                            <option value =
> "${productPromoCond.carrierShippingMethod?if_exists}">${carrierParty?if_exists}&nbsp;${description}</option>
> +                                            <option value = "">&nbsp;</option>
> +                                            <#list carrierShipmentMethods as carrierShipmentMethod>
> +                                                <#assign shipmentMethodType =
> carrierShipmentMethod.getRelatedOneCache("ShipmentMethodType")>
> +                                                <option value =
> "${carrierShipmentMethod.partyId?if_exists}@${carrierShipmentMethod.shipmentMethodTypeId?if_exists}">${carrierShipmentMethod.partyId?if_exists}&nbsp;${shipmentMethodType.get("description")?if_exists}</option>
> +                                            </#list>
> +                                        </select>
>                                         <input type="submit" value="${uiLabelMap.CommonUpdate}">
>                                     </form>
>                                     <#-- ======================= Categories ======================== -->
> @@ -207,6 +227,14 @@
>                                         </select>
>                                         <input type="text" size="25" name="condValue">
>                                         ${uiLabelMap.CommonOther}:<input type="text" size="10" name="otherValue">
> +                                        <label>${uiLabelMap.OrderSelectShippingMethod}:</label>
> +                                        <select name = "carrierShipmentMethod">
> +                                            <option value = "">--${uiLabelMap.OrderSelectShippingMethod}--</option>
> +                                            <#list carrierShipmentMethods as carrierShipmentMethod>
> +                                                <#assign shipmentMethodType =
> carrierShipmentMethod.getRelatedOneCache("ShipmentMethodType")>
> +                                                <option value =
> "${carrierShipmentMethod.partyId?if_exists}@${carrierShipmentMethod.shipmentMethodTypeId?if_exists}">${carrierShipmentMethod.partyId?if_exists}&nbsp;${shipmentMethodType.get("description")?if_exists}</option>
> +                                            </#list>
> +                                        </select>
>                                         <input type="submit" value="${uiLabelMap.CommonCreate}">
>                                     </form>
>                                 </td>
>
> Modified: ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml?rev=776581&r1=776580&r2=776581&view=diff
> ==============================================================================
> --- ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml (original)
> +++ ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml Wed May 20 06:25:23 2009
> @@ -164,6 +164,7 @@
>                 <set field="tabButtonItem" value="EditProductPromoRules"/>
>                 <set field="labelTitleProperty" value="ProductRules"/>
>
> +                <property-map resource="OrderUiLabels" map-name="uiLabelMap"/>
>                 <set field="productPromoId" from-field="parameters.productPromoId"/>
>                 <entity-one entity-name="ProductPromo" value-field="productPromo" auto-field-map="true"/>
>
> @@ -194,6 +195,9 @@
>                     <condition-expr field-name="enumTypeId" value="PROD_PROMO_IN_PARAM"/>
>                     <order-by field-name="sequenceId"/>
>                 </entity-condition>
> +                <entity-condition entity-name="CarrierShipmentMethod" list="carrierShipmentMethods" use-cache="true">
> +                    <order-by field-name="shipmentMethodTypeId"/>
> +                </entity-condition>
>                 <entity-condition entity-name="Enumeration" list="condOperEnums" use-cache="true">
>                     <condition-expr field-name="enumTypeId" value="PROD_PROMO_COND"/>
>                     <order-by field-name="sequenceId"/>
>
> Modified: ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml
> URL:
> http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml?rev=776581&r1=776580&r2=776581&view=diff
> ==============================================================================
> --- ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml (original)
> +++ ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml Wed May 20 06:25:23 2009
> @@ -1149,6 +1149,10 @@
>             parameters.put("cartGrandTotal", cartGrandTotal);
>
>         ]]></call-bsh>
> +        <call-class-method method-name="doPromotions" class-name="org.ofbiz.order.shoppingcart.product.ProductPromoWorker">
> +            <field field="shoppingCart" type="org.ofbiz.order.shoppingcart.ShoppingCart"/>
> +            <field field="dispatcher" type="org.ofbiz.service.LocalDispatcher"/>
> +        </call-class-method>
>         <field-to-request field="parameters.shippingTotal" request-name="shippingTotal"/>
>         <field-to-request field="parameters.cartGrandTotal" request-name="cartGrandTotal"/>
>         <field-to-request field="parameters.totalSalesTax" request-name="totalSalesTax"/>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r776581 - in /ofbiz/trunk: applications/order/src/org/ofbiz/order/shoppingcart/ applications/order/src/org/ofbiz/order/shoppingcart/product/ applications/order/src/org/ofbiz/order/shoppingcart/shipping/ applications/product/data/ applicatio

Vikas Mayur-3
Yes it is. A New promotion rule can be setup on the basis of  
percentage on shipping discount and it could be 100% discount (free  
shipping).

Vikas

On May 20, 2009, at 12:29 PM, Jacques Le Roux wrote:

> Does this allow for free-shipping ?
>
> Jacques
>
> From: <[hidden email]>
>> Author: mor
>> Date: Wed May 20 06:25:23 2009
>> New Revision: 776581
>>
>> URL: http://svn.apache.org/viewvc?rev=776581&view=rev
>> Log:
>> Now Shipping Total adjustments can be applied using promotion. User  
>> can specify percentage discount on a specific shipping method.
>> Applied patch from Arun Patidar, part of OFBIZ-2488 (https://issues.apache.org/jira/browse/OFBIZ-2488 
>> )
>>
>> Modified:
>>   ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>> CheckOutHelper.java
>>   ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>> product/ProductPromoWorker.java
>>   ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>> shipping/ShippingEvents.java
>>   ofbiz/trunk/applications/product/data/ProductTypeData.xml
>>   ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/
>> PromoServices.xml
>>   ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
>>   ofbiz/trunk/applications/product/webapp/catalog/promo/
>> EditProductPromoRules.ftl
>>   ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml
>>   ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/
>> customer/CustomerEvents.xml
>>
>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/
>> shoppingcart/CheckOutHelper.java
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=776581&r1=776580&r2=776581&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>> CheckOutHelper.java (original)
>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>> CheckOutHelper.java Wed May 20 06:25:23 2009
>> @@ -53,6 +53,7 @@
>> import org.ofbiz.order.finaccount.FinAccountHelper;
>> import org.ofbiz.order.order.OrderChangeHelper;
>> import org.ofbiz.order.order.OrderReadHelper;
>> +import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;
>> import org.ofbiz.order.shoppingcart.shipping.ShippingEvents;
>> import org.ofbiz.party.contact.ContactHelper;
>> import org.ofbiz.product.store.ProductStoreWorker;
>> @@ -407,6 +408,7 @@
>>                shippingTotal = BigDecimal.ZERO;
>>            }
>>            cart.setItemShipGroupEstimate(shippingTotal, 0);
>> +            ProductPromoWorker.doPromotions(cart, dispatcher);
>>
>>            //Recalc tax before setting payment
>>            try {
>>
>> 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=776581&r1=776580&r2=776581&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 Wed May 20 06:25:23 2009
>> @@ -763,7 +763,12 @@
>>        String otherValue = productPromoCond.getString("otherValue");
>>        String inputParamEnumId =  
>> productPromoCond.getString("inputParamEnumId");
>>        String operatorEnumId =  
>> productPromoCond.getString("operatorEnumId");
>> +        String shippingMethod = "";
>>
>> +        if (otherValue != null && otherValue.contains("@")) {
>> +            shippingMethod =  
>> otherValue.substring(otherValue.indexOf("@")+1);
>> +            otherValue = "";
>> +        }
>>        String partyId = cart.getPartyId();
>>        GenericValue userLogin = cart.getUserLogin();
>>        if (userLogin == null) {
>> @@ -1121,6 +1126,10 @@
>>                    }
>>                }
>>            }
>> +        } else if ("PPIP_ORDER_SHIPTOTAL".equals(inputParamEnumId)  
>> && shippingMethod.equals(cart.getShipmentMethodTypeId())) {
>> +            BigDecimal orderTotalShipping = cart.getTotalShipping();
>> +            if (Debug.verboseOn()) { Debug.logVerbose("Doing order  
>> total Shipping compare: ordertotalShipping=" + orderTotalShipping,  
>> module); }
>> +            compareBase = new  
>> Integer(orderTotalShipping.compareTo(new BigDecimal(condValue)));
>>        } else {
>>            
>> Debug
>> .logWarning
>> (UtilProperties
>> .getMessage
>> (resource_error
>> ,"OrderAnUnSupportedProductPromoCondInputParameterLhs",  
>> UtilMisc
>> .toMap
>> ("inputParamEnumId
>> ",productPromoCond.getString("inputParamEnumId")),  
>> cart.getLocale()), module);
>>            return false;
>> @@ -1494,6 +1503,14 @@
>>                    }
>>                }
>>            }
>> +        } else if  
>> ("PROMO_SHIP_CHARGE".equals(productPromoActionEnumId)) {
>> +            BigDecimal percentage =  
>> (productPromoAction.get("amount") == null ? BigDecimal.ZERO :  
>> (productPromoAction
>> .getBigDecimal("amount").movePointLeft(2))).negate();
>> +            BigDecimal amount =  
>> cart.getTotalShipping().multiply(percentage);
>> +            if (amount.compareTo(BigDecimal.ZERO) != 0) {
>> +                doOrderPromoAction(productPromoAction, cart,  
>> amount, "amount", delegator);
>> +                actionResultInfo.ranAction = true;
>> +                actionResultInfo.totalDiscountAmount = amount;
>> +            }
>>        } else {
>>            Debug.logError("An un-supported productPromoActionType  
>> was used: " + productPromoActionEnumId + ", not performing any  
>> action", module);
>>            actionResultInfo.ranAction = false;
>>
>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/
>> shoppingcart/shipping/ShippingEvents.java
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java?rev=776581&r1=776580&r2=776581&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>> shipping/ShippingEvents.java (original)
>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>> shipping/ShippingEvents.java Wed May 20 06:25:23 2009
>> @@ -52,6 +52,7 @@
>> import java.util.HashMap;
>> import java.util.List;
>> import java.util.Map;
>> +import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;
>>
>> /**
>> * ShippingEvents - Events used for processing shipping fees
>> @@ -84,6 +85,7 @@
>>            cart.setItemShipGroupEstimate(shippingTotal, i);
>>        }
>>
>> +        ProductPromoWorker.doPromotions(cart, dispatcher);
>>        // all done
>>        return "success";
>>    }
>>
>> Modified: ofbiz/trunk/applications/product/data/ProductTypeData.xml
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?rev=776581&r1=776580&r2=776581&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- ofbiz/trunk/applications/product/data/ProductTypeData.xml  
>> (original)
>> +++ ofbiz/trunk/applications/product/data/ProductTypeData.xml Wed  
>> May 20 06:25:23 2009
>> @@ -377,6 +377,7 @@
>>    <Enumeration description="Promotion Recurrence"  
>> enumCode="PROMO_RECURRENCE" enumId="PPIP_RECURRENCE"  
>> sequenceId="11" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>    <Enumeration description="Order sub-total X since beginning of  
>> current year" enumCode="ORST_YEAR" enumId="PPIP_ORST_YEAR"  
>> sequenceId="12" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>    <Enumeration description="Order sub-total X last year"  
>> enumCode="ORST_LAST_YEAR" enumId="PPIP_ORST_LAST_YEAR"  
>> sequenceId="13" enumTypeId="PROD_PROMO_IN_PARAM"/>
>> +    <Enumeration description="Shipping Total"  
>> enumCode="ORDER_SHIP_TOTAL" enumId="PPIP_ORDER_SHIPTOTAL"  
>> sequenceId="14" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>
>>    <EnumerationType description="Product Promotion Condition"  
>> enumTypeId="PROD_PROMO_COND" hasTable="N" parentTypeId="PROD_PROMO"/>
>>    <!-- old style very technical ...
>> @@ -408,6 +409,7 @@
>>    <Enumeration description="Order Percent Discount"  
>> enumCode="ORDER_PERCENT" enumId="PROMO_ORDER_PERCENT"  
>> sequenceId="06" enumTypeId="PROD_PROMO_ACTION"/>
>>    <Enumeration description="Order Amount Flat"  
>> enumCode="ORDER_AMOUNT" enumId="PROMO_ORDER_AMOUNT" sequenceId="07"  
>> enumTypeId="PROD_PROMO_ACTION"/>
>>    <Enumeration description="Product for [Special Promo] Price"  
>> enumCode="PROD_SPPRC" enumId="PROMO_PROD_SPPRC" sequenceId="08"  
>> enumTypeId="PROD_PROMO_ACTION"/>
>> +    <Enumeration description="Shipping X% discount"  
>> enumCode="SHIP_CHARGE" enumId="PROMO_SHIP_CHARGE" sequenceId="09"  
>> enumTypeId="PROD_PROMO_ACTION"/>
>>
>>    <EnumerationType description="Product Rating Field Type"  
>> enumTypeId="PROD_RATING_TYPE" hasTable="N" parentTypeId=""/>
>>    <Enumeration description="Min Rating" enumCode="MIN"  
>> enumId="PRDR_MIN" sequenceId="01" enumTypeId="PROD_RATING_TYPE"/>
>>
>> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/
>> promo/PromoServices.xml
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml?rev=776581&r1=776580&r2=776581&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/
>> PromoServices.xml (original)
>> +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/
>> PromoServices.xml Wed May 20 06:25:23 2009
>> @@ -251,6 +251,9 @@
>>
>>        <make-value value-field="newEntity" entity-
>> name="ProductPromoCond"/>
>>        <set-nonpk-fields map="parameters" value-field="newEntity"/>
>> +        <if-not-empty field="parameters.carrierShipmentMethod">
>> +            <set field="newEntity.otherValue" from-
>> field="parameters.carrierShipmentMethod"/>
>> +        </if-not-empty>
>>        <set-pk-fields map="parameters" value-field="newEntity"/>
>>        <make-next-seq-id value-field="newEntity" seq-field-
>> name="productPromoCondSeqId" numeric-padding="2"/>
>>        <field-to-result field="newEntity.productPromoCondSeqId"  
>> result-name="productPromoCondSeqId"/>
>> @@ -266,6 +269,9 @@
>>        <set-pk-fields map="parameters" value-field="lookupPKMap"/>
>>        <find-by-primary-key entity-name="ProductPromoCond"  
>> map="lookupPKMap" value-field="lookedUpValue"/>
>>        <set-nonpk-fields map="parameters" value-
>> field="lookedUpValue"/>
>> +        <if-not-empty field="parameters.carrierShipmentMethod">
>> +            <set field="lookedUpValue.otherValue" from-
>> field="parameters.carrierShipmentMethod"/>
>> +        </if-not-empty>
>>        <store-value value-field="lookedUpValue"/>
>>    </simple-method>
>>    <simple-method method-name="deleteProductPromoCond" short-
>> description="Delete an ProductPromoCond">
>>
>> Modified: ofbiz/trunk/applications/product/servicedef/
>> services_pricepromo.xml
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml?rev=776581&r1=776580&r2=776581&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- ofbiz/trunk/applications/product/servicedef/
>> services_pricepromo.xml (original)
>> +++ ofbiz/trunk/applications/product/servicedef/
>> services_pricepromo.xml Wed May 20 06:25:23 2009
>> @@ -273,6 +273,7 @@
>>        <description>Create a ProductPromo</description>
>>        <auto-attributes include="pk" mode="IN" optional="false"/>
>>        <auto-attributes include="nonpk" mode="IN" optional="true"/>
>> +        <attribute name="carrierShipmentMethod" type="String"  
>> mode="IN" optional="true"/>
>>        <override name="productPromoCondSeqId" mode="OUT"/>
>>    </service>
>>    <service name="updateProductPromoCond" default-entity-
>> name="ProductPromoCond" engine="simple"
>> @@ -280,6 +281,7 @@
>>        <description>Update a ProductPromo</description>
>>        <auto-attributes include="pk" mode="IN" optional="false"/>
>>        <auto-attributes include="nonpk" mode="IN" optional="true"/>
>> +        <attribute name="carrierShipmentMethod" type="String"  
>> mode="IN" optional="true"/>
>>    </service>
>>    <service name="deleteProductPromoCond" default-entity-
>> name="ProductPromoCond" engine="simple"
>>                location="component://product/script/org/ofbiz/
>> product/promo/PromoServices.xml" invoke="deleteProductPromoCond"  
>> auth="true">
>>
>> Modified: ofbiz/trunk/applications/product/webapp/catalog/promo/
>> EditProductPromoRules.ftl
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl?rev=776581&r1=776580&r2=776581&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- ofbiz/trunk/applications/product/webapp/catalog/promo/
>> EditProductPromoRules.ftl (original)
>> +++ ofbiz/trunk/applications/product/webapp/catalog/promo/
>> EditProductPromoRules.ftl Wed May 20 06:25:23 2009
>> @@ -98,7 +98,27 @@
>>                                            </#list>
>>                                        </select>
>>                                        <input type="text" size="25"  
>> name="condValue" value="${(productPromoCond.condValue)?if_exists}">
>> -                                        $
>> {uiLabelMap.CommonOther}:<input type="text" size="10"  
>> name="otherValue" value="${(productPromoCond.otherValue)?if_exists}">
>> +                                        <#assign otherValue =  
>> productPromoCond.otherValue?if_exists>
>> +                                        <label>$
>> {uiLabelMap.CommonOther}:</label><input type="text" size="10"  
>> name="otherValue" <#if otherValue?has_content && !
>> otherValue.contains("@")> value="${(productPromoCond.otherValue)?
>> if_exists}"</#if> >
>> +                                        <#if otherValue?
>> has_content && otherValue.contains("@")>
>> +                                            <#assign  
>> carrierShippingMethod = productPromoCond.otherValue?if_exists>
>> +                                        </#if>
>> +                                        <#if carrierShippingMethod?
>> has_content>
>> +                                            <#assign carrierParty  
>> = carrierShippingMethod.substring(0,  
>> carrierShippingMethod.indexOf("@"))>
>> +                                            <#assign  
>> shippingMethodTypeId =  
>> carrierShippingMethod.substring(carrierShippingMethod.indexOf("@")
>> +1)>
>> +                                            <#assign description =  
>> (delegator.findOne("ShipmentMethodType",  
>> {"shipmentMethodTypeId":shippingMethodTypeId}, false)).description>
>> +                                        <#else>
>> +                                            <#assign description =  
>> "">
>> +                                        </#if>
>> +                                        <label>$
>> {uiLabelMap.OrderSelectShippingMethod}:</label>
>> +                                        <select name =  
>> "carrierShipmentMethod">
>> +                                            <option value = "$
>> {productPromoCond.carrierShippingMethod?if_exists}">${carrierParty?
>> if_exists}&nbsp;${description}</option>
>> +                                            <option value =  
>> "">&nbsp;</option>
>> +                                            <#list  
>> carrierShipmentMethods as carrierShipmentMethod>
>> +                                                <#assign  
>> shipmentMethodType =  
>> carrierShipmentMethod.getRelatedOneCache("ShipmentMethodType")>
>> +                                                <option value = "$
>> {carrierShipmentMethod.partyId?if_exists}@$
>> {carrierShipmentMethod.shipmentMethodTypeId?if_exists}">$
>> {carrierShipmentMethod.partyId?if_exists}&nbsp;$
>> {shipmentMethodType.get("description")?if_exists}</option>
>> +                                            </#list>
>> +                                        </select>
>>                                        <input type="submit" value="$
>> {uiLabelMap.CommonUpdate}">
>>                                    </form>
>>                                    <#-- =======================  
>> Categories ======================== -->
>> @@ -207,6 +227,14 @@
>>                                        </select>
>>                                        <input type="text" size="25"  
>> name="condValue">
>>                                        $
>> {uiLabelMap.CommonOther}:<input type="text" size="10"  
>> name="otherValue">
>> +                                        <label>$
>> {uiLabelMap.OrderSelectShippingMethod}:</label>
>> +                                        <select name =  
>> "carrierShipmentMethod">
>> +                                            <option value = "">--$
>> {uiLabelMap.OrderSelectShippingMethod}--</option>
>> +                                            <#list  
>> carrierShipmentMethods as carrierShipmentMethod>
>> +                                                <#assign  
>> shipmentMethodType =  
>> carrierShipmentMethod.getRelatedOneCache("ShipmentMethodType")>
>> +                                                <option value = "$
>> {carrierShipmentMethod.partyId?if_exists}@$
>> {carrierShipmentMethod.shipmentMethodTypeId?if_exists}">$
>> {carrierShipmentMethod.partyId?if_exists}&nbsp;$
>> {shipmentMethodType.get("description")?if_exists}</option>
>> +                                            </#list>
>> +                                        </select>
>>                                        <input type="submit" value="$
>> {uiLabelMap.CommonCreate}">
>>                                    </form>
>>                                </td>
>>
>> Modified: ofbiz/trunk/applications/product/widget/catalog/
>> PromoScreens.xml
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml?rev=776581&r1=776580&r2=776581&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- ofbiz/trunk/applications/product/widget/catalog/
>> PromoScreens.xml (original)
>> +++ ofbiz/trunk/applications/product/widget/catalog/
>> PromoScreens.xml Wed May 20 06:25:23 2009
>> @@ -164,6 +164,7 @@
>>                <set field="tabButtonItem"  
>> value="EditProductPromoRules"/>
>>                <set field="labelTitleProperty" value="ProductRules"/>
>>
>> +                <property-map resource="OrderUiLabels" map-
>> name="uiLabelMap"/>
>>                <set field="productPromoId" from-
>> field="parameters.productPromoId"/>
>>                <entity-one entity-name="ProductPromo" value-
>> field="productPromo" auto-field-map="true"/>
>>
>> @@ -194,6 +195,9 @@
>>                    <condition-expr field-name="enumTypeId"  
>> value="PROD_PROMO_IN_PARAM"/>
>>                    <order-by field-name="sequenceId"/>
>>                </entity-condition>
>> +                <entity-condition entity-
>> name="CarrierShipmentMethod" list="carrierShipmentMethods" use-
>> cache="true">
>> +                    <order-by field-name="shipmentMethodTypeId"/>
>> +                </entity-condition>
>>                <entity-condition entity-name="Enumeration"  
>> list="condOperEnums" use-cache="true">
>>                    <condition-expr field-name="enumTypeId"  
>> value="PROD_PROMO_COND"/>
>>                    <order-by field-name="sequenceId"/>
>>
>> Modified: ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/
>> ecommerce/customer/CustomerEvents.xml
>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml?rev=776581&r1=776580&r2=776581&view=diff
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/
>> customer/CustomerEvents.xml (original)
>> +++ ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/
>> customer/CustomerEvents.xml Wed May 20 06:25:23 2009
>> @@ -1149,6 +1149,10 @@
>>            parameters.put("cartGrandTotal", cartGrandTotal);
>>
>>        ]]></call-bsh>
>> +        <call-class-method method-name="doPromotions" class-
>> name="org.ofbiz.order.shoppingcart.product.ProductPromoWorker">
>> +            <field field="shoppingCart"  
>> type="org.ofbiz.order.shoppingcart.ShoppingCart"/>
>> +            <field field="dispatcher"  
>> type="org.ofbiz.service.LocalDispatcher"/>
>> +        </call-class-method>
>>        <field-to-request field="parameters.shippingTotal" request-
>> name="shippingTotal"/>
>>        <field-to-request field="parameters.cartGrandTotal" request-
>> name="cartGrandTotal"/>
>>        <field-to-request field="parameters.totalSalesTax" request-
>> name="totalSalesTax"/>
>>
>
>


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r776581 - in /ofbiz/trunk: applications/order/src/org/ofbiz/order/shoppingcart/ applications/order/src/org/ofbiz/order/shoppingcart/product/ applications/order/src/org/ofbiz/order/shoppingcart/shipping/ applications/product/data/ applicatio

David E Jones-3

Thanks Vikas and others involved... it is VERY cool to have this back  
in OFBiz!

-David


On May 20, 2009, at 1:54 AM, Vikas Mayur wrote:

> Yes it is. A New promotion rule can be setup on the basis of  
> percentage on shipping discount and it could be 100% discount (free  
> shipping).
>
> Vikas
>
> On May 20, 2009, at 12:29 PM, Jacques Le Roux wrote:
>
>> Does this allow for free-shipping ?
>>
>> Jacques
>>
>> From: <[hidden email]>
>>> Author: mor
>>> Date: Wed May 20 06:25:23 2009
>>> New Revision: 776581
>>>
>>> URL: http://svn.apache.org/viewvc?rev=776581&view=rev
>>> Log:
>>> Now Shipping Total adjustments can be applied using promotion.  
>>> User can specify percentage discount on a specific shipping method.
>>> Applied patch from Arun Patidar, part of OFBIZ-2488 (https://issues.apache.org/jira/browse/OFBIZ-2488 
>>> )
>>>
>>> Modified:
>>>  ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>>> CheckOutHelper.java
>>>  ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>>> product/ProductPromoWorker.java
>>>  ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/
>>> shipping/ShippingEvents.java
>>>  ofbiz/trunk/applications/product/data/ProductTypeData.xml
>>>  ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/
>>> PromoServices.xml
>>>  ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
>>>  ofbiz/trunk/applications/product/webapp/catalog/promo/
>>> EditProductPromoRules.ftl
>>>  ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml
>>>  ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/
>>> customer/CustomerEvents.xml
>>>
>>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/
>>> shoppingcart/CheckOutHelper.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=776581&r1=776580&r2=776581&view=diff
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/
>>> shoppingcart/CheckOutHelper.java (original)
>>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/
>>> shoppingcart/CheckOutHelper.java Wed May 20 06:25:23 2009
>>> @@ -53,6 +53,7 @@
>>> import org.ofbiz.order.finaccount.FinAccountHelper;
>>> import org.ofbiz.order.order.OrderChangeHelper;
>>> import org.ofbiz.order.order.OrderReadHelper;
>>> +import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;
>>> import org.ofbiz.order.shoppingcart.shipping.ShippingEvents;
>>> import org.ofbiz.party.contact.ContactHelper;
>>> import org.ofbiz.product.store.ProductStoreWorker;
>>> @@ -407,6 +408,7 @@
>>>               shippingTotal = BigDecimal.ZERO;
>>>           }
>>>           cart.setItemShipGroupEstimate(shippingTotal, 0);
>>> +            ProductPromoWorker.doPromotions(cart, dispatcher);
>>>
>>>           //Recalc tax before setting payment
>>>           try {
>>>
>>> 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=776581&r1=776580&r2=776581&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 Wed May 20 06:25:23  
>>> 2009
>>> @@ -763,7 +763,12 @@
>>>       String otherValue = productPromoCond.getString("otherValue");
>>>       String inputParamEnumId =  
>>> productPromoCond.getString("inputParamEnumId");
>>>       String operatorEnumId =  
>>> productPromoCond.getString("operatorEnumId");
>>> +        String shippingMethod = "";
>>>
>>> +        if (otherValue != null && otherValue.contains("@")) {
>>> +            shippingMethod =  
>>> otherValue.substring(otherValue.indexOf("@")+1);
>>> +            otherValue = "";
>>> +        }
>>>       String partyId = cart.getPartyId();
>>>       GenericValue userLogin = cart.getUserLogin();
>>>       if (userLogin == null) {
>>> @@ -1121,6 +1126,10 @@
>>>                   }
>>>               }
>>>           }
>>> +        } else if  
>>> ("PPIP_ORDER_SHIPTOTAL".equals(inputParamEnumId) &&  
>>> shippingMethod.equals(cart.getShipmentMethodTypeId())) {
>>> +            BigDecimal orderTotalShipping =  
>>> cart.getTotalShipping();
>>> +            if (Debug.verboseOn()) { Debug.logVerbose("Doing  
>>> order total Shipping compare: ordertotalShipping=" +  
>>> orderTotalShipping, module); }
>>> +            compareBase = new  
>>> Integer(orderTotalShipping.compareTo(new BigDecimal(condValue)));
>>>       } else {
>>>            
>>> Debug
>>> .logWarning
>>> (UtilProperties
>>> .getMessage
>>> (resource_error
>>> ,"OrderAnUnSupportedProductPromoCondInputParameterLhs",  
>>> UtilMisc
>>> .toMap
>>> ("inputParamEnumId
>>> ",productPromoCond.getString("inputParamEnumId")),  
>>> cart.getLocale()), module);
>>>           return false;
>>> @@ -1494,6 +1503,14 @@
>>>                   }
>>>               }
>>>           }
>>> +        } else if  
>>> ("PROMO_SHIP_CHARGE".equals(productPromoActionEnumId)) {
>>> +            BigDecimal percentage =  
>>> (productPromoAction.get("amount") == null ? BigDecimal.ZERO :  
>>> (productPromoAction
>>> .getBigDecimal("amount").movePointLeft(2))).negate();
>>> +            BigDecimal amount =  
>>> cart.getTotalShipping().multiply(percentage);
>>> +            if (amount.compareTo(BigDecimal.ZERO) != 0) {
>>> +                doOrderPromoAction(productPromoAction, cart,  
>>> amount, "amount", delegator);
>>> +                actionResultInfo.ranAction = true;
>>> +                actionResultInfo.totalDiscountAmount = amount;
>>> +            }
>>>       } else {
>>>           Debug.logError("An un-supported productPromoActionType  
>>> was used: " + productPromoActionEnumId + ", not performing any  
>>> action", module);
>>>           actionResultInfo.ranAction = false;
>>>
>>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/
>>> shoppingcart/shipping/ShippingEvents.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java?rev=776581&r1=776580&r2=776581&view=diff
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/
>>> shoppingcart/shipping/ShippingEvents.java (original)
>>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/
>>> shoppingcart/shipping/ShippingEvents.java Wed May 20 06:25:23 2009
>>> @@ -52,6 +52,7 @@
>>> import java.util.HashMap;
>>> import java.util.List;
>>> import java.util.Map;
>>> +import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;
>>>
>>> /**
>>> * ShippingEvents - Events used for processing shipping fees
>>> @@ -84,6 +85,7 @@
>>>           cart.setItemShipGroupEstimate(shippingTotal, i);
>>>       }
>>>
>>> +        ProductPromoWorker.doPromotions(cart, dispatcher);
>>>       // all done
>>>       return "success";
>>>   }
>>>
>>> Modified: ofbiz/trunk/applications/product/data/ProductTypeData.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?rev=776581&r1=776580&r2=776581&view=diff
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/applications/product/data/ProductTypeData.xml  
>>> (original)
>>> +++ ofbiz/trunk/applications/product/data/ProductTypeData.xml Wed  
>>> May 20 06:25:23 2009
>>> @@ -377,6 +377,7 @@
>>>   <Enumeration description="Promotion Recurrence"  
>>> enumCode="PROMO_RECURRENCE" enumId="PPIP_RECURRENCE"  
>>> sequenceId="11" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>>   <Enumeration description="Order sub-total X since beginning of  
>>> current year" enumCode="ORST_YEAR" enumId="PPIP_ORST_YEAR"  
>>> sequenceId="12" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>>   <Enumeration description="Order sub-total X last year"  
>>> enumCode="ORST_LAST_YEAR" enumId="PPIP_ORST_LAST_YEAR"  
>>> sequenceId="13" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>> +    <Enumeration description="Shipping Total"  
>>> enumCode="ORDER_SHIP_TOTAL" enumId="PPIP_ORDER_SHIPTOTAL"  
>>> sequenceId="14" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>>
>>>   <EnumerationType description="Product Promotion Condition"  
>>> enumTypeId="PROD_PROMO_COND" hasTable="N"  
>>> parentTypeId="PROD_PROMO"/>
>>>   <!-- old style very technical ...
>>> @@ -408,6 +409,7 @@
>>>   <Enumeration description="Order Percent Discount"  
>>> enumCode="ORDER_PERCENT" enumId="PROMO_ORDER_PERCENT"  
>>> sequenceId="06" enumTypeId="PROD_PROMO_ACTION"/>
>>>   <Enumeration description="Order Amount Flat"  
>>> enumCode="ORDER_AMOUNT" enumId="PROMO_ORDER_AMOUNT"  
>>> sequenceId="07" enumTypeId="PROD_PROMO_ACTION"/>
>>>   <Enumeration description="Product for [Special Promo] Price"  
>>> enumCode="PROD_SPPRC" enumId="PROMO_PROD_SPPRC" sequenceId="08"  
>>> enumTypeId="PROD_PROMO_ACTION"/>
>>> +    <Enumeration description="Shipping X% discount"  
>>> enumCode="SHIP_CHARGE" enumId="PROMO_SHIP_CHARGE" sequenceId="09"  
>>> enumTypeId="PROD_PROMO_ACTION"/>
>>>
>>>   <EnumerationType description="Product Rating Field Type"  
>>> enumTypeId="PROD_RATING_TYPE" hasTable="N" parentTypeId=""/>
>>>   <Enumeration description="Min Rating" enumCode="MIN"  
>>> enumId="PRDR_MIN" sequenceId="01" enumTypeId="PROD_RATING_TYPE"/>
>>>
>>> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/
>>> product/promo/PromoServices.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml?rev=776581&r1=776580&r2=776581&view=diff
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/applications/product/script/org/ofbiz/product/
>>> promo/PromoServices.xml (original)
>>> +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/
>>> promo/PromoServices.xml Wed May 20 06:25:23 2009
>>> @@ -251,6 +251,9 @@
>>>
>>>       <make-value value-field="newEntity" entity-
>>> name="ProductPromoCond"/>
>>>       <set-nonpk-fields map="parameters" value-field="newEntity"/>
>>> +        <if-not-empty field="parameters.carrierShipmentMethod">
>>> +            <set field="newEntity.otherValue" from-
>>> field="parameters.carrierShipmentMethod"/>
>>> +        </if-not-empty>
>>>       <set-pk-fields map="parameters" value-field="newEntity"/>
>>>       <make-next-seq-id value-field="newEntity" seq-field-
>>> name="productPromoCondSeqId" numeric-padding="2"/>
>>>       <field-to-result field="newEntity.productPromoCondSeqId"  
>>> result-name="productPromoCondSeqId"/>
>>> @@ -266,6 +269,9 @@
>>>       <set-pk-fields map="parameters" value-field="lookupPKMap"/>
>>>       <find-by-primary-key entity-name="ProductPromoCond"  
>>> map="lookupPKMap" value-field="lookedUpValue"/>
>>>       <set-nonpk-fields map="parameters" value-
>>> field="lookedUpValue"/>
>>> +        <if-not-empty field="parameters.carrierShipmentMethod">
>>> +            <set field="lookedUpValue.otherValue" from-
>>> field="parameters.carrierShipmentMethod"/>
>>> +        </if-not-empty>
>>>       <store-value value-field="lookedUpValue"/>
>>>   </simple-method>
>>>   <simple-method method-name="deleteProductPromoCond" short-
>>> description="Delete an ProductPromoCond">
>>>
>>> Modified: ofbiz/trunk/applications/product/servicedef/
>>> services_pricepromo.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml?rev=776581&r1=776580&r2=776581&view=diff
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/applications/product/servicedef/
>>> services_pricepromo.xml (original)
>>> +++ ofbiz/trunk/applications/product/servicedef/
>>> services_pricepromo.xml Wed May 20 06:25:23 2009
>>> @@ -273,6 +273,7 @@
>>>       <description>Create a ProductPromo</description>
>>>       <auto-attributes include="pk" mode="IN" optional="false"/>
>>>       <auto-attributes include="nonpk" mode="IN" optional="true"/>
>>> +        <attribute name="carrierShipmentMethod" type="String"  
>>> mode="IN" optional="true"/>
>>>       <override name="productPromoCondSeqId" mode="OUT"/>
>>>   </service>
>>>   <service name="updateProductPromoCond" default-entity-
>>> name="ProductPromoCond" engine="simple"
>>> @@ -280,6 +281,7 @@
>>>       <description>Update a ProductPromo</description>
>>>       <auto-attributes include="pk" mode="IN" optional="false"/>
>>>       <auto-attributes include="nonpk" mode="IN" optional="true"/>
>>> +        <attribute name="carrierShipmentMethod" type="String"  
>>> mode="IN" optional="true"/>
>>>   </service>
>>>   <service name="deleteProductPromoCond" default-entity-
>>> name="ProductPromoCond" engine="simple"
>>>               location="component://product/script/org/ofbiz/
>>> product/promo/PromoServices.xml" invoke="deleteProductPromoCond"  
>>> auth="true">
>>>
>>> Modified: ofbiz/trunk/applications/product/webapp/catalog/promo/
>>> EditProductPromoRules.ftl
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl?rev=776581&r1=776580&r2=776581&view=diff
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/applications/product/webapp/catalog/promo/
>>> EditProductPromoRules.ftl (original)
>>> +++ ofbiz/trunk/applications/product/webapp/catalog/promo/
>>> EditProductPromoRules.ftl Wed May 20 06:25:23 2009
>>> @@ -98,7 +98,27 @@
>>>                                           </#list>
>>>                                       </select>
>>>                                       <input type="text" size="25"  
>>> name="condValue" value="${(productPromoCond.condValue)?if_exists}">
>>> -                                        $
>>> {uiLabelMap.CommonOther}:<input type="text" size="10"  
>>> name="otherValue" value="${(productPromoCond.otherValue)?
>>> if_exists}">
>>> +                                        <#assign otherValue =  
>>> productPromoCond.otherValue?if_exists>
>>> +                                        <label>$
>>> {uiLabelMap.CommonOther}:</label><input type="text" size="10"  
>>> name="otherValue" <#if otherValue?has_content && !
>>> otherValue.contains("@")> value="${(productPromoCond.otherValue)?
>>> if_exists}"</#if> >
>>> +                                        <#if otherValue?
>>> has_content && otherValue.contains("@")>
>>> +                                            <#assign  
>>> carrierShippingMethod = productPromoCond.otherValue?if_exists>
>>> +                                        </#if>
>>> +                                        <#if  
>>> carrierShippingMethod?has_content>
>>> +                                            <#assign carrierParty  
>>> = carrierShippingMethod.substring(0,  
>>> carrierShippingMethod.indexOf("@"))>
>>> +                                            <#assign  
>>> shippingMethodTypeId =  
>>> carrierShippingMethod.substring(carrierShippingMethod.indexOf("@")
>>> +1)>
>>> +                                            <#assign description  
>>> = (delegator.findOne("ShipmentMethodType",  
>>> {"shipmentMethodTypeId":shippingMethodTypeId}, false)).description>
>>> +                                        <#else>
>>> +                                            <#assign description  
>>> = "">
>>> +                                        </#if>
>>> +                                        <label>$
>>> {uiLabelMap.OrderSelectShippingMethod}:</label>
>>> +                                        <select name =  
>>> "carrierShipmentMethod">
>>> +                                            <option value = "$
>>> {productPromoCond.carrierShippingMethod?if_exists}">${carrierParty?
>>> if_exists}&nbsp;${description}</option>
>>> +                                            <option value =  
>>> "">&nbsp;</option>
>>> +                                            <#list  
>>> carrierShipmentMethods as carrierShipmentMethod>
>>> +                                                <#assign  
>>> shipmentMethodType =  
>>> carrierShipmentMethod.getRelatedOneCache("ShipmentMethodType")>
>>> +                                                <option value = "$
>>> {carrierShipmentMethod.partyId?if_exists}@$
>>> {carrierShipmentMethod.shipmentMethodTypeId?if_exists}">$
>>> {carrierShipmentMethod.partyId?if_exists}&nbsp;$
>>> {shipmentMethodType.get("description")?if_exists}</option>
>>> +                                            </#list>
>>> +                                        </select>
>>>                                       <input type="submit" value="$
>>> {uiLabelMap.CommonUpdate}">
>>>                                   </form>
>>>                                   <#-- =======================  
>>> Categories ======================== -->
>>> @@ -207,6 +227,14 @@
>>>                                       </select>
>>>                                       <input type="text" size="25"  
>>> name="condValue">
>>>                                       $
>>> {uiLabelMap.CommonOther}:<input type="text" size="10"  
>>> name="otherValue">
>>> +                                        <label>$
>>> {uiLabelMap.OrderSelectShippingMethod}:</label>
>>> +                                        <select name =  
>>> "carrierShipmentMethod">
>>> +                                            <option value = "">--$
>>> {uiLabelMap.OrderSelectShippingMethod}--</option>
>>> +                                            <#list  
>>> carrierShipmentMethods as carrierShipmentMethod>
>>> +                                                <#assign  
>>> shipmentMethodType =  
>>> carrierShipmentMethod.getRelatedOneCache("ShipmentMethodType")>
>>> +                                                <option value = "$
>>> {carrierShipmentMethod.partyId?if_exists}@$
>>> {carrierShipmentMethod.shipmentMethodTypeId?if_exists}">$
>>> {carrierShipmentMethod.partyId?if_exists}&nbsp;$
>>> {shipmentMethodType.get("description")?if_exists}</option>
>>> +                                            </#list>
>>> +                                        </select>
>>>                                       <input type="submit" value="$
>>> {uiLabelMap.CommonCreate}">
>>>                                   </form>
>>>                               </td>
>>>
>>> Modified: ofbiz/trunk/applications/product/widget/catalog/
>>> PromoScreens.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml?rev=776581&r1=776580&r2=776581&view=diff
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/applications/product/widget/catalog/
>>> PromoScreens.xml (original)
>>> +++ ofbiz/trunk/applications/product/widget/catalog/
>>> PromoScreens.xml Wed May 20 06:25:23 2009
>>> @@ -164,6 +164,7 @@
>>>               <set field="tabButtonItem"  
>>> value="EditProductPromoRules"/>
>>>               <set field="labelTitleProperty" value="ProductRules"/>
>>>
>>> +                <property-map resource="OrderUiLabels" map-
>>> name="uiLabelMap"/>
>>>               <set field="productPromoId" from-
>>> field="parameters.productPromoId"/>
>>>               <entity-one entity-name="ProductPromo" value-
>>> field="productPromo" auto-field-map="true"/>
>>>
>>> @@ -194,6 +195,9 @@
>>>                   <condition-expr field-name="enumTypeId"  
>>> value="PROD_PROMO_IN_PARAM"/>
>>>                   <order-by field-name="sequenceId"/>
>>>               </entity-condition>
>>> +                <entity-condition entity-
>>> name="CarrierShipmentMethod" list="carrierShipmentMethods" use-
>>> cache="true">
>>> +                    <order-by field-name="shipmentMethodTypeId"/>
>>> +                </entity-condition>
>>>               <entity-condition entity-name="Enumeration"  
>>> list="condOperEnums" use-cache="true">
>>>                   <condition-expr field-name="enumTypeId"  
>>> value="PROD_PROMO_COND"/>
>>>                   <order-by field-name="sequenceId"/>
>>>
>>> Modified: ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/
>>> ecommerce/customer/CustomerEvents.xml
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml?rev=776581&r1=776580&r2=776581&view=diff
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/
>>> ecommerce/customer/CustomerEvents.xml (original)
>>> +++ ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/
>>> ecommerce/customer/CustomerEvents.xml Wed May 20 06:25:23 2009
>>> @@ -1149,6 +1149,10 @@
>>>           parameters.put("cartGrandTotal", cartGrandTotal);
>>>
>>>       ]]></call-bsh>
>>> +        <call-class-method method-name="doPromotions" class-
>>> name="org.ofbiz.order.shoppingcart.product.ProductPromoWorker">
>>> +            <field field="shoppingCart"  
>>> type="org.ofbiz.order.shoppingcart.ShoppingCart"/>
>>> +            <field field="dispatcher"  
>>> type="org.ofbiz.service.LocalDispatcher"/>
>>> +        </call-class-method>
>>>       <field-to-request field="parameters.shippingTotal" request-
>>> name="shippingTotal"/>
>>>       <field-to-request field="parameters.cartGrandTotal" request-
>>> name="cartGrandTotal"/>
>>>       <field-to-request field="parameters.totalSalesTax" request-
>>> name="totalSalesTax"/>
>>>
>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r776581 - in /ofbiz/trunk: applications/order/src/org/ofbiz/order/shoppingcart/ applications/order/src/org/ofbiz/order/shoppingcart/product/ applications/order/src/org/ofbiz/order/shoppingcart/shipping/ applications/product/data/ applicatio

Jacques Le Roux
Administrator
Yes, much appreciated.
For some months I had something for Free Shipping to commit (it's working with one of my customer).
It was an adaptation of freeShippingProductPromoActions. I have not reviewed this commit in detail but at 1st glance it looks
better.

Thanks

Jacques

From: "David E Jones" <[hidden email]>

>
> Thanks Vikas and others involved... it is VERY cool to have this back  in OFBiz!
>
> -David
>
>
> On May 20, 2009, at 1:54 AM, Vikas Mayur wrote:
>
>> Yes it is. A New promotion rule can be setup on the basis of  percentage on shipping discount and it could be 100% discount (free
>> shipping).
>>
>> Vikas
>>
>> On May 20, 2009, at 12:29 PM, Jacques Le Roux wrote:
>>
>>> Does this allow for free-shipping ?
>>>
>>> Jacques
>>>
>>> From: <[hidden email]>
>>>> Author: mor
>>>> Date: Wed May 20 06:25:23 2009
>>>> New Revision: 776581
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=776581&view=rev
>>>> Log:
>>>> Now Shipping Total adjustments can be applied using promotion.  User can specify percentage discount on a specific shipping
>>>> method.
>>>> Applied patch from Arun Patidar, part of OFBIZ-2488 (https://issues.apache.org/jira/browse/OFBIZ-2488 )
>>>>
>>>> Modified:
>>>>  ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ CheckOutHelper.java
>>>>  ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ product/ProductPromoWorker.java
>>>>  ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ shipping/ShippingEvents.java
>>>>  ofbiz/trunk/applications/product/data/ProductTypeData.xml
>>>>  ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/ PromoServices.xml
>>>>  ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml
>>>>  ofbiz/trunk/applications/product/webapp/catalog/promo/ EditProductPromoRules.ftl
>>>>  ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml
>>>>  ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/ customer/CustomerEvents.xml
>>>>
>>>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/CheckOutHelper.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=776581&r1=776580&r2=776581&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/CheckOutHelper.java (original)
>>>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/CheckOutHelper.java Wed May 20 06:25:23 2009
>>>> @@ -53,6 +53,7 @@
>>>> import org.ofbiz.order.finaccount.FinAccountHelper;
>>>> import org.ofbiz.order.order.OrderChangeHelper;
>>>> import org.ofbiz.order.order.OrderReadHelper;
>>>> +import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;
>>>> import org.ofbiz.order.shoppingcart.shipping.ShippingEvents;
>>>> import org.ofbiz.party.contact.ContactHelper;
>>>> import org.ofbiz.product.store.ProductStoreWorker;
>>>> @@ -407,6 +408,7 @@
>>>>               shippingTotal = BigDecimal.ZERO;
>>>>           }
>>>>           cart.setItemShipGroupEstimate(shippingTotal, 0);
>>>> +            ProductPromoWorker.doPromotions(cart, dispatcher);
>>>>
>>>>           //Recalc tax before setting payment
>>>>           try {
>>>>
>>>> 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=776581&r1=776580&r2=776581&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 Wed May 20 06:25:23  2009
>>>> @@ -763,7 +763,12 @@
>>>>       String otherValue = productPromoCond.getString("otherValue");
>>>>       String inputParamEnumId =  productPromoCond.getString("inputParamEnumId");
>>>>       String operatorEnumId =  productPromoCond.getString("operatorEnumId");
>>>> +        String shippingMethod = "";
>>>>
>>>> +        if (otherValue != null && otherValue.contains("@")) {
>>>> +            shippingMethod =  otherValue.substring(otherValue.indexOf("@")+1);
>>>> +            otherValue = "";
>>>> +        }
>>>>       String partyId = cart.getPartyId();
>>>>       GenericValue userLogin = cart.getUserLogin();
>>>>       if (userLogin == null) {
>>>> @@ -1121,6 +1126,10 @@
>>>>                   }
>>>>               }
>>>>           }
>>>> +        } else if  ("PPIP_ORDER_SHIPTOTAL".equals(inputParamEnumId) &&  shippingMethod.equals(cart.getShipmentMethodTypeId()))
>>>> {
>>>> +            BigDecimal orderTotalShipping =  cart.getTotalShipping();
>>>> +            if (Debug.verboseOn()) { Debug.logVerbose("Doing  order total Shipping compare: ordertotalShipping=" +
>>>> orderTotalShipping, module); }
>>>> +            compareBase = new  Integer(orderTotalShipping.compareTo(new BigDecimal(condValue)));
>>>>       } else {
>>>>            Debug .logWarning (UtilProperties .getMessage (resource_error
>>>> ,"OrderAnUnSupportedProductPromoCondInputParameterLhs",  UtilMisc .toMap ("inputParamEnumId
>>>> ",productPromoCond.getString("inputParamEnumId")),  cart.getLocale()), module);
>>>>           return false;
>>>> @@ -1494,6 +1503,14 @@
>>>>                   }
>>>>               }
>>>>           }
>>>> +        } else if  ("PROMO_SHIP_CHARGE".equals(productPromoActionEnumId)) {
>>>> +            BigDecimal percentage =  (productPromoAction.get("amount") == null ? BigDecimal.ZERO :  (productPromoAction
>>>> .getBigDecimal("amount").movePointLeft(2))).negate();
>>>> +            BigDecimal amount =  cart.getTotalShipping().multiply(percentage);
>>>> +            if (amount.compareTo(BigDecimal.ZERO) != 0) {
>>>> +                doOrderPromoAction(productPromoAction, cart,  amount, "amount", delegator);
>>>> +                actionResultInfo.ranAction = true;
>>>> +                actionResultInfo.totalDiscountAmount = amount;
>>>> +            }
>>>>       } else {
>>>>           Debug.logError("An un-supported productPromoActionType  was used: " + productPromoActionEnumId + ", not performing
>>>> any  action", module);
>>>>           actionResultInfo.ranAction = false;
>>>>
>>>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/shipping/ShippingEvents.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java?rev=776581&r1=776580&r2=776581&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/shipping/ShippingEvents.java (original)
>>>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/ shoppingcart/shipping/ShippingEvents.java Wed May 20 06:25:23 2009
>>>> @@ -52,6 +52,7 @@
>>>> import java.util.HashMap;
>>>> import java.util.List;
>>>> import java.util.Map;
>>>> +import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;
>>>>
>>>> /**
>>>> * ShippingEvents - Events used for processing shipping fees
>>>> @@ -84,6 +85,7 @@
>>>>           cart.setItemShipGroupEstimate(shippingTotal, i);
>>>>       }
>>>>
>>>> +        ProductPromoWorker.doPromotions(cart, dispatcher);
>>>>       // all done
>>>>       return "success";
>>>>   }
>>>>
>>>> Modified: ofbiz/trunk/applications/product/data/ProductTypeData.xml
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?rev=776581&r1=776580&r2=776581&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/applications/product/data/ProductTypeData.xml  (original)
>>>> +++ ofbiz/trunk/applications/product/data/ProductTypeData.xml Wed  May 20 06:25:23 2009
>>>> @@ -377,6 +377,7 @@
>>>>   <Enumeration description="Promotion Recurrence"  enumCode="PROMO_RECURRENCE" enumId="PPIP_RECURRENCE"  sequenceId="11"
>>>> enumTypeId="PROD_PROMO_IN_PARAM"/>
>>>>   <Enumeration description="Order sub-total X since beginning of  current year" enumCode="ORST_YEAR" enumId="PPIP_ORST_YEAR"
>>>> sequenceId="12" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>>>   <Enumeration description="Order sub-total X last year"  enumCode="ORST_LAST_YEAR" enumId="PPIP_ORST_LAST_YEAR"
>>>> sequenceId="13" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>>> +    <Enumeration description="Shipping Total"  enumCode="ORDER_SHIP_TOTAL" enumId="PPIP_ORDER_SHIPTOTAL"  sequenceId="14"
>>>> enumTypeId="PROD_PROMO_IN_PARAM"/>
>>>>
>>>>   <EnumerationType description="Product Promotion Condition"  enumTypeId="PROD_PROMO_COND" hasTable="N"
>>>> parentTypeId="PROD_PROMO"/>
>>>>   <!-- old style very technical ...
>>>> @@ -408,6 +409,7 @@
>>>>   <Enumeration description="Order Percent Discount"  enumCode="ORDER_PERCENT" enumId="PROMO_ORDER_PERCENT"  sequenceId="06"
>>>> enumTypeId="PROD_PROMO_ACTION"/>
>>>>   <Enumeration description="Order Amount Flat"  enumCode="ORDER_AMOUNT" enumId="PROMO_ORDER_AMOUNT"  sequenceId="07"
>>>> enumTypeId="PROD_PROMO_ACTION"/>
>>>>   <Enumeration description="Product for [Special Promo] Price"  enumCode="PROD_SPPRC" enumId="PROMO_PROD_SPPRC" sequenceId="08"
>>>> enumTypeId="PROD_PROMO_ACTION"/>
>>>> +    <Enumeration description="Shipping X% discount"  enumCode="SHIP_CHARGE" enumId="PROMO_SHIP_CHARGE" sequenceId="09"
>>>> enumTypeId="PROD_PROMO_ACTION"/>
>>>>
>>>>   <EnumerationType description="Product Rating Field Type"  enumTypeId="PROD_RATING_TYPE" hasTable="N" parentTypeId=""/>
>>>>   <Enumeration description="Min Rating" enumCode="MIN"  enumId="PRDR_MIN" sequenceId="01" enumTypeId="PROD_RATING_TYPE"/>
>>>>
>>>> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/ product/promo/PromoServices.xml
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml?rev=776581&r1=776580&r2=776581&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/applications/product/script/org/ofbiz/product/ promo/PromoServices.xml (original)
>>>> +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/ promo/PromoServices.xml Wed May 20 06:25:23 2009
>>>> @@ -251,6 +251,9 @@
>>>>
>>>>       <make-value value-field="newEntity" entity- name="ProductPromoCond"/>
>>>>       <set-nonpk-fields map="parameters" value-field="newEntity"/>
>>>> +        <if-not-empty field="parameters.carrierShipmentMethod">
>>>> +            <set field="newEntity.otherValue" from- field="parameters.carrierShipmentMethod"/>
>>>> +        </if-not-empty>
>>>>       <set-pk-fields map="parameters" value-field="newEntity"/>
>>>>       <make-next-seq-id value-field="newEntity" seq-field- name="productPromoCondSeqId" numeric-padding="2"/>
>>>>       <field-to-result field="newEntity.productPromoCondSeqId"  result-name="productPromoCondSeqId"/>
>>>> @@ -266,6 +269,9 @@
>>>>       <set-pk-fields map="parameters" value-field="lookupPKMap"/>
>>>>       <find-by-primary-key entity-name="ProductPromoCond"  map="lookupPKMap" value-field="lookedUpValue"/>
>>>>       <set-nonpk-fields map="parameters" value- field="lookedUpValue"/>
>>>> +        <if-not-empty field="parameters.carrierShipmentMethod">
>>>> +            <set field="lookedUpValue.otherValue" from- field="parameters.carrierShipmentMethod"/>
>>>> +        </if-not-empty>
>>>>       <store-value value-field="lookedUpValue"/>
>>>>   </simple-method>
>>>>   <simple-method method-name="deleteProductPromoCond" short- description="Delete an ProductPromoCond">
>>>>
>>>> Modified: ofbiz/trunk/applications/product/servicedef/ services_pricepromo.xml
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml?rev=776581&r1=776580&r2=776581&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/applications/product/servicedef/ services_pricepromo.xml (original)
>>>> +++ ofbiz/trunk/applications/product/servicedef/ services_pricepromo.xml Wed May 20 06:25:23 2009
>>>> @@ -273,6 +273,7 @@
>>>>       <description>Create a ProductPromo</description>
>>>>       <auto-attributes include="pk" mode="IN" optional="false"/>
>>>>       <auto-attributes include="nonpk" mode="IN" optional="true"/>
>>>> +        <attribute name="carrierShipmentMethod" type="String"  mode="IN" optional="true"/>
>>>>       <override name="productPromoCondSeqId" mode="OUT"/>
>>>>   </service>
>>>>   <service name="updateProductPromoCond" default-entity- name="ProductPromoCond" engine="simple"
>>>> @@ -280,6 +281,7 @@
>>>>       <description>Update a ProductPromo</description>
>>>>       <auto-attributes include="pk" mode="IN" optional="false"/>
>>>>       <auto-attributes include="nonpk" mode="IN" optional="true"/>
>>>> +        <attribute name="carrierShipmentMethod" type="String"  mode="IN" optional="true"/>
>>>>   </service>
>>>>   <service name="deleteProductPromoCond" default-entity- name="ProductPromoCond" engine="simple"
>>>>               location="component://product/script/org/ofbiz/ product/promo/PromoServices.xml" invoke="deleteProductPromoCond"
>>>> auth="true">
>>>>
>>>> Modified: ofbiz/trunk/applications/product/webapp/catalog/promo/ EditProductPromoRules.ftl
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl?rev=776581&r1=776580&r2=776581&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/applications/product/webapp/catalog/promo/ EditProductPromoRules.ftl (original)
>>>> +++ ofbiz/trunk/applications/product/webapp/catalog/promo/ EditProductPromoRules.ftl Wed May 20 06:25:23 2009
>>>> @@ -98,7 +98,27 @@
>>>>                                           </#list>
>>>>                                       </select>
>>>>                                       <input type="text" size="25"  name="condValue"
>>>> value="${(productPromoCond.condValue)?if_exists}">
>>>> -                                        $ {uiLabelMap.CommonOther}:<input type="text" size="10"  name="otherValue"
>>>> value="${(productPromoCond.otherValue)? if_exists}">
>>>> +                                        <#assign otherValue =  productPromoCond.otherValue?if_exists>
>>>> +                                        <label>$ {uiLabelMap.CommonOther}:</label><input type="text" size="10"
>>>> name="otherValue" <#if otherValue?has_content && ! otherValue.contains("@")> value="${(productPromoCond.otherValue)?
>>>> if_exists}"</#if> >
>>>> +                                        <#if otherValue? has_content && otherValue.contains("@")>
>>>> +                                            <#assign  carrierShippingMethod = productPromoCond.otherValue?if_exists>
>>>> +                                        </#if>
>>>> +                                        <#if  carrierShippingMethod?has_content>
>>>> +                                            <#assign carrierParty  = carrierShippingMethod.substring(0,
>>>> carrierShippingMethod.indexOf("@"))>
>>>> +                                            <#assign  shippingMethodTypeId =
>>>> carrierShippingMethod.substring(carrierShippingMethod.indexOf("@") +1)>
>>>> +                                            <#assign description  = (delegator.findOne("ShipmentMethodType",
>>>> {"shipmentMethodTypeId":shippingMethodTypeId}, false)).description>
>>>> +                                        <#else>
>>>> +                                            <#assign description  = "">
>>>> +                                        </#if>
>>>> +                                        <label>$ {uiLabelMap.OrderSelectShippingMethod}:</label>
>>>> +                                        <select name =  "carrierShipmentMethod">
>>>> +                                            <option value = "$
>>>> {productPromoCond.carrierShippingMethod?if_exists}">${carrierParty? if_exists}&nbsp;${description}</option>
>>>> +                                            <option value =  "">&nbsp;</option>
>>>> +                                            <#list  carrierShipmentMethods as carrierShipmentMethod>
>>>> +                                                <#assign  shipmentMethodType =
>>>> carrierShipmentMethod.getRelatedOneCache("ShipmentMethodType")>
>>>> +                                                <option value = "$ {carrierShipmentMethod.partyId?if_exists}@$
>>>> {carrierShipmentMethod.shipmentMethodTypeId?if_exists}">$ {carrierShipmentMethod.partyId?if_exists}&nbsp;$
>>>> {shipmentMethodType.get("description")?if_exists}</option>
>>>> +                                            </#list>
>>>> +                                        </select>
>>>>                                       <input type="submit" value="$ {uiLabelMap.CommonUpdate}">
>>>>                                   </form>
>>>>                                   <#-- =======================  Categories ======================== -->
>>>> @@ -207,6 +227,14 @@
>>>>                                       </select>
>>>>                                       <input type="text" size="25"  name="condValue">
>>>>                                       $ {uiLabelMap.CommonOther}:<input type="text" size="10"  name="otherValue">
>>>> +                                        <label>$ {uiLabelMap.OrderSelectShippingMethod}:</label>
>>>> +                                        <select name =  "carrierShipmentMethod">
>>>> +                                            <option value = "">--$ {uiLabelMap.OrderSelectShippingMethod}--</option>
>>>> +                                            <#list  carrierShipmentMethods as carrierShipmentMethod>
>>>> +                                                <#assign  shipmentMethodType =
>>>> carrierShipmentMethod.getRelatedOneCache("ShipmentMethodType")>
>>>> +                                                <option value = "$ {carrierShipmentMethod.partyId?if_exists}@$
>>>> {carrierShipmentMethod.shipmentMethodTypeId?if_exists}">$ {carrierShipmentMethod.partyId?if_exists}&nbsp;$
>>>> {shipmentMethodType.get("description")?if_exists}</option>
>>>> +                                            </#list>
>>>> +                                        </select>
>>>>                                       <input type="submit" value="$ {uiLabelMap.CommonCreate}">
>>>>                                   </form>
>>>>                               </td>
>>>>
>>>> Modified: ofbiz/trunk/applications/product/widget/catalog/ PromoScreens.xml
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml?rev=776581&r1=776580&r2=776581&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/applications/product/widget/catalog/ PromoScreens.xml (original)
>>>> +++ ofbiz/trunk/applications/product/widget/catalog/ PromoScreens.xml Wed May 20 06:25:23 2009
>>>> @@ -164,6 +164,7 @@
>>>>               <set field="tabButtonItem"  value="EditProductPromoRules"/>
>>>>               <set field="labelTitleProperty" value="ProductRules"/>
>>>>
>>>> +                <property-map resource="OrderUiLabels" map- name="uiLabelMap"/>
>>>>               <set field="productPromoId" from- field="parameters.productPromoId"/>
>>>>               <entity-one entity-name="ProductPromo" value- field="productPromo" auto-field-map="true"/>
>>>>
>>>> @@ -194,6 +195,9 @@
>>>>                   <condition-expr field-name="enumTypeId"  value="PROD_PROMO_IN_PARAM"/>
>>>>                   <order-by field-name="sequenceId"/>
>>>>               </entity-condition>
>>>> +                <entity-condition entity- name="CarrierShipmentMethod" list="carrierShipmentMethods" use- cache="true">
>>>> +                    <order-by field-name="shipmentMethodTypeId"/>
>>>> +                </entity-condition>
>>>>               <entity-condition entity-name="Enumeration"  list="condOperEnums" use-cache="true">
>>>>                   <condition-expr field-name="enumTypeId"  value="PROD_PROMO_COND"/>
>>>>                   <order-by field-name="sequenceId"/>
>>>>
>>>> Modified: ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ ecommerce/customer/CustomerEvents.xml
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml?rev=776581&r1=776580&r2=776581&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ ecommerce/customer/CustomerEvents.xml (original)
>>>> +++ ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ ecommerce/customer/CustomerEvents.xml Wed May 20 06:25:23 2009
>>>> @@ -1149,6 +1149,10 @@
>>>>           parameters.put("cartGrandTotal", cartGrandTotal);
>>>>
>>>>       ]]></call-bsh>
>>>> +        <call-class-method method-name="doPromotions" class- name="org.ofbiz.order.shoppingcart.product.ProductPromoWorker">
>>>> +            <field field="shoppingCart"  type="org.ofbiz.order.shoppingcart.ShoppingCart"/>
>>>> +            <field field="dispatcher"  type="org.ofbiz.service.LocalDispatcher"/>
>>>> +        </call-class-method>
>>>>       <field-to-request field="parameters.shippingTotal" request- name="shippingTotal"/>
>>>>       <field-to-request field="parameters.cartGrandTotal" request- name="cartGrandTotal"/>
>>>>       <field-to-request field="parameters.totalSalesTax" request- name="totalSalesTax"/>
>>>>
>>>
>>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r776581 - in /ofbiz/trunk: applications/order/src/org/ofbiz/order/shoppingcart/ applications/order/src/org/ofbiz/order/shoppingcart/product/ applications/order/src/org/ofbiz/order/shoppingcart/shipping/ applications/product/data/ applicatio

Vikas Mayur-3
Good to know that it is a useful feature for you, Jacques.

Vikas

On May 20, 2009, at 1:57 PM, Jacques Le Roux wrote:

> Yes, much appreciated.
> For some months I had something for Free Shipping to commit (it's  
> working with one of my customer).
> It was an adaptation of freeShippingProductPromoActions. I have not  
> reviewed this commit in detail but at 1st glance it looks better.
>
> Thanks
>
> Jacques
>
> From: "David E Jones" <[hidden email]>
>>
>> Thanks Vikas and others involved... it is VERY cool to have this  
>> back  in OFBiz!
>>
>> -David
>>
>>
>> On May 20, 2009, at 1:54 AM, Vikas Mayur wrote:
>>
>>> Yes it is. A New promotion rule can be setup on the basis of  
>>> percentage on shipping discount and it could be 100% discount  
>>> (free shipping).
>>>
>>> Vikas
>>>
>>> On May 20, 2009, at 12:29 PM, Jacques Le Roux wrote:
>>>
>>>> Does this allow for free-shipping ?
>>>>
>>>> Jacques
>>>>
>>>> From: <[hidden email]>
>>>>> Author: mor
>>>>> Date: Wed May 20 06:25:23 2009
>>>>> New Revision: 776581
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=776581&view=rev
>>>>> Log:
>>>>> Now Shipping Total adjustments can be applied using promotion.  
>>>>> User can specify percentage discount on a specific shipping  
>>>>> method.
>>>>> Applied patch from Arun Patidar, part of OFBIZ-2488 (https://issues.apache.org/jira/browse/OFBIZ-2488 
>>>>>  )
>>>>>
>>>>> Modified:
>>>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/  
>>>>> CheckOutHelper.java
>>>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/  
>>>>> product/ProductPromoWorker.java
>>>>> ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/  
>>>>> shipping/ShippingEvents.java
>>>>> ofbiz/trunk/applications/product/data/ProductTypeData.xml
>>>>> ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/  
>>>>> PromoServices.xml
>>>>> ofbiz/trunk/applications/product/servicedef/
>>>>> services_pricepromo.xml
>>>>> ofbiz/trunk/applications/product/webapp/catalog/promo/  
>>>>> EditProductPromoRules.ftl
>>>>> ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml
>>>>> ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/  
>>>>> customer/CustomerEvents.xml
>>>>>
>>>>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/  
>>>>> shoppingcart/CheckOutHelper.java
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutHelper.java?rev=776581&r1=776580&r2=776581&view=diff
>>>>> = = = = = = = = = =  
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/  
>>>>> shoppingcart/CheckOutHelper.java (original)
>>>>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/  
>>>>> shoppingcart/CheckOutHelper.java Wed May 20 06:25:23 2009
>>>>> @@ -53,6 +53,7 @@
>>>>> import org.ofbiz.order.finaccount.FinAccountHelper;
>>>>> import org.ofbiz.order.order.OrderChangeHelper;
>>>>> import org.ofbiz.order.order.OrderReadHelper;
>>>>> +import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;
>>>>> import org.ofbiz.order.shoppingcart.shipping.ShippingEvents;
>>>>> import org.ofbiz.party.contact.ContactHelper;
>>>>> import org.ofbiz.product.store.ProductStoreWorker;
>>>>> @@ -407,6 +408,7 @@
>>>>>              shippingTotal = BigDecimal.ZERO;
>>>>>          }
>>>>>          cart.setItemShipGroupEstimate(shippingTotal, 0);
>>>>> +            ProductPromoWorker.doPromotions(cart, dispatcher);
>>>>>
>>>>>          //Recalc tax before setting payment
>>>>>          try {
>>>>>
>>>>> 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=776581&r1=776580&r2=776581&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 Wed May 20  
>>>>> 06:25:23  2009
>>>>> @@ -763,7 +763,12 @@
>>>>>      String otherValue = productPromoCond.getString("otherValue");
>>>>>      String inputParamEnumId =  
>>>>> productPromoCond.getString("inputParamEnumId");
>>>>>      String operatorEnumId =  
>>>>> productPromoCond.getString("operatorEnumId");
>>>>> +        String shippingMethod = "";
>>>>>
>>>>> +        if (otherValue != null && otherValue.contains("@")) {
>>>>> +            shippingMethod =  
>>>>> otherValue.substring(otherValue.indexOf("@")+1);
>>>>> +            otherValue = "";
>>>>> +        }
>>>>>      String partyId = cart.getPartyId();
>>>>>      GenericValue userLogin = cart.getUserLogin();
>>>>>      if (userLogin == null) {
>>>>> @@ -1121,6 +1126,10 @@
>>>>>                  }
>>>>>              }
>>>>>          }
>>>>> +        } else if  
>>>>> ("PPIP_ORDER_SHIPTOTAL".equals(inputParamEnumId) &&  
>>>>> shippingMethod.equals(cart.getShipmentMethodTypeId())) {
>>>>> +            BigDecimal orderTotalShipping =  
>>>>> cart.getTotalShipping();
>>>>> +            if (Debug.verboseOn()) { Debug.logVerbose("Doing  
>>>>> order total Shipping compare: ordertotalShipping=" +  
>>>>> orderTotalShipping, module); }
>>>>> +            compareBase = new  
>>>>> Integer(orderTotalShipping.compareTo(new BigDecimal(condValue)));
>>>>>      } else {
>>>>>           Debug .logWarning (UtilProperties .getMessage  
>>>>> (resource_error
>>>>>  ,"OrderAnUnSupportedProductPromoCondInputParameterLhs",  
>>>>> UtilMisc .toMap ("inputParamEnumId  
>>>>> ",productPromoCond.getString("inputParamEnumId")),  
>>>>> cart.getLocale()), module);
>>>>>          return false;
>>>>> @@ -1494,6 +1503,14 @@
>>>>>                  }
>>>>>              }
>>>>>          }
>>>>> +        } else if  
>>>>> ("PROMO_SHIP_CHARGE".equals(productPromoActionEnumId)) {
>>>>> +            BigDecimal percentage =  
>>>>> (productPromoAction.get("amount") == null ? BigDecimal.ZERO :  
>>>>> (productPromoAction
>>>>>  .getBigDecimal("amount").movePointLeft(2))).negate();
>>>>> +            BigDecimal amount =  
>>>>> cart.getTotalShipping().multiply(percentage);
>>>>> +            if (amount.compareTo(BigDecimal.ZERO) != 0) {
>>>>> +                doOrderPromoAction(productPromoAction, cart,  
>>>>> amount, "amount", delegator);
>>>>> +                actionResultInfo.ranAction = true;
>>>>> +                actionResultInfo.totalDiscountAmount = amount;
>>>>> +            }
>>>>>      } else {
>>>>>          Debug.logError("An un-supported productPromoActionType  
>>>>> was used: " + productPromoActionEnumId + ", not performing any  
>>>>> action", module);
>>>>>          actionResultInfo.ranAction = false;
>>>>>
>>>>> Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/  
>>>>> shoppingcart/shipping/ShippingEvents.java
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java?rev=776581&r1=776580&r2=776581&view=diff
>>>>> = = = = = = = = = =  
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/applications/order/src/org/ofbiz/order/  
>>>>> shoppingcart/shipping/ShippingEvents.java (original)
>>>>> +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/  
>>>>> shoppingcart/shipping/ShippingEvents.java Wed May 20 06:25:23 2009
>>>>> @@ -52,6 +52,7 @@
>>>>> import java.util.HashMap;
>>>>> import java.util.List;
>>>>> import java.util.Map;
>>>>> +import org.ofbiz.order.shoppingcart.product.ProductPromoWorker;
>>>>>
>>>>> /**
>>>>> * ShippingEvents - Events used for processing shipping fees
>>>>> @@ -84,6 +85,7 @@
>>>>>          cart.setItemShipGroupEstimate(shippingTotal, i);
>>>>>      }
>>>>>
>>>>> +        ProductPromoWorker.doPromotions(cart, dispatcher);
>>>>>      // all done
>>>>>      return "success";
>>>>>  }
>>>>>
>>>>> Modified: ofbiz/trunk/applications/product/data/
>>>>> ProductTypeData.xml
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?rev=776581&r1=776580&r2=776581&view=diff
>>>>> = = = = = = = = = =  
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/applications/product/data/ProductTypeData.xml  
>>>>> (original)
>>>>> +++ ofbiz/trunk/applications/product/data/ProductTypeData.xml  
>>>>> Wed  May 20 06:25:23 2009
>>>>> @@ -377,6 +377,7 @@
>>>>>  <Enumeration description="Promotion Recurrence"  
>>>>> enumCode="PROMO_RECURRENCE" enumId="PPIP_RECURRENCE"  
>>>>> sequenceId="11" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>>>>  <Enumeration description="Order sub-total X since beginning of  
>>>>> current year" enumCode="ORST_YEAR" enumId="PPIP_ORST_YEAR"  
>>>>> sequenceId="12" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>>>>  <Enumeration description="Order sub-total X last year"  
>>>>> enumCode="ORST_LAST_YEAR" enumId="PPIP_ORST_LAST_YEAR"  
>>>>> sequenceId="13" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>>>> +    <Enumeration description="Shipping Total"  
>>>>> enumCode="ORDER_SHIP_TOTAL" enumId="PPIP_ORDER_SHIPTOTAL"  
>>>>> sequenceId="14" enumTypeId="PROD_PROMO_IN_PARAM"/>
>>>>>
>>>>>  <EnumerationType description="Product Promotion Condition"  
>>>>> enumTypeId="PROD_PROMO_COND" hasTable="N"  
>>>>> parentTypeId="PROD_PROMO"/>
>>>>>  <!-- old style very technical ...
>>>>> @@ -408,6 +409,7 @@
>>>>>  <Enumeration description="Order Percent Discount"  
>>>>> enumCode="ORDER_PERCENT" enumId="PROMO_ORDER_PERCENT"  
>>>>> sequenceId="06" enumTypeId="PROD_PROMO_ACTION"/>
>>>>>  <Enumeration description="Order Amount Flat"  
>>>>> enumCode="ORDER_AMOUNT" enumId="PROMO_ORDER_AMOUNT"  
>>>>> sequenceId="07" enumTypeId="PROD_PROMO_ACTION"/>
>>>>>  <Enumeration description="Product for [Special Promo] Price"  
>>>>> enumCode="PROD_SPPRC" enumId="PROMO_PROD_SPPRC" sequenceId="08"  
>>>>> enumTypeId="PROD_PROMO_ACTION"/>
>>>>> +    <Enumeration description="Shipping X% discount"  
>>>>> enumCode="SHIP_CHARGE" enumId="PROMO_SHIP_CHARGE"  
>>>>> sequenceId="09" enumTypeId="PROD_PROMO_ACTION"/>
>>>>>
>>>>>  <EnumerationType description="Product Rating Field Type"  
>>>>> enumTypeId="PROD_RATING_TYPE" hasTable="N" parentTypeId=""/>
>>>>>  <Enumeration description="Min Rating" enumCode="MIN"  
>>>>> enumId="PRDR_MIN" sequenceId="01" enumTypeId="PROD_RATING_TYPE"/>
>>>>>
>>>>> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/  
>>>>> product/promo/PromoServices.xml
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/promo/PromoServices.xml?rev=776581&r1=776580&r2=776581&view=diff
>>>>> = = = = = = = = = =  
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/applications/product/script/org/ofbiz/product/  
>>>>> promo/PromoServices.xml (original)
>>>>> +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/  
>>>>> promo/PromoServices.xml Wed May 20 06:25:23 2009
>>>>> @@ -251,6 +251,9 @@
>>>>>
>>>>>      <make-value value-field="newEntity" entity-  
>>>>> name="ProductPromoCond"/>
>>>>>      <set-nonpk-fields map="parameters" value-field="newEntity"/>
>>>>> +        <if-not-empty field="parameters.carrierShipmentMethod">
>>>>> +            <set field="newEntity.otherValue" from-  
>>>>> field="parameters.carrierShipmentMethod"/>
>>>>> +        </if-not-empty>
>>>>>      <set-pk-fields map="parameters" value-field="newEntity"/>
>>>>>      <make-next-seq-id value-field="newEntity" seq-field-  
>>>>> name="productPromoCondSeqId" numeric-padding="2"/>
>>>>>      <field-to-result field="newEntity.productPromoCondSeqId"  
>>>>> result-name="productPromoCondSeqId"/>
>>>>> @@ -266,6 +269,9 @@
>>>>>      <set-pk-fields map="parameters" value-field="lookupPKMap"/>
>>>>>      <find-by-primary-key entity-name="ProductPromoCond"  
>>>>> map="lookupPKMap" value-field="lookedUpValue"/>
>>>>>      <set-nonpk-fields map="parameters" value-  
>>>>> field="lookedUpValue"/>
>>>>> +        <if-not-empty field="parameters.carrierShipmentMethod">
>>>>> +            <set field="lookedUpValue.otherValue" from-  
>>>>> field="parameters.carrierShipmentMethod"/>
>>>>> +        </if-not-empty>
>>>>>      <store-value value-field="lookedUpValue"/>
>>>>>  </simple-method>
>>>>>  <simple-method method-name="deleteProductPromoCond" short-  
>>>>> description="Delete an ProductPromoCond">
>>>>>
>>>>> Modified: ofbiz/trunk/applications/product/servicedef/  
>>>>> services_pricepromo.xml
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/servicedef/services_pricepromo.xml?rev=776581&r1=776580&r2=776581&view=diff
>>>>> = = = = = = = = = =  
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/applications/product/servicedef/  
>>>>> services_pricepromo.xml (original)
>>>>> +++ ofbiz/trunk/applications/product/servicedef/  
>>>>> services_pricepromo.xml Wed May 20 06:25:23 2009
>>>>> @@ -273,6 +273,7 @@
>>>>>      <description>Create a ProductPromo</description>
>>>>>      <auto-attributes include="pk" mode="IN" optional="false"/>
>>>>>      <auto-attributes include="nonpk" mode="IN" optional="true"/>
>>>>> +        <attribute name="carrierShipmentMethod" type="String"  
>>>>> mode="IN" optional="true"/>
>>>>>      <override name="productPromoCondSeqId" mode="OUT"/>
>>>>>  </service>
>>>>>  <service name="updateProductPromoCond" default-entity-  
>>>>> name="ProductPromoCond" engine="simple"
>>>>> @@ -280,6 +281,7 @@
>>>>>      <description>Update a ProductPromo</description>
>>>>>      <auto-attributes include="pk" mode="IN" optional="false"/>
>>>>>      <auto-attributes include="nonpk" mode="IN" optional="true"/>
>>>>> +        <attribute name="carrierShipmentMethod" type="String"  
>>>>> mode="IN" optional="true"/>
>>>>>  </service>
>>>>>  <service name="deleteProductPromoCond" default-entity-  
>>>>> name="ProductPromoCond" engine="simple"
>>>>>              location="component://product/script/org/ofbiz/  
>>>>> product/promo/PromoServices.xml" invoke="deleteProductPromoCond"  
>>>>> auth="true">
>>>>>
>>>>> Modified: ofbiz/trunk/applications/product/webapp/catalog/promo/  
>>>>> EditProductPromoRules.ftl
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/promo/EditProductPromoRules.ftl?rev=776581&r1=776580&r2=776581&view=diff
>>>>> = = = = = = = = = =  
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/applications/product/webapp/catalog/promo/  
>>>>> EditProductPromoRules.ftl (original)
>>>>> +++ ofbiz/trunk/applications/product/webapp/catalog/promo/  
>>>>> EditProductPromoRules.ftl Wed May 20 06:25:23 2009
>>>>> @@ -98,7 +98,27 @@
>>>>>                                          </#list>
>>>>>                                      </select>
>>>>>                                      <input type="text"  
>>>>> size="25"  name="condValue" value="$
>>>>> {(productPromoCond.condValue)?if_exists}">
>>>>> -                                        $  
>>>>> {uiLabelMap.CommonOther}:<input type="text" size="10"  
>>>>> name="otherValue" value="${(productPromoCond.otherValue)?  
>>>>> if_exists}">
>>>>> +                                        <#assign otherValue =  
>>>>> productPromoCond.otherValue?if_exists>
>>>>> +                                        <label>$  
>>>>> {uiLabelMap.CommonOther}:</label><input type="text" size="10"  
>>>>> name="otherValue" <#if otherValue?has_content && !  
>>>>> otherValue.contains("@")> value="$
>>>>> {(productPromoCond.otherValue)? if_exists}"</#if> >
>>>>> +                                        <#if otherValue?  
>>>>> has_content && otherValue.contains("@")>
>>>>> +                                            <#assign  
>>>>> carrierShippingMethod = productPromoCond.otherValue?if_exists>
>>>>> +                                        </#if>
>>>>> +                                        <#if  
>>>>> carrierShippingMethod?has_content>
>>>>> +                                            <#assign  
>>>>> carrierParty  = carrierShippingMethod.substring(0,  
>>>>> carrierShippingMethod.indexOf("@"))>
>>>>> +                                            <#assign  
>>>>> shippingMethodTypeId =  
>>>>> carrierShippingMethod
>>>>> .substring(carrierShippingMethod.indexOf("@") +1)>
>>>>> +                                            <#assign  
>>>>> description  = (delegator.findOne("ShipmentMethodType",  
>>>>> {"shipmentMethodTypeId":shippingMethodTypeId},  
>>>>> false)).description>
>>>>> +                                        <#else>
>>>>> +                                            <#assign  
>>>>> description  = "">
>>>>> +                                        </#if>
>>>>> +                                        <label>$  
>>>>> {uiLabelMap.OrderSelectShippingMethod}:</label>
>>>>> +                                        <select name =  
>>>>> "carrierShipmentMethod">
>>>>> +                                            <option value = "$  
>>>>> {productPromoCond.carrierShippingMethod?if_exists}">$
>>>>> {carrierParty? if_exists}&nbsp;${description}</option>
>>>>> +                                            <option value =  
>>>>> "">&nbsp;</option>
>>>>> +                                            <#list  
>>>>> carrierShipmentMethods as carrierShipmentMethod>
>>>>> +                                                <#assign  
>>>>> shipmentMethodType =  
>>>>> carrierShipmentMethod.getRelatedOneCache("ShipmentMethodType")>
>>>>> +                                                <option value =  
>>>>> "$ {carrierShipmentMethod.partyId?if_exists}@$  
>>>>> {carrierShipmentMethod.shipmentMethodTypeId?if_exists}">$  
>>>>> {carrierShipmentMethod.partyId?if_exists}&nbsp;$  
>>>>> {shipmentMethodType.get("description")?if_exists}</option>
>>>>> +                                            </#list>
>>>>> +                                        </select>
>>>>>                                      <input type="submit"  
>>>>> value="$ {uiLabelMap.CommonUpdate}">
>>>>>                                  </form>
>>>>>                                  <#-- =======================  
>>>>> Categories ======================== -->
>>>>> @@ -207,6 +227,14 @@
>>>>>                                      </select>
>>>>>                                      <input type="text"  
>>>>> size="25"  name="condValue">
>>>>>                                      $  
>>>>> {uiLabelMap.CommonOther}:<input type="text" size="10"  
>>>>> name="otherValue">
>>>>> +                                        <label>$  
>>>>> {uiLabelMap.OrderSelectShippingMethod}:</label>
>>>>> +                                        <select name =  
>>>>> "carrierShipmentMethod">
>>>>> +                                            <option value =  
>>>>> "">--$ {uiLabelMap.OrderSelectShippingMethod}--</option>
>>>>> +                                            <#list  
>>>>> carrierShipmentMethods as carrierShipmentMethod>
>>>>> +                                                <#assign  
>>>>> shipmentMethodType =  
>>>>> carrierShipmentMethod.getRelatedOneCache("ShipmentMethodType")>
>>>>> +                                                <option value =  
>>>>> "$ {carrierShipmentMethod.partyId?if_exists}@$  
>>>>> {carrierShipmentMethod.shipmentMethodTypeId?if_exists}">$  
>>>>> {carrierShipmentMethod.partyId?if_exists}&nbsp;$  
>>>>> {shipmentMethodType.get("description")?if_exists}</option>
>>>>> +                                            </#list>
>>>>> +                                        </select>
>>>>>                                      <input type="submit"  
>>>>> value="$ {uiLabelMap.CommonCreate}">
>>>>>                                  </form>
>>>>>                              </td>
>>>>>
>>>>> Modified: ofbiz/trunk/applications/product/widget/catalog/  
>>>>> PromoScreens.xml
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/widget/catalog/PromoScreens.xml?rev=776581&r1=776580&r2=776581&view=diff
>>>>> = = = = = = = = = =  
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/applications/product/widget/catalog/  
>>>>> PromoScreens.xml (original)
>>>>> +++ ofbiz/trunk/applications/product/widget/catalog/  
>>>>> PromoScreens.xml Wed May 20 06:25:23 2009
>>>>> @@ -164,6 +164,7 @@
>>>>>              <set field="tabButtonItem"  
>>>>> value="EditProductPromoRules"/>
>>>>>              <set field="labelTitleProperty"  
>>>>> value="ProductRules"/>
>>>>>
>>>>> +                <property-map resource="OrderUiLabels" map-  
>>>>> name="uiLabelMap"/>
>>>>>              <set field="productPromoId" from-  
>>>>> field="parameters.productPromoId"/>
>>>>>              <entity-one entity-name="ProductPromo" value-  
>>>>> field="productPromo" auto-field-map="true"/>
>>>>>
>>>>> @@ -194,6 +195,9 @@
>>>>>                  <condition-expr field-name="enumTypeId"  
>>>>> value="PROD_PROMO_IN_PARAM"/>
>>>>>                  <order-by field-name="sequenceId"/>
>>>>>              </entity-condition>
>>>>> +                <entity-condition entity-  
>>>>> name="CarrierShipmentMethod" list="carrierShipmentMethods" use-  
>>>>> cache="true">
>>>>> +                    <order-by field-name="shipmentMethodTypeId"/>
>>>>> +                </entity-condition>
>>>>>              <entity-condition entity-name="Enumeration"  
>>>>> list="condOperEnums" use-cache="true">
>>>>>                  <condition-expr field-name="enumTypeId"  
>>>>> value="PROD_PROMO_COND"/>
>>>>>                  <order-by field-name="sequenceId"/>
>>>>>
>>>>> Modified: ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/  
>>>>> ecommerce/customer/CustomerEvents.xml
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/ecommerce/customer/CustomerEvents.xml?rev=776581&r1=776580&r2=776581&view=diff
>>>>> = = = = = = = = = =  
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/  
>>>>> ecommerce/customer/CustomerEvents.xml (original)
>>>>> +++ ofbiz/trunk/specialpurpose/ecommerce/script/org/ofbiz/  
>>>>> ecommerce/customer/CustomerEvents.xml Wed May 20 06:25:23 2009
>>>>> @@ -1149,6 +1149,10 @@
>>>>>          parameters.put("cartGrandTotal", cartGrandTotal);
>>>>>
>>>>>      ]]></call-bsh>
>>>>> +        <call-class-method method-name="doPromotions" class-  
>>>>> name="org.ofbiz.order.shoppingcart.product.ProductPromoWorker">
>>>>> +            <field field="shoppingCart"  
>>>>> type="org.ofbiz.order.shoppingcart.ShoppingCart"/>
>>>>> +            <field field="dispatcher"  
>>>>> type="org.ofbiz.service.LocalDispatcher"/>
>>>>> +        </call-class-method>
>>>>>      <field-to-request field="parameters.shippingTotal" request-  
>>>>> name="shippingTotal"/>
>>>>>      <field-to-request field="parameters.cartGrandTotal"  
>>>>> request- name="cartGrandTotal"/>
>>>>>      <field-to-request field="parameters.totalSalesTax" request-  
>>>>> name="totalSalesTax"/>
>>>>>
>>>>
>>>>
>>>
>
>


smime.p7s (3K) Download Attachment