Customers can have an unlimited number of orders at one time. They can place items in different shopping carts, switch between carts, retrieve a list of saved carts, delete carts, and can check out one cart’s contents while waiting until later to check out the contents of others.

Using multiple orders requires atg.commerce.order.OrderHolder in addition to atg.commerce.order.Order. This class maintains the current Order object as well as a collection of saved Order objects. The component that utilizes OrderHolder is /atg/commerce/ShoppingCart, a session-scoped component whose handleXXX methods add, delete, and switch between carts, as explained in the rest of this section.

You implement multiple shopping carts using the handleCreate method of the OrderHolder class. This method creates a new Order and sets it as the currentOrder in the OrderHolder. Any previously existing Order object is placed into the collection of saved carts. Refer to the following JSP example:

<dsp:form action="ShoppingCart.jsp" method="post">
  <dsp:input bean="ShoppingCart.create" value="Create" type="submit"/> another
   shopping cart.<BR>

The handleSwitch() method allows customers to switch between shopping carts. It switches the current Order object out to the saved collection of orders and sets the current Order to the Order identified by the handlerOrderId property. If a customer has several shopping carts saved, you can allow them to switch between any of the Order objects using the following JSP code:

<dsp:form action="ShoppingCart.jsp" method="post">
 <dsp:select bean="ShoppingCart.handlerOrderId">
  <dsp:droplet name="ForEach">
   <dsp:param bean="ShoppingCart.saved" name="array"/>
   <dsp:param value="SavedOrder" name="elementName"/>
   <dsp:oparam name="output">
    <dsp:getvalueof id="option12" param="" idtype="java.lang.String">
<dsp:option value="<%=option12%>"/>
 <dsp:input bean="ShoppingCart.switch" value="Switch" type="submit"/>

The example iterates through the list of saved shopping carts, displays the shopping carts to the customer, and gives the customer the option to select one of the saved carts. The handlerOrderId property would be set to the selected Order ID, and the corresponding Order would be set as the current Order.

The handleDelete() and handleDeleteAll() methods remove a single Order or all orders (both current and saved), respectively.