Applied patch from Ashish Vijaywargiya also in Jira #OFBIZ-498; this is mostly cleanups of the checkout stuff, and adds the form submit feature too; reading over it everything looks fine and it was okay in a brief test, but it would be good for more people to test it now

git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@480761 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David E. Jones
2006-11-29 23:05:25 +00:00
parent fef539252d
commit 5246ea7fa8
16 changed files with 45 additions and 147 deletions
@@ -430,73 +430,6 @@ under the License.
<!-- =========================================== -->
<!-- ======== Anonymous Checkout Events ======== -->
<!-- =========================================== -->
<simple-method method-name="processCustomerSettingsOld" short-description="Process Customer Settings; to be called as a Request Event" login-required="false">
<if-empty field-name="parameters.partyId">
<call-simple-method method-name="createCustomer"/>
<else>
<call-simple-method method-name="updateCustomer"/>
</else>
</if-empty>
<!-- see if we should continue now... -->
<check-errors/>
<log level="info" message="Setting up party ${tempMap.partyId} and shipping address ${addressPurposeContext.contactMechId} in cart"/>
<!-- this is code from CheckOutEvents->finalizeOrderEntry -->
<call-bsh><![CDATA[
import org.ofbiz.order.shoppingcart.ShoppingCart;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.Debug;
ShoppingCart cart = (ShoppingCart) session.getAttribute("shoppingCart");
GenericValue userLogin = (GenericValue) session.getAttribute("userLogin");
// if null then we must be an anonymous shopper
if (userLogin == null) {
// remove auto-login fields
session.removeAttribute("autoUserLogin");
session.removeAttribute("autoName");
// clear out the login fields from the cart
try {
if (cart!=null) cart.setAutoUserLogin(null, dispatcher);
} catch (CartItemModifyException e) {
Debug.logError(e, module);
}
}
// set party id in cart
String partyId = (String) request.getAttribute("partyId");
if (partyId != null) {
// no userLogin means we are an anonymous shopper; fake the UL for service calls
if (userLogin == null) {
try {
userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "anonymous"));
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
if (userLogin != null) {
userLogin.set("partyId", partyId);
}
session.setAttribute("userLogin", userLogin);
try {
if (cart != null) {
cart.setOrderPartyId(partyId);
cart.setUserLogin(userLogin, dispatcher);
}
} catch (CartItemModifyException e) {
Debug.logError(e, module);
}
}
}
]]></call-bsh>
<check-errors/>
<log level="info" message="If anonymous, user-login has been activated"/>
</simple-method>
<simple-method method-name="processCustomerSettings" short-description="Process Customer Settings; to be called as a Request Event" login-required="false">
<if-empty field-name="parameters.partyId">
@@ -512,7 +445,6 @@ under the License.
<session-to-field field-name="userLogin" session-name="userLogin"/>
<log level="info" message="userLogin in Env ${userLogin} in parameters.userLogin ${parameters.userLogin}"/>
<if-empty field-name="userLogin">
<log level="info" message="removeAttributeremoveAttributeremoveAttribute"/>
<call-object-method obj-field-name="session" method-name="removeAttribute">
<string value="autoUserLogin"/>
</call-object-method>
@@ -850,56 +782,6 @@ under the License.
</if-not-empty>
</simple-method>
<simple-method method-name="processShipOptionsOld" short-description="Process Ship Options; to be called as a Request Event" login-required="false">
<call-bsh><![CDATA[
import org.ofbiz.order.shoppingcart.ShoppingCart;
import org.ofbiz.service.LocalDispatcher;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.order.shoppingcart.CheckOutHelper;
import org.ofbiz.service.ServiceUtil;
ShoppingCart cart = (ShoppingCart) session.getAttribute("shoppingCart");
LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
CheckOutHelper checkOutHelper = new CheckOutHelper(dispatcher, delegator, cart);
// set contact mech for shipping address in cart
if (cart != null) {
Map callResult = ServiceUtil.returnSuccess();
List errorMessages = new ArrayList();
Map errorMaps = new HashMap();
for (int shipGroupIndex = 0; shipGroupIndex < cart.getShipGroupSize(); shipGroupIndex++) {
shippingMethod = request.getParameter(shipGroupIndex + "_shipping_method");
if (UtilValidate.isEmpty(shippingMethod)){
shippingMethod = request.getParameter("shipping_method");
}
shippingInstructions = request.getParameter(shipGroupIndex + "_shipping_instructions");
if (UtilValidate.isEmpty(shippingInstructions)){
shippingInstructions = request.getParameter("shipping_instructions");
}
maySplit = request.getParameter(shipGroupIndex + "_may_split");
if (UtilValidate.isEmpty(maySplit)){
maySplit = request.getParameter("may_split");
}
giftMessage = request.getParameter(shipGroupIndex + "_gift_message");
isGift = request.getParameter(shipGroupIndex + "_is_gift");
internalCode = request.getParameter("internalCode"); // FIXME
shipBeforeDate = request.getParameter(shipGroupIndex + "_shipBeforeDate");
shipAfterDate = request.getParameter(shipGroupIndex + "_shipAfterDate");
callResult = checkOutHelper.finalizeOrderEntryOptions(shipGroupIndex, shippingMethod, shippingInstructions, maySplit, giftMessage, isGift, internalCode, shipBeforeDate, shipAfterDate);
ServiceUtil.addErrors(errorMessages, errorMaps, callResult);
}
}
]]></call-bsh>
</simple-method>
<simple-method method-name="processShipOptions" short-description="Process Ship Options; to be called as a Request Event" login-required="false">
<call-bsh><![CDATA[
shipmentMethod = parameters.get("shipping_method");
@@ -18,10 +18,10 @@ import org.ofbiz.order.shoppingcart.ShoppingCartEvents;
shoppingCart = ShoppingCartEvents.getCartObject(request);
orderPartyId = shoppingCart.getOrderPartyId();
if (orderPartyId !=null && !orderPartyId.equals("")) {
userLogin = context.get("userLogin");
if (userLogin != null) {
context.put("enableShippingAddress",true);
}
}
shippingContactMechId = shoppingCart.getShippingContactMechId();
if (shippingContactMechId !=null && !shippingContactMechId.equals("")) {
@@ -35,6 +35,7 @@ if (partyId != null) {
if (request.getAttribute("_ERROR_MESSAGE_") == null && request.getAttribute("_ERROR_MESSAGE_LIST_") == null) {
person = delegator.findByPrimaryKey("Person", UtilMisc.toMap("partyId", partyId));
if (person != null) {
context.put("callSubmitForm",true);
// should never be null for the anonymous checkout, but just in case
parameters.put("personalTitle", person.get("personalTitle"));
parameters.put("firstName", person.get("firstName"));
@@ -53,6 +53,7 @@ context.put("emailList", ContactHelper.getContactMechByType(party, "EMAIL_ADDRE
if (shoppingCart != null && shoppingCart.getShipmentMethodTypeId() != null && shoppingCart.getCarrierPartyId() != null) {
context.put("chosenShippingMethod", shoppingCart.getShipmentMethodTypeId() + '@' + shoppingCart.getCarrierPartyId());
context.put("callSubmitForm",true);
}
context.put("productStoreId", productStore.get("productStoreId"));
@@ -114,4 +114,7 @@ if(context.get("postalAddress") != null){
parameters.put("postalCode",postalAddress.get("postalCode"));
parameters.put("countryGeoId",postalAddress.get("countryGeoId"));
parameters.put("contactMechId",postalAddress.get("contactMechId"));
if(context.get("creditCard") != null){
context.put("callSubmitForm",true);
}
}
@@ -23,6 +23,7 @@ paymentMethodTypeIds = cart.getPaymentMethodTypeIds();
paymentMethodTypeIdIter = paymentMethodTypeIds.iterator();
while (paymentMethodTypeIdIter.hasNext()) {
String paymentMethodTypeId = (String) paymentMethodTypeIdIter.next();
context.put("callSubmitForm",true);
if ("GIFT_CARD".equals(paymentMethodTypeId)) {
context.put("addGiftCard","Y");
} else {
@@ -40,7 +40,8 @@ if (cart != null && cart.getShippingContactMechId() != null) {
shippingPartyContactDetail = EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd("PartyContactDetailByPurpose",
UtilMisc.toMap("partyId", partyId, "contactMechId", shippingContactMechId)), true));
parameters.put("shippingContactMechId", shippingPartyContactDetail.get("contactMechId"));
context.put("callSubmitForm",true);
fullAddressBuf = new StringBuffer();
fullAddressBuf.append(shippingPartyContactDetail.get("address1"));
if (shippingPartyContactDetail.get("address2") != null) {
@@ -61,7 +62,7 @@ if (cart != null && cart.getShippingContactMechId() != null) {
parameters.put("city", shippingPartyContactDetail.get("city"));
parameters.put("postalCode", shippingPartyContactDetail.get("postalCode"));
parameters.put("stateProvinceGeoId", shippingPartyContactDetail.get("stateProvinceGeoId"));
parameters.put("countyGeoId", shippingPartyContactDetail.get("countyGeoId"));
parameters.put("countryGeoId", shippingPartyContactDetail.get("countryGeoId"));
parameters.put("allowSolicitation", shippingPartyContactDetail.get("allowSolicitation"));
}
@@ -14,31 +14,35 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
<script language="javascript" type="text/javascript">
function submitForm(form) {
form.submit();
}
</script>
<div>
<a href="<@ofbizUrl>setCustomer</@ofbizUrl>" class="buttontext">Personal Info</a>
<a href="<@ofbizUrl>setCustomer</@ofbizUrl>" class="buttontext" <#if callSubmitForm?exists>onclick="javascript:submitForm(document.${parameters.formNameValue?if_exists});"</#if>>Personal Info</a>
<#if (enableShippingAddress)?exists>
<a href="<@ofbizUrl>setShipping</@ofbizUrl>" class="buttontext">Shipping Address</a>
<a href="<@ofbizUrl>setShipping</@ofbizUrl>" class="buttontext" <#if callSubmitForm?exists>onclick="javascript:submitForm(document.${parameters.formNameValue?if_exists});"</#if>>Shipping Address</a>
<#else>
<span class="buttontextdisabled">Shipping Address</span>
</#if>
<#if (enableShipmentMethod)?exists>
<a href="<@ofbizUrl>setShipOptions</@ofbizUrl>" class="buttontext">Shipping Options</a>
<a href="<@ofbizUrl>setShipOptions</@ofbizUrl>" class="buttontext" <#if callSubmitForm?exists>onclick="javascript:submitForm(document.${parameters.formNameValue?if_exists});"</#if>>Shipping Options</a>
<#else>
<span class="buttontextdisabled">Shipping Options</span>
</#if>
<#if (enablePaymentOptions)?exists>
<a href="<@ofbizUrl>setPaymentOption</@ofbizUrl>" class="buttontext">Payment Options</a>
<a href="<@ofbizUrl>setPaymentOption</@ofbizUrl>" class="buttontext" <#if callSubmitForm?exists>onclick="javascript:submitForm(document.${parameters.formNameValue?if_exists});"</#if>>Payment Options</a>
<#else>
<span class="buttontextdisabled">Payment Options</span>
</#if>
<#if (enablePaymentInformation)?exists>
<a href="<@ofbizUrl>setPaymentInformation?paymentMethodTypeId=${requestParameters.paymentMethodTypeId?if_exists}</@ofbizUrl>" class="buttontext">Payment Information</a>
<a href="<@ofbizUrl>setPaymentInformation?paymentMethodTypeId=${requestParameters.paymentMethodTypeId?if_exists}</@ofbizUrl>" class="buttontext" <#if callSubmitForm?exists>onclick="javascript:submitForm(document.${parameters.formNameValue?if_exists});"</#if>>Payment Information</a>
<#else>
<span class="buttontextdisabled">Payment Information</span>
</#if>
<#if (enableReviewOrder)?exists>
<a href="<@ofbizUrl>reviewOrder</@ofbizUrl>" class="buttontext">Review Order</a>
<a href="<@ofbizUrl>reviewOrder</@ofbizUrl>" class="buttontext" <#if callSubmitForm?exists>onclick="javascript:submitForm(document.${parameters.formNameValue?if_exists});"</#if>>Review Order</a>
<#else>
<span class="buttontextdisabled">Review Order</span>
</#if>
@@ -22,9 +22,9 @@ under the License.
if (clicked == 0) {
clicked++;
//window.location.replace("<@ofbizUrl>processorder</@ofbizUrl>");
document.processForm.processButton.value="${uiLabelMap.OrderSubmittingOrder}";
document.processForm.processButton.disabled=true;
document.processForm.submit();
document.${parameters.formNameValue}.processButton.value="${uiLabelMap.OrderSubmittingOrder}";
document.${parameters.formNameValue}.processButton.disabled=true;
document.${parameters.formNameValue}.submit();
} else {
alert("You order is being processed, this may take a moment.");
}
@@ -45,7 +45,7 @@ under the License.
&nbsp;
</td>
<td align="right">
<form type="POST" action="<@ofbizUrl>processorder</@ofbizUrl>" name="processForm">
<form type="POST" action="<@ofbizUrl>processorder</@ofbizUrl>" name="${parameters.formNameValue}">
<#if (requestParameters.checkoutpage)?has_content>
<input type="hidden" name="checkoutpage" value="${requestParameters.checkoutpage}">
</#if>
@@ -19,7 +19,7 @@ under the License.
<div class="boxhead">&nbsp;${uiLabelMap.PartyBasicInformation}</div>
</div>
<div class="screenlet-body">
<form name="custsetupform" method="post" action="<@ofbizUrl>processCustomerSettings</@ofbizUrl>">
<form name="${parameters.formNameValue}" method="post" action="<@ofbizUrl>processCustomerSettings</@ofbizUrl>">
<input type="hidden" name="partyId" value="${parameters.partyId?if_exists}"/>
<table width="100%" border="0" cellpadding="1" cellspacing="0">
<tr>
@@ -66,8 +66,7 @@ under the License.
<td width="74%">
<select name="stateProvinceGeoId" class="selectBox" <#if requestParameters.useShipAddr?exists>disabled</#if>>
<#if (parameters.stateProvinceGeoId)?exists>
<#assign findGeoMap = Static["org.ofbiz.base.util.UtilMisc"].toMap("geoId", parameters.stateProvinceGeoId)>
<#assign stateGeo = delegator.findByPrimaryKeyCache("Geo", findGeoMap)> <option>${parameters.stateProvinceGeoId}</option>
<option>${parameters.stateProvinceGeoId}</option>
<option value="${parameters.stateProvinceGeoId}">---</option>
<#else>
<option value="">${uiLabelMap.PartyNoState}</option>
@@ -20,7 +20,7 @@ under the License.
<div class='boxhead'>&nbsp;${uiLabelMap.OrderShippingInformation}</div>
</div>
<div class="screenlet-body">
<form method="post" action="<@ofbizUrl>processShipOptions</@ofbizUrl>" name="optsetupform">
<form method="post" action="<@ofbizUrl>processShipOptions</@ofbizUrl>" name="${parameters.formNameValue}">
<input type="hidden" name="finalizeMode" value="options"/>
<table width="100%" cellpadding="1" border="0" cellpadding="0" cellspacing="0">
<#list carrierShipmentMethodList as carrierShipmentMethod>
@@ -39,28 +39,28 @@ function shipBillAddr() {
<#-- after initial screen; show detailed screens for selected type -->
<#if paymentMethodTypeId?if_exists == "CREDIT_CARD">
<#if creditCard?has_content && postalAddress?has_content && !requestParameters.useShipAddr?exists>
<form method="post" action="<@ofbizUrl>changeCreditCardAndBillingAddress</@ofbizUrl>" name="billsetupform">
<form method="post" action="<@ofbizUrl>changeCreditCardAndBillingAddress</@ofbizUrl>" name="${parameters.formNameValue}">
<input type="hidden" name="paymentMethodId" value="${creditCard.paymentMethodId?if_exists}"/>
<input type="hidden" name="contactMechId" value="${postalAddress.contactMechId?if_exists}"/>
<#elseif requestParameters.useShipAddr?exists>
<form method="post" action="<@ofbizUrl>enterCreditCard</@ofbizUrl>" name="billsetupform">
<form method="post" action="<@ofbizUrl>enterCreditCard</@ofbizUrl>" name="${parameters.formNameValue}">
<#else>
<form method="post" action="<@ofbizUrl>enterCreditCardAndBillingAddress</@ofbizUrl>" name="billsetupform">
<form method="post" action="<@ofbizUrl>enterCreditCardAndBillingAddress</@ofbizUrl>" name="${parameters.formNameValue}">
</#if>
</#if>
<#if paymentMethodTypeId?if_exists == "EFT_ACCOUNT">
<#if eftAccount?has_content && postalAddress?has_content>
<form method="post" action="<@ofbizUrl>changeEftAccountAndBillingAddress</@ofbizUrl>" name="billsetupform">
<form method="post" action="<@ofbizUrl>changeEftAccountAndBillingAddress</@ofbizUrl>" name="${parameters.formNameValue}">
<input type="hidden" name="paymentMethodId" value="${eftAccount.paymentMethodId?if_exists}"/>
<input type="hidden" name="contactMechId" value="${postalAddress.contactMechId?if_exists}"/>
<#elseif requestParameters.useShipAddr?exists>
<form method="post" action="<@ofbizUrl>enterEftAccount</@ofbizUrl>" name="billsetupform">
<form method="post" action="<@ofbizUrl>enterEftAccount</@ofbizUrl>" name="${parameters.formNameValue}">
<#else>
<form method="post" action="<@ofbizUrl>enterEftAccountAndBillingAddress</@ofbizUrl>" name="billsetupform">
<form method="post" action="<@ofbizUrl>enterEftAccountAndBillingAddress</@ofbizUrl>" name="${parameters.formNameValue}">
</#if>
</#if>
<#if paymentMethodTypeId?if_exists == "GIFT_CARD"> <#--Don't know much how this is handled -->
<form method="post" action="<@ofbizUrl>enterGiftCard</@ofbizUrl>" name="billsetupform">
<form method="post" action="<@ofbizUrl>enterGiftCard</@ofbizUrl>" name="${parameters.formNameValue}">
</#if>
<#if requestParameters.singleUsePayment?default("N") == "Y">
@@ -22,7 +22,7 @@ under the License.
<div class="screenlet-body">
<#-- initial screen show a list of options -->
<form method="post" action="<@ofbizUrl>setPaymentInformation</@ofbizUrl>" name="billsetupform">
<form method="post" action="<@ofbizUrl>setPaymentInformation</@ofbizUrl>" name="${parameters.formNameValue}">
<table width="100%" border="0" cellpadding="1" cellspacing="0">
<#if productStorePaymentMethodTypeIdMap.GIFT_CARD?exists>
<tr>
@@ -19,7 +19,7 @@ under the License.
<div class='boxhead'>&nbsp;${uiLabelMap.OrderShippingInformation}</div>
</div>
<div class="screenlet-body">
<form method="post" action="<@ofbizUrl>processShipSettings</@ofbizUrl>" name="shipsetupform">
<form method="post" action="<@ofbizUrl>processShipSettings</@ofbizUrl>" name="${parameters.formNameValue}">
<input type="hidden" name="contactMechId" value="${parameters.shippingContactMechId?if_exists}"/>
<input type="hidden" name="partyId" value="${cart.getPartyId()?default("_NA_")}"/>
@@ -91,6 +91,7 @@ under the License.
<actions>
<set field="rightbarScreenName" value="rightbar"/>
<set field="MainColumnStyle" value="rightonly"/>
<set field="parameters.formNameValue" value="custsetupform" global="true"/>
<set field="titleProperty" value="PageTitleShippingInformation"/>
<script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/custsettings.bsh"/>
@@ -110,6 +111,7 @@ under the License.
<actions>
<set field="rightbarScreenName" value="rightbar"/>
<set field="MainColumnStyle" value="rightonly"/>
<set field="parameters.formNameValue" value="shipsetupform" global="true"/>
<set field="titleProperty" value="PageTitleShippingInformation"/>
<script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/shipsettings.bsh"/>
@@ -129,6 +131,7 @@ under the License.
<actions>
<set field="rightbarScreenName" value="rightbar"/>
<set field="MainColumnStyle" value="rightonly"/>
<set field="parameters.formNameValue" value="optsetupform" global="true"/>
<set field="titleProperty" value="PageTitleShippingOptions"/>
<script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/optionsettings.bsh"/>
@@ -148,6 +151,7 @@ under the License.
<actions>
<set field="rightbarScreenName" value="rightbar"/>
<set field="MainColumnStyle" value="rightonly"/>
<set field="parameters.formNameValue" value="paymentoptions" global="true"/>
<set field="titleProperty" value="PageTitleBillingInformation"/>
<script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/paymentoptions.bsh"/>
@@ -168,6 +172,7 @@ under the License.
<actions>
<set field="rightbarScreenName" value="rightbar"/>
<set field="MainColumnStyle" value="rightonly"/>
<set field="parameters.formNameValue" value="billsetupform"/>
<set field="titleProperty" value="PageTitleBillingInformation"/>
<script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/paymentinformation.bsh"/>
@@ -187,6 +192,7 @@ under the License.
<section>
<actions>
<set field="titleProperty" value="PageTitleCheckoutReview"/>
<set field="parameters.formNameValue" value="orderreview" global="true"/>
<script location="component://ecommerce/webapp/ecommerce/WEB-INF/actions/order/checkoutreview.bsh"/>
</actions>
<widgets>