BEA Logo BEA WebLogic Commerce Server Release 3.1.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   WebLogic Commerce Server Doc Home   |   Order Processing Package   |   Previous Topic   |   Next Topic   |   Contents   |   Index

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 Order Processing package 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.

shoppingcart.jsp Template

The shoppingcart.jsp template (shown in Figure 3-1 and Figure 3-2) 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-1 and Figure 3-2 show annotated versions of the shoppingcart.jsp template; the first shows the page for a customer who has not logged in, the second shows the page for a customer who has logged in. The dashed lines and numbers in the diagram are not part of the template; they are referenced in the explanation that follows the screen shot.

Figure 3-1 Annotated shoppingcart.jsp Template - Customer Not Logged In


Figure 3-2 Annotated shoppingcart.jsp Template - Customer Logged In

The numbers in the following list refer to the numbered regions in the figures:

  1. The page header (top banner) is created from an import of the header2.jsp template. This is standard across many of the JSP templates provided by WebLogic Commerce Server. The import call is:

    <%@ include file="/commerce/includes/header2.jsp" %>

  2. This region is the main content area for the page, which contains both dynamically generated data and static content. The dynamic content on shoppingcart.jsp is generated using WebLogic Server and Pipeline JSP tags that obtain and display the contents of both the active shopping cart and Saved Item list. For the shoppingcart.jsp template, the form posts include Delete, Buy Later, and Add to Cart (all per item), and Empty Cart, Check Out, Update, and Continue Shopping.

  3. The shoppingcart.jsp template's content in region 3 contains the included footer2.jsp template. The include call in shoppingcart.jsp is:

    <%@ include file="/commerce/includes/footer2.jsp" %>

    footer2.jsp consists of the horizontal footer at the bottom of the page, plus the right-side vertical column that describes (for the benefit of you and your development team) the name of the current template and links to its About information. In the footer2.jsp file, the right-side vertical column is an include file:

    <%@ include file="/commerce/includes/rightside.jsp" %> 

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%\server\webapps\wlcs\commerce\shoppingcart.jsp (Windows)
$WL_COMMERCE_HOME/server/webapps/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" %>

Note: For more information on the WebLogic Server JSP tags, see "JSP Tag Reference" in the BEA WebLogic Personalization Server documentation. For more information about the Pipeline JSP tags, see BEA WebLogic Commerce Server Webflow and Pipeline Management.

These files reside in the following directory for the WebLogic Commerce Server Web application:

%WL_COMMERCE_HOME%\server\webapps\wlcs\WEB-INF (Windows)
$WL_COMMERCE_HOME/server/webapps/wlcs/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.foundation.pipeline.*" %>
<%@ page import="com.beasys.commerce.axiom.units.*" %>
<%@ page import="com.beasys.commerce.ebusiness.shoppingcart.*" %>
<%@ page import="com.beasys.commerce.webflow.*" %>

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 login at the login.jsp template (prior to loading the shipping.jsp template). For more information about the login.jsp template, see BEA WebLogic Commerce Server Registration and User Processing Package.

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 Totals, 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 the Order Processing Package.

Included JSP Templates

The following JSP templates are included in the shoppingcart.jsp template:

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-1 shoppingcart.jsp Events

Event

Webflow Response(s)

--

InitShoppingCartIP

--

RefreshSavedList

button(checkout)

InitShippingMethodListIP

button(deleteItemFromShoppingCart)

DeleteProductItemFromShoppingCartIP

button(deleteItemFromSavedList)

UpdateSkuIP DeleteProductItemFromSavedList

button(emptyShoppingCart)

EmptyShoppingCartIP

button(moveItemToSavedList)

UpdateSkuIP

MoveProductItemToSavedList

button(moveItemToShoppingCart)

UpdateSkuIP MoveProductItemToShoppingCart

button(updateShoppingCartQuantities)

UpdateShoppingCartQuantitiesIP

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.

Table 3-2 Shopping Cart Pipelines

Pipeline

Description

RefreshSavedList

Contains RefreshSavedListPC and is not transactional.

DeleteProductItemFromSavedList

Contains DeleteProductItemFromSavedListPC and is transactional.

MoveProductItemToSavedList

Contains MoveProductItemToSavedListPC and is transactional.

MoveProductItemToShoppingCart

Contains MoveProductItemToShoppingCartPC and is transactional.

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 BEA WebLogic Commerce Server Product Catalog Management documentation.

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 .

Table 3-3 shoppingcart.jsp Pipeline Session Attributes

Attribute

Type

Description

PipelineSessionConstants.SAVED_SHOPPING_CART

com.beasys.commerce.ebusiness.shoppingcart.ShoppingCart

