Saturday, January 7, 2012

ATG Commerce Basic Checkout Process


The basic checkout process allows a customer to send an order to a single location using a single credit card as a form of payment.

When an order is created, it has by default one shipping group and one payment group: atg.commerce.order.HardgoodShippingGroup and atg.commerce.order.CreditCard. If these are the only two groups that exist when a user checks out, then relationship objects are created between the commerce items in the order and these groups. shipItemRel links all the commerce items to the single shipping group; payItemRel links all the commerce items to the single payment group. The basic checkout process populates these two groups.

Basic Shipping Information Input

Shipping information entered by the customer includes the address and method. The customer can input information to the shipping group by entering the shipping address or copying the billing address to the shipping address. The customer also can select from a choice of shipping methods.

This JSP enters shipping information into the order object:

<!-- Store the ProfileID in ownerId field of the new address.
     This tells us this address "belongs to" (and can be
     edited) by the user. -->
<dsp:input
     bean="ShoppingCartModifier.shippingGroup.shippingAddress.ownerId"
     beanvalue="Profile.id" type="hidden"/>


<dsp:getvalueof id="firstName"
     bean="ShoppingCartModifier.shippingGroup.shippingAddress.firstName">


<% if((firstName== null) || (firstName.equals(""))) { %>
  <dsp:input
       bean="ShoppingCartModifier.shippingGroup.shippingAddress.firstName"
       beanvalue="Profile.shippingAddress.firstName" size="15"
       type="text"/>
<%} else {%>
  <dsp:input
       bean="ShoppingCartModifier.shippingGroup.shippingAddress.firstName"
       size="15" type="text"/>
<%}%>


</dsp:getvalueof>


<dsp:getvalueof id="middleName"
             bean="ShoppingCartModifier.shippingGroup.shippingAddress.middleName">


<% if((middleName== null) || (middleName.equals(""))) { %>
  <dsp:input
      bean="ShoppingCartModifier.shippingGroup.shippingAddress.middleName"
      beanvalue="Profile.shippingAddress.middleName" size="10"
      type="text"/>
<%} else {%>
  <dsp:input
      bean="ShoppingCartModifier.shippingGroup.shippingAddress.middleName"
      size="10" type="text"/>
<%}%>


</dsp:getvalueof>


There are several things to notice about this JSP. First, note that each piece of information is inserted somewhere in the default shipping group. The line <dsp:input type="text" bean="ShoppingCartModifier.shippingGroup.shippingAddress"> refers to the default shipping group address and then to each element of the shippingAddress. For example, shippingAddress.state refers to the state to which the order is sent.

If the default shippingAddress is not empty, it displays the information in it. If it is empty, it tries to populate those fields with information from the user’s Profile object. If a customer is registered and is going through the checkout process for the first time, her shipping address information is prepopulated with her information from her Profile. She can then choose to use this information or to change it. The customer can also go back to the store to add other items to her cart.

This JSP sets the ownerId of the address to the id of the current user’s Profile. This indicates that the user is the owner of this address and has the ability to edit that address if necessary.

Copy billing address to shipping address

In the basic checkout, an unregistered customer must enter a billing address first. She can then elect to copy the billing address information to her shipping address or enter a new one. The ability to copy the billing address is handled by the following JSP:

<!-- Indicate if the billing address should be copied to the shipping address -->
 <dsp:input bean="ShoppingCartModifier.CopyBillingAddrToShippingAddr"
      name="copyAddress" type="radio" checked="<%=true%>" value="true"/> Ship
      items to my billing address<br>
 <dsp:input bean="ShoppingCartModifier.CopyBillAddrToShippingAddr"
      name="copyAddress" type="radio" value="false"/> Ship items to the new
      address below <p>

If the customer decides to use her billing address as the shipping address, the Boolean property ShoppingCartModifier.copyBillingAddrToShippingAddr remains true, and the billing address that she entered is automatically copied to the shipping address. Otherwise, the Boolean property is set to false and nothing is copied.

Choosing a shipping Method

Finally, the customer must select a shipping method such as ground or next day. The following JSP code handles shipping method selection. Note: The “. . .” marker in the following code sample indicate a place where code has been removed to clarify the sample.

<dsp:importbean bean="/atg/commerce/pricing/UserPricingModels"/>
<dsp:importbean bean="/atg/commerce/pricing/AvailableShippingMethods"/>
<dsp:importbean bean="/atg/userprofiling/Profile"/>
<dsp:importbean bean="/atg/commerce/order/ShoppingCartModifier"/>
<dsp:importbean bean="/atg/dynamo/droplet/ForEach"/>
<dsp:importbean bean="/atg/dynamo/droplet/Switch"/>


. . .


<!-- The droplet AvailableShippingMethods is able to give us a list of
      the shipping methods that should be available to a user. -->


 Shipping Method<br>
