|
|
Shopping Cart Management Services
As in a physical store, a shopping cart is the mechanism used to store items that a customer decides to purchase from your e-business. Implicitly, the cart also stores various types of information related to these items: a unique identifier, a quantity, a price, discounts, taxes, and so on. Customers need to be able to manage their shopping cart by adding and removing items. This topic provides you with information about the Shopping Cart Management Services, which allow your customers to perform these activities.
This topic includes the following sections:
JavaServer Pages (JSPs)
The Managing Purchases and Processing Orders services contains one JavaServer Page (JSP) that allows your customers to manage their shopping cart. You can choose to utilize this page in its current form, or adapt it to meet your specific needs. This section describes this page in detail.
Note: For a description of the complete set of JSPs used in the WebLogic Commerce Server Web application and a listing of their locations in the directory structure, see the E-Commerce JSP Template Summary.
Common JSP Template Elements
Several elements are common to all JSP commerce templates. The callouts in Figure 3-1 point out each common element; a description of each element follows the figure.
Figure 3-1 Common Commerce JSP Template Elements
<%@ include file="/commerce/includes/admin.inc" %>
<%@ include file="/commerce/includes/header.inc" %>
<%@ include file="/commerce/includes/leftside.inc" %>
<%@ include file="/commerce/includes/footer.inc" %>
shoppingcart.jsp Template
The shoppingcart.jsp template (shown in Figure 3-2 and Figure 3-3) displays the items currently in a customer's shopping cart. For each item the customer added to their cart (that is still actively part of the current purchase), the shoppingcart.jsp template displays the quantity, the item name, the list price, the actual price, a savings amount, and a subtotal. Following this information, a total price for the order is displayed.
The item quantity is shown in an editable field, allowing customers to change the quantity of the item simply by typing a new quantity and clicking the Update button. For your customers' convenience, the item name is hyperlinked back to its description in the product catalog. For each item in the shopping cart, there is also a Delete button and a Buy Later button. Clicking the Delete button removes the item from the shopping cart, while clicking the Buy Later button causes the item to be moved from the Shopping Cart to the Saved Items list. For each item shown in the Saved Items list, the hyperlinked item name and a brief description are displayed. Additionally, the Delete and Add to Cart buttons in this section allow your customers to remove the item altogether or to move it back to their active Shopping Cart.
Notes: To be able to use the features of the Saved Items list, a customer must have first logged in.
If there are no items in a customer's shopping cart, the Empty Cart, Update, and Check Out buttons will not be available.
If the customer is satisfied with the contents of their shopping cart, the customer can click the Check Out button to begin the checkout process.
Note: If the customer is not logged into your e-commerce site, they will be prompted to do so before continuing to the next part of the checkout process.
If your customer wants to start over, the customer can click the Empty Cart button to empty the entire contents of the shopping cart (both active and saved). If your customer wants to continue shopping, the customer can click the Continue Shopping button to return to the product catalog.
Sample Browser View
Figure 3-2 and Figure 3-3 show annotated versions of the shoppingcart.jsp template; the first figure shows the page for a customer who has not logged in, the second shows the page for a customer who has logged in. The main content area of the template contains both dynamically generated data and static content. The dynamic content on shoppingcart.jsp is generated using WebLogic Server and Pipeline JSP tags, which obtain and display the contents for both the active shopping cart and Saved Item list. For the shoppingcart.jsp template, the form posts include Empty Cart, Check Out, Remove, Update, and Continue.
Note: For information on other elements in the shoppingcart.jsp template, see Common JSP Template Elements.
Figure 3-2 Annotated shoppingcart.jsp Template - Customer Not Logged In
Figure 3-3 Annotated shoppingcart.jsp Template - Customer Logged In
In Figure 3-3, the following changes occur after the user has logged in:
Location in the WebLogic Commerce Server Directory Structure
You can find the shoppingcart.jsp template file at the following location, where WL_COMMERCE_HOME is the directory in which you installed WebLogic Commerce Server:
%WL_COMMERCE_HOME%\config\wlcsDomain\applications\wlcsApp\wlcs\commerce\shoppingcart.jsp (Windows)
$WL_COMMERCE_HOME/config/wlcsDomain/applications/wlcsApp/wlcs/commerce/shoppingcart.jsp (UNIX)
Tag Library Imports
The shoppingcart.jsp template uses WebLogic Server and Pipeline JSP tags. Therefore, the template includes the following JSP tag libraries:
<%@ taglib uri="weblogic.tld" prefix="wl" %>
<%@ taglib uri="pipeline.tld" prefix="pipeline" %>
<%@ taglib uri="i18n.tld" prefix="i18n" %>
Note: For more information on the WebLogic Server JSP tags, see "JSP Tag Reference" in the Guide to Building Personalized Applications. For more information about the Pipeline JSP tags, see the Guide to Registering Customers and Managing Customer Services.
These files reside in the following directory for the WebLogic Commerce Server Web application:
%WL_COMMERCE_HOME%\config\wlcsDomain\applications\wlcsApp\wlcs\commerce\wlcs\WEB-INF (Windows)
$WL_COMMERCE_HOME/config/wlcsDomain/applications/wlcsApp/wlcs/commerce/WEB-INF (UNIX)
Java Package Imports
The shoppingcart.jsp template uses Java classes in the following packages and therefore includes these import statements:
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%@ page import="com.beasys.commerce.webflow.*" %>
<%@ page import="com.beasys.commerce.axiom.units.*" %>
<%@ page import="com.beasys.commerce.foundation.pipeline.*" %>
<%@ page import="com.beasys.commerce.ebusiness.shoppingcart.*" %>
<%@ page import="com.bea.commerce.ebusiness.price.service.DiscountPresentation" %>
<%@ page import="com.bea.commerce.ebusiness.price.quote.OrderAdjustment" %>
<%@ page import="com.bea.commerce.ebusiness.price.quote.AdjustmentDetail" %>
Location in Default Webflow
Customers can arrive at shoppingcart.jsp template from any product catalog page by clicking the View Cart button. If the customer is satisfied with the contents of their shopping cart as shown on this page, the customer can initiate the checkout process by clicking the Check Out button. If this is the case, the next page is the shipping information page (shipping.jsp).
Note: If the customer has not yet logged into the site and clicks the Check Out button, the customer will be prompted to log in at the login.jsp template (prior to loading the shipping.jsp template). For more information about the login.jsp template, see the Guide to Registering Customers and Managing Customer Services.
If customers click a link to an individual product item to review detailed information about that product item, the next page is the appropriate product catalog page. If they click on the Update, Empty Cart, Delete, or Save for Later buttons, they are returned to the shopping cart page (shoppingcart.jsp) after the appropriate input processor or Pipeline has been executed to record the modification.
Note: For more information about the default Webflow, see Overview of Managing Purchases and Processing Orders.
Events
Every time a customer clicks a button to manage the contents of their shopping cart, it is considered an event. Each event triggers a particular response in the default Webflow that allows the customer to continue. While this response can be to load another JSP, it is usually the case that an input processor and/or Pipeline is invoked first. Table 3-1 provides information about these events and the business logic they invoke.
Table 3-2 briefly describes each of the Pipelines from Table 3-1, as they are defined in the pipeline.properties file. For more information about individual Pipeline components, see Pipeline Components.
Notes: Although the InitShoppingCartIP and RefreshSavedList Pipeline are associated with the shoppingcart.jsp template, they are not triggered by events on the page. Rather, both are executed before the shoppingcart.jsp is viewed. The InitShoppingCartIP input processor creates an empty shopping cart in preparation for the customer's shopping experience, while the RefreshSavedList Pipeline retrieves a customer's list of previously saved shopping cart items.
For information about the AddProductItemToShoppingCartPC, a Pipeline component invoked in a Pipeline prior to display of the shoppingcart.jsp template, see the "Product Catalog JSP Templates and Tag Library" in the Guide to Building a Product Catalog.
Dynamic Data Display
One purpose of the shoppingcart.jsp template is to display the data specific to a customer's shopping experience for their review. This is accomplished on shoppingcart.jsp using a combination of WebLogic Server and Pipeline JSP tags and accessor methods/attributes.
First, the getPipelineProperty JSP tag retrieves the SHOPPING_CART and SAVED_SHOPPING_CART attributes from the Pipeline session. Table 3-3 provides more detailed information on these attributes.
Listing 3-1 illustrates how these attributes are retrieved from the Pipeline session using the getPipelineProperty JSP tag.
Listing 3-1 Retrieving Shopping Cart Attributes
<pipeline:getPipelineProperty
propertyName="<%=PipelineSessionConstants.SHOPPING_CART%>"
returnName="shoppingCart"
returnType="com.beasys.commerce.ebusiness.shoppingcart.ShoppingCart"/>
<pipeline:getPipelineProperty
propertyName="<%=PipelineSessionConstants.SAVED_SHOPPING_CART%>
returnName="savedShoppingCart"
returnType="com.beasys.commerce.ebusiness.shoppingcart.ShoppingCart"/>
Note: For more information on the getPipelineProperty JSP tag, see the Guide to Registering Customers and Managing Customer Services.
The data stored within the Pipeline session attributes is accessed by using accessor methods/attributes within Java scriptlets. Table 3-4 provides more detailed information about these methods for ShoppingCart (also savedShoppingCart), while Table 3-5 provides this information for ShoppingCartLine.
Because the getShoppingCartLineCollection() method allows you to retrieve a collection of the individual lines within a shopping cart, there are also accessor methods/attributes you can use to break apart the information contained within each line. Table 3-5 provides information about these methods/attributes.
Listing 3-2 provides an example of how these accessor methods/attributes are used within Java scriptlets.
Note: The ProductItem object is described in the Guide to Building a Product Catalog.
Listing 3-2 Using Accessor Methods Within shoppingcart.jsp Java Scriptlets
<wl:repeat set="<%shoppingCart.getShoppingCartLineCollection().iterator()%>" id="shoppingCartLine" type="ShoppingCartLine" count="100000">
<tr>
<td>
<%=shoppingCartLine.getProductItem().getName()%>
</td>
<td align="right">
<input type="text" name="NewQuantity_<%=shoppingCartLine.getProductItem().
getKey().getIdentifier()%>"
value="<%=quantityFormat.format(shoppingCartLine.getQuantity())%>"
size="9">
</td>
<td align="right">
<%=shoppingCartLine.getProductItem().getMsrp().getCurrency()%>
<%=priceFormat.format(shoppingCartLine.getProductItem().getMsrp().
getValue())%>
</td>
<td align="center">
<input type="submit" value="Delete" onclick="submitForm(`shoppingCartForm',
'button(deleteItemFromShoppingCart)','<%=shoppingCartLine.getProductItem()
.getKey().getIdentifier()%>')">
</td>
</tr>
</wl:repeat>
Note: For more information on the WebLogic Server JSP tags, see "JSP Tag Reference" in the Guide to Building Personalized Applications.
Form Field Specification
Another purpose of the shoppingcart.jsp template is to allow customers to make changes to their shopping cart using various HTML form fields. These form fields are also used to pass needed information to the Webflow.
The form fields used in the shoppingcart.jsp template, and a description for each of them, are listed in Table 3-6.
Note: Parameters that are literals in the JSP code are shown in quotes, while non-literals will require scriptlet syntax (such as
<%= HttpRequestConstants.CATALOG_ITEM_SKU %>) for use in the JSP.
Input Processors
This section provides a brief description of each input processor associated with the Shopping Cart Management Services JSP template(s).
Note: For information about the InitShippingMethodListIP input processor, see the input processors listed in Shipping Services.
DeleteProductItemFromShoppingCartIP
EmptyShoppingCartIP
InitShoppingCartIP
UpdateShoppingCartQuantitiesIP
UpdateSkuIP
Pipeline Components
This section provides a brief description of each Pipeline component associated with the Shopping Cart Management Services JSP template(s).
Notes: For information about the AddProductItemToShoppingCartPC, invoked prior to display of the shoppingcart.jsp template, see "the Product Catalog JSP Templates and Tag Library" in the Guide to Building a Product Catalog.
Some Pipeline components extend other, base Pipeline components. For more information on the base classes, see the Javadoc.
DeleteProductItemFromSavedListPC
MoveProductItemToSavedListPC
MoveProductItemToShoppingCartPC
RefreshSavedListPC
PriceShoppingCartPC
AddToCartTrackerPC
RemoveFromCartTrackerPC
UpdateShoppingCartQuantitiesTrackerPC
|
Copyright © 2001 BEA Systems, Inc. All rights reserved.
|