You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2007/02/23 16:11:51 UTC
svn commit: r510976 - in /ofbiz/trunk/applications:
ecommerce/webapp/ecommerce/WEB-INF/
ecommerce/webapp/ecommerce/WEB-INF/actions/order/
order/src/org/ofbiz/order/shoppingcart/ product/entitydef/
product/webapp/catalog/store/
Author: jonesde
Date: Fri Feb 23 07:11:50 2007
New Revision: 510976
URL: http://svn.apache.org/viewvc?view=rev&rev=510976
Log:
Added an option configured on the ProductStore to not require a shipping address when purchasing only digital products, ie no physical products; this is supported right now only in the long anonymous checkout process
Modified:
ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/order/paymentinformation.bsh
ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
ofbiz/trunk/applications/product/entitydef/entitymodel.xml
ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml
Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/order/paymentinformation.bsh
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/order/paymentinformation.bsh?view=diff&rev=510976&r1=510975&r2=510976
==============================================================================
--- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/order/paymentinformation.bsh (original)
+++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/order/paymentinformation.bsh Fri Feb 23 07:11:50 2007
@@ -95,12 +95,12 @@
if(parameters.get("useShipAddr") == null){
if (cart != null && postalAddress !=null){
- postalAddress = context.get("postalAddress");
- shippingContactMechId = cart.getShippingContactMechId();
- contactMechId = postalAddress.get("contactMechId");
- if(shippingContactMechId.equals(contactMechId)){
- context.put("useShipAddr","Y");
- }
+ postalAddress = context.get("postalAddress");
+ shippingContactMechId = cart.getShippingContactMechId();
+ contactMechId = postalAddress.get("contactMechId");
+ if(shippingContactMechId != null && shippingContactMechId.equals(contactMechId)){
+ context.put("useShipAddr","Y");
+ }
}
}else{
context.put("useShipAddr",parameters.get("useShipAddr"));
Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml?view=diff&rev=510976&r1=510975&r2=510976
==============================================================================
--- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/controller.xml Fri Feb 23 07:11:50 2007
@@ -312,7 +312,16 @@
<request-map uri="processCustomerSettings">
<security https="true" auth="false"/>
<event type="simple" path="org/ofbiz/ecommerce/customer/CustomerEvents.xml" invoke="processCustomerSettings"/>
- <response name="success" type="request" value="setShipping"/>
+ <response name="success" type="request" value="anonCheckShipmentNeeded"/>
+ <response name="error" type="view" value="custsetting"/>
+ </request-map>
+
+ <request-map uri="anonCheckShipmentNeeded">
+ <security direct-request="false"/>
+ <event type="java" path="org.ofbiz.order.shoppingcart.CheckOutEvents" invoke="checkShipmentNeeded"/>
+ <response name="shipmentNeeded" type="request" value="setShipping"/>
+ <!-- NOTE: it seems like setTaxBeforePayment would be the best here, but without an address it doesn't work -->
+ <response name="shipmentNotNeeded" type="request" value="setPaymentOption"/>
<response name="error" type="view" value="custsetting"/>
</request-map>
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java?view=diff&rev=510976&r1=510975&r2=510976
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/CheckOutEvents.java Fri Feb 23 07:11:50 2007
@@ -425,7 +425,7 @@
private static void calcTax(HttpServletRequest request) throws GeneralException {
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
- ShoppingCart cart = (ShoppingCart) request.getSession().getAttribute("shoppingCart");
+ ShoppingCart cart = ShoppingCartEvents.getCartObject(request);
CheckOutHelper checkOutHelper = new CheckOutHelper(dispatcher, delegator, cart);
//Calculate and add the tax adjustments
@@ -440,6 +440,28 @@
}
return productStore.getBoolean("explodeOrderItems").booleanValue();
}
+
+ public static String checkShipmentNeeded(HttpServletRequest request, HttpServletResponse response) {
+ GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
+ ShoppingCart cart = ShoppingCartEvents.getCartObject(request);
+ GenericValue productStore = null;
+ try {
+ productStore = delegator.findByPrimaryKeyCache("ProductStore", UtilMisc.toMap("productStoreId", cart.getProductStoreId()));
+ } catch (GenericEntityException e) {
+ Debug.logError(e, "Error getting ProductStore: " + e.toString(), module);
+ }
+
+ Debug.logInfo("checkShipmentNeeded: reqShipAddrForDigItems=" + productStore.getString("reqShipAddrForDigItems"), module);
+ if (productStore != null && "N".equals(productStore.getString("reqShipAddrForDigItems"))) {
+ Debug.logInfo("checkShipmentNeeded: cart.containOnlyDigitalGoods()=" + cart.containOnlyDigitalGoods(), module);
+ // don't require shipping for all digital items
+ if (cart.containOnlyDigitalGoods()) {
+ return "shipmentNotNeeded";
+ }
+ }
+
+ return "shipmentNeeded";
+ }
// Event wrapper for processPayment.
public static String processPayment(HttpServletRequest request, HttpServletResponse response) {
@@ -971,6 +993,5 @@
} else {
return null;
}
-
}
}
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?view=diff&rev=510976&r1=510975&r2=510976
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Fri Feb 23 07:11:50 2007
@@ -698,12 +698,10 @@
// ============== WorkEffort related methods ===============
public boolean containAnyWorkEffortCartItems() {
// Check for existing cart item.
- for (int i = 0; i < this.cartLines.size();) {
+ for (int i = 0; i < this.cartLines.size(); i++) {
ShoppingCartItem cartItem = (ShoppingCartItem) cartLines.get(i);
if (cartItem.getItemType().equals("RENTAL_ORDER_ITEM")) { // create workeffort items?
return true;
- } else {
- i++;
}
}
return false;
@@ -711,12 +709,32 @@
public boolean containAllWorkEffortCartItems() {
// Check for existing cart item.
- for (int i = 0; i < this.cartLines.size();) {
+ for (int i = 0; i < this.cartLines.size(); i++) {
ShoppingCartItem cartItem = (ShoppingCartItem) cartLines.get(i);
if (!cartItem.getItemType().equals("RENTAL_ORDER_ITEM")) { // not a item to create workefforts?
return false;
- } else {
- i++;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Check to see if the cart contains only Digital Goods, ie no Finished Goods and no Finished/Digital Goods, et cetera.
+ * This is determined by making sure no Product has a type where ProductType.isPhysical!=N.
+ */
+ public boolean containOnlyDigitalGoods() {
+ for (int i = 0; i < this.cartLines.size(); i++) {
+ ShoppingCartItem cartItem = (ShoppingCartItem) cartLines.get(i);
+ GenericValue product = cartItem.getProduct();
+ try {
+ GenericValue productType = product.getRelatedOneCache("ProductType");
+ if (productType == null || !"N".equals(productType.getString("isPhysical"))) {
+ return false;
+ }
+ } catch (GenericEntityException e) {
+ Debug.logError(e, "Error looking up ProductType: " + e.toString(), module);
+ // consider this not a digital good if we don't have "proof"
+ return false;
}
}
return true;
Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?view=diff&rev=510976&r1=510975&r2=510976
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Fri Feb 23 07:11:50 2007
@@ -3131,7 +3131,8 @@
<field name="headerRightBackground" type="url"></field>
<field name="usePrimaryEmailUsername" type="indicator"></field>
<field name="requireCustomerRole" type="indicator"></field>
- <field name="autoInvoiceDigitalItems" type="indicator"></field>
+ <field name="autoInvoiceDigitalItems" type="indicator"><description>Default Y. Invoice digital items when order is placed rather than waiting for completing order items (though shipment/fulfillment).</description></field>
+ <field name="reqShipAddrForDigItems" type="indicator"><description>Default Y. Require Shipping Address for Digital Items? Note this only has an effect if there are ONLY digital goods in the cart.</description></field>
<field name="showCheckoutGiftOptions" type="indicator"></field>
<field name="selectPaymentTypePerItem" type="indicator"></field>
<field name="showPricesWithVatTax" type="indicator"></field>
Modified: ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml?view=diff&rev=510976&r1=510975&r2=510976
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml Fri Feb 23 07:11:50 2007
@@ -68,6 +68,10 @@
<field name="autoInvoiceDigitalItems" widget-style="selectBox">
<drop-down allow-empty="false" no-current-selected-key="Y"><option key="Y" description="${uiLabelMap.CommonY}"/><option key="N" description="${uiLabelMap.CommonN}"/></drop-down>
</field>
+ <field name="reqShipAddrForDigItems" widget-style="selectBox">
+ <drop-down allow-empty="false" no-current-selected-key="Y"><option key="Y" description="${uiLabelMap.CommonY}"/><option key="N" description="${uiLabelMap.CommonN}"/></drop-down>
+ </field>
+
<field name="isDemoStore" widget-style="selectBox">
<drop-down allow-empty="false" no-current-selected-key="Y"><option key="Y" description="${uiLabelMap.CommonY}"/><option key="N" description="${uiLabelMap.CommonN}"/></drop-down>
</field>