The saved shopping cart (source of the saved items).

PipelineSessionConstants.SHOPPING_CART

com.beasys.commerce.ebusiness.shoppingcart.ShoppingCart

The currently active shopping cart.

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 BEA WebLogic Commerce Server Webflow and Pipeline Management.

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.

Table 3-4 ShoppingCart Accessor Methods/Attributes

Method/Attribute

Description

getShoppingCartLineCollection()

A collection of the individual lines in the shopping cart (that is, ShoppingCartLine).

getTotal(int totalType)

The total amount specified by the totalType parameter. Valid parameters include:

ShoppingCartConstants.LINE_UNIT_PRICE_TIMES_QUANTITY
ShoppingCartConstants.LINE_SHIPPING
ShoppingCartConstants.LINE_TAX

Note: The getTotal() method also allows you to combine different total types. For more information, see the Javadoc.

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.

Table 3-5 ShoppingCartLine Accessor Methods/Attributes

Method/Attribute

Description

getQuantity()

The quantity of the item.

getProductItem()

The product item in the shopping cart line.

getUnitPrice()

The current price for the item at the time it was added to the shopping cart. May be different from MSRP.

getLineTotal(int totalType)

The total amount specified by the totalType parameter. Valid parameters include:

ShoppingCartConstants.LINE_UNIT_PRICE_TIMES_QUANTITY
ShoppingCartConstants.LINE_SHIPPING
ShoppingCartConstants.LINE_TAX

Note: The getLineTotal() method also allows you to combine different total types. For more information, see the Javadoc.

Listing 3-2 illustrates how these accessor methods/attributes are used within Java scriptlets.

Note: The ProductItem object is described in the BEA WebLogic Commerce Server Product Catalog Management document.

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 BEA WebLogic Personalization Server documentation.

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.

Table 3-6 shoppingcart.jsp Form Fields

Parameter Name

Type

Description

"event"

Hidden

Indicates which event has been triggered. It is used by the Webflow to determine what happens next.

"origin"

Hidden

The name of the current page (shoppingcart.jsp), used by the Webflow.

HttpRequestConstants.
CATALOG_ITEM_SKU

Hidden

SKU of the item that the event is to operate on.

NewQuantity_<SKU>


where <SKU> is replaced with the SKU of the item on the shopping cart line.

Textbox

The new quantity for the item in the shopping cart. It is the only form field on this page that requires input from the customer.

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

Class Name

com.beasys.commerce.ebusiness.shoppingcart.webflow.

DeleteProductItemFromShoppingCartIP

Description

Removes the item from the shopping cart.

Required HTTPServletRequest Parameters

HttpRequestConstants.CATALOG_ITEM_SKU

Required Pipeline
Session Attributes

PipelineSessionConstants.SHOPPING_CART

Updated Pipeline
Session Attributes

PipelineSessionConstants.SHOPPING_CART


Removed Pipeline
Session Attributes

None

Validation

None

Exceptions

ProcessingException, thrown if the required request parameters or required Pipeline session attributes are not available.

EmptyShoppingCartIP

Class Name

com.beasys.commerce.ebusiness.shoppingcart.webflow.

EmptyShoppingCartIP

Description

Creates a new shopping cart and stores it in the Pipeline session. The old shopping cart is discarded.

Required HTTPServletRequest Parameters

None

Required Pipeline
Session Attributes

None

Updated Pipeline
Session Attributes

PipelineSessionConstants.SHOPPING_CART


Removed Pipeline
Session Attributes

None

Validation

None

Exceptions

None

r

InitShoppingCartIP

Class Name

com.beasys.commerce.ebusiness.shoppingcart.webflow.

InitShoppingCartIP

Description

Initializes the active shopping cart prior to loading the shoppingcart.jsp template. If the shopping cart already exists, this input processor does nothing.

Required HTTPServletRequest Parameters

None

Required Pipeline
Session Attributes

None

Updated Pipeline
Session Attributes

PipelineSessionConstants.SHOPPING_CART


Removed Pipeline
Session Attributes

None

Validation

None

Exceptions

None

UpdateShoppingCartQuantitiesIP

Class Name

com.beasys.commerce.ebusiness.shoppingcart.webflow.

UpdateShoppingCartQuantitiesIP

Description

Validates the quantity fields for each line and sets those quantities in the shopping cart. If the quantity is zero, it will delete the item from the shopping cart.

Required HTTPServletRequest Parameters

NewQuantity_<SKU>

where <SKU> is replaced with the SKU of the item on the shopping cart line.

Required Pipeline
Session Attributes

PipelineSessionConstants.SHOPPING_CART

Updated Pipeline
Session Attributes

PipelineSessionConstants.SHOPPING_CART