<dsp:droplet name="AvailableShippingMethods">
<dsp:param bean="ShoppingCartModifier.shippingGroup" name="shippingGroup"/>
<dsp:param bean="UserPricingModels.shippingPricingModels" name="pricingModels"/>
<dsp:param bean="Profile" name="profile"/>
<dsp:oparam name="output">
   <dsp:select bean="ShoppingCartModifier.shippingGroup.shippingMethod">
   <dsp:droplet name="ForEach">
    <dsp:param name="array" param="availableShippingMethods"/>
    <dsp:param name="elementName" value="method"/>
    <dsp:oparam name="output">
    <dsp:getvalueof id="option199" param="method" idtype="java.lang.String">
<dsp:option value="<%=option199%>"/>
</dsp:getvalueof><dsp:valueof param="method"/>
    </dsp:oparam>
   </dsp:droplet>
   </dsp:select>
</dsp:oparam>
</dsp:droplet>

The shipping method that the customer selects is inserted into the shippingMethod property of the shippingGroup. For more information, consult the Shipping Prices section of the Pricing chapter in this document.

ATG Consumer Commerce also supports soft goods. For example, gift certificates are delivered via e-mail. See the Gift Certificates section in the Merchandising chapter of this guide for more information.

Billing information

The second part of the basic checkout process is when the customer enters the billing address and credit information.

For more information about credit card properties, see the Working with Purchase Process Objects chapter of the ATG Commerce Programming Guide.

Getting billing address information

The following JSP captures the billing address for the credit card:

Name<br>
<dsp:droplet name="IsEmpty">
  <dsp:param bean="ShoppingCartModifier.paymentGroup.billingAddress.firstName"
       name="value"/>
  <dsp:oparam name="false">
<dsp:input bean="ShoppingCartModifier.paymentGroup.billingAddress.firstName"
      size="15" type="text"/>
  </dsp:oparam>
  <dsp:oparam name="true">
<dsp:input bean="ShoppingCartModifier.paymentGroup.billingAddress.firstName"
     beanvalue="Profile.billingAddress.firstName" size="15" type="text"/>
  </dsp:oparam>
</dsp:droplet>


<dsp:droplet name="IsEmpty">
  <dsp:param bean="ShoppingCartModifier.paymentGroup.billingAddress.middleName"
       name="value"/>
  <dsp:oparam name="false">
<dsp:input bean="ShoppingCartModifier.paymentGroup.billingAddress.middleName"
       size="10" type="text"/>
  </dsp:oparam>
  <dsp:oparam name="true">
<dsp:input bean="ShoppingCartModifier.paymentGroup.billingAddress.middleName"
     beanvalue="Profile.billingAddress.middleName" size="10" type="text"/>
  </dsp:oparam>
</dsp:droplet>


Credit Card Information

In addition to the address associated with the paymentGroup, it is necessary to obtain credit card information such as the credit card number and expiration date. The credit card object in the order is accessed through the paymentGroup property of the ShoppingCartModifier.

New card type <dsp:select bean="ShoppingCartModifier.paymentGroup.creditCardType"
    required="<%=true%>">
<dsp:option value="Visa"/>Visa
<dsp:option value="MasterCard"/>Master Card
<dsp:option value="AmericanExpress"/>American Express
<dsp:option value="Discover"/>Discover
</dsp:select><br>


   New card number and expiration date<br>
<dsp:input bean="ShoppingCartModifier.paymentGroup.creditCardNumber" maxsize="20"
     size="20" type="text" required="<%=true%>"/><br>


<!-- Set the month that the card will expire on -->
Month: <dsp:select bean="ShoppingCartModifier.paymentGroup.expirationMonth">
<dsp:option value="1"/>January
<dsp:option value="2"/>February
<dsp:option value="3"/>March
<dsp:option value="4"/>April
<dsp:option value="5"/>May
<dsp:option value="6"/>June
<dsp:option value="7"/>July
<dsp:option value="8"/>August
<dsp:option value="9"/>September
<dsp:option value="10"/>October
<dsp:option value="11"/>November
<dsp:option value="12"/>December
</dsp:select>


<!-- Set the year that the card will expire on -->
Year: <dsp:select bean="ShoppingCartModifier.paymentGroup.expirationYear">
<dsp:option value="2000"/>2000
<dsp:option value="2001"/>2001
<dsp:option value="2002"/>2002
<dsp:option value="2003"/>2003
<dsp:option value="2004"/>2004
<dsp:option value="2005"/>2005
<dsp:option value="2006"/>2006
<dsp:option value="2007"/>2007
<dsp:option value="2008"/>2008
<dsp:option value="2009"/>2009
<dsp:option value="2010"/>2010
</dsp:select>

No comments:

Popular Posts