Removed Pipeline
Session Attributes

None

Validation

Verifies that the quantity fields only contain positive integers.

Exceptions

ProcessingException, thrown if the required request parameters or required Pipeline session attributes are not available.

UpdateSkuIP

Class Name

com.beasys.commerce.ebusiness.shoppingcart.webflow.

UpdateSkuIP

Description

Reads the SKU from the HTTP request and places it into the Pipeline session.

Required HTTPServletRequest
Parameters

HttpRequestConstants.CATALOG_ITEM_SKU

Required Pipeline
Session Attributes

None

Updated Pipeline
Session Attributes

PipelineSessionConstants.CATALOG_ITEM_SKU

Removed Pipeline
Session Attributes

None

Validation

None

Exceptions

ProcessingException, thrown if the required request parameters are not available.

 


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 BEA WebLogic Commerce Server Product Catalog Management documentation.

Some Pipeline components extend other, base Pipeline components. For more information on the base classes, see the Javadoc.

DeleteProductItemFromSavedListPC

Class Name

com.beasys.commerce.ebusiness.shoppingcart.pipeline.DeleteProductItemFromSavedListPC

Description

Removes the item from the saved list and updates the WLCS_SAVED_ITEM_LIST table in the database.

Required Pipeline
Session Attributes

PipelineSessionConstants.CATALOG_ITEM_SKU

PipelineSessionConstants.SAVED_SHOPPING_CART

PipelineSessionConstants.USER_NAME

Updated Pipeline
Session Attributes

PipelineSessionConstants.SAVED_SHOPPING_CART


Removed Pipeline
Session Attributes

None

Type

Session bean

JNDI Name

com.beasys.commerce.ebusiness.shoppingcart.pipeline.DeleteProductItemFromSavedListPC

Exceptions

PipelineFatalException, thrown if the required Pipeline session attributes are not available.

MoveProductItemToSavedListPC

Class Name

com.beasys.commerce.ebusiness.shoppingcart.pipeline.
MoveProductItemToSavedListPC

Description

Removes the item from the shopping cart, adds it to the saved list, and then updates the WLCS_SAVED_ITEM_LIST table in the database.

Required Pipeline
Session Attributes

PipelineSessionConstants.CATALOG_ITEM_SKU

PipelineSessionConstants.SAVED_SHOPPING_CART

PipelineSessionConstants.SHOPPING_CART

PipelineSessionConstants.USER_NAME

Updated Pipeline
Session Attributes

PipelineSessionConstants.SAVED_SHOPPING_CART

PipelineSessionConstants.SHOPPING_CART

Removed Pipeline
Session Attributes

None

Type

Session bean

JNDI Name

com.beasys.commerce.ebusiness.shoppingcart.pipeline.
MoveProductItemToSavedListPC

Exceptions

PipelineFatalException, thrown if the required Pipeline session attributes are not available.

MoveProductItemToShoppingCartPC

Class Name

com.beasys.commerce.ebusiness.shoppingcart.pipeline.
MoveProductItemToShoppingCartPC

Description

Removes the item from the saved list, adds it to the shopping cart with a quantity of 1, and then updates the WLCS_SAVED_ITEM_LIST table in the database.

Required Pipeline
Session Attributes

PipelineSessionConstants.CATALOG_ITEM_SKU

PipelineSessionConstants.SAVED_SHOPPING_CART

PipelineSessionConstants.SHOPPING_CART

PipelineSessionConstants.USER_NAME

Updated Pipeline
Session Attributes

PipelineSessionConstants.SAVED_SHOPPING_CART

PipelineSessionConstants.SHOPPING_CART

Removed Pipeline
Session Attributes

None

Type

Session bean

JNDI Name

com.beasys.commerce.ebusiness.shoppingcart.

pipeline.MoveProductItemToShoppingCartPC

Exceptions

PipelineFatalException, thrown if the required Pipeline session attributes are not available.

RefreshSavedListPC

Class Name

com.beasys.commerce.ebusiness.shoppingcart.pipeline.
RefreshSavedListPC

Description

Queries the WLCS_SAVED_ITEM_LIST table and refreshes the saved shopping cart in the Pipeline session. The saved list is only refreshed if the saved shopping cart does not exist in the Pipeline session.

Required Pipeline Session Attributes

PipelineSessionConstants.USER_NAME

Updated Pipeline
Session Attributes

PipelineSessionConstants.SAVED_SHOPPING_CART

Removed Pipeline
Session Attributes

None

Type

Session bean

JNDI Name

com.beasys.commerce.ebusiness.shoppingcart.pipeline.
RefreshSavedListPC

Exceptions

PipelineFatalException, thrown if the required Pipeline session attributes are not available.