Buyers can save selected orders from one session to the next. This feature is comparable to the concept of having multiple saved shopping carts.

checkout/cart.jsp and checkout/save_order.jsp allow users to save orders under a description they provide.

On the Current Order page (checkout/cart.jsp), the buyer can check out, cancel the order, or save the order. If he clicks the Save Order button, he is taken to save_order.jsp, where he is asked to provide a description of the saved order. If the user does not provide a name, the order is saved with the current date/time stamp, according to the user’s locale.

We used /atg/commerce/order/purchase/SaveOrderFormHandler to save the user’s current order based on the name that the user specifies. Each saved order for a specific buyer must have a unique name; an error is displayed if the buyer enters a name that already exists on a saved order in their saved order list. We used the following block of JSP code in user/save_order.jsp to provide this:

<dsp:form action="saved_orders.jsp">
   Enter a name to identify this order:<p>
   <dsp:input bean="SaveOrderFormHandler.description" type="text"/>
   <dsp:input bean="SaveOrderFormHandler.saveOrder" type="submit" value="Save
      order"/>
   <dsp:input bean="SaveOrderFormHandler.saveOrder" type="hidden" value="save"/>
   <dsp:input bean="SaveOrderFormHandler.saveOrderSuccessURL" type="hidden"
      value="../user/saved_orders.jsp"/>
   <dsp:input bean="SaveOrderFormHandler.saveOrderErrorURL" type="hidden"
     value="../user/save_order.jsp"/>

Users have a link for their saved orders on the My Account page (order_management.jsp). They can browse through a list their of saved orders by clicking this link, which takes them to saved_orders.jsp. Once on this page, users can choose any saved order as their current order.

The code to display the list of saved orders is:

<dsp:droplet name="IsEmpty">
  <dsp:param name="value" bean="ShoppingCart.saved"/>
  <dsp:oparam name="true">
    <tr><td>You have no saved orders.</td></tr>
  </dsp:oparam>
  <dsp:oparam name="false">
    <tr valign=top>
      <td>
      <table border=0 cellpadding=4 width=100%>
        <tr>
          <td><b><span class=small> Order name</span></b></td>
          <td>&nbsp; </td>
          <td><b><span class=small> Order #</span></b></td>
          <td>&nbsp; </td>
          <td><b><span class=small>Date saved</span></b></td>
        </tr>
        <dsp:droplet name="ForEach">
          <dsp:param name="array" bean="ShoppingCart.saved"/>
          <dsp:oparam name="output">
            <tr>
              <td><dsp:a href="saved_order.jsp"><dsp:param name="orderId"
                param="element.id"/><dsp:valueof
                param="element.description"/></dsp:a></td>
              <td></td>
              <td><dsp:valueof  param="element.id"/></td>
              <td></td>
              <td><dsp:valueof date="MMMM d, yyyy h:mm a" param=
               "element.creationDate"/></td>
            </tr>
          </dsp:oparam>
        </dsp:droplet>
      </table>
      </td>
    </tr>
  </dsp:oparam>
</dsp:droplet><!--end IsEmpty-->

All the saved orders of the user are stored in saved array property of the Shopping Cart. We iterate through it displaying each saved order with a link, using which an user can access the saved order and he can choose it as his current Shopping Cart. The following code from saved_order.jsp demonstrates this:

<td colspan=4 align=right>
   <dsp:form action="../checkout/cart.jsp" method="post">
   <dsp:input bean="ShoppingCart.handlerOrderId" paramvalue="order.id"
      type="hidden"/>
   <dsp:input bean="ShoppingCart.switch" type="submit" value="Make this your
      current order"/> &nbsp;
   </dsp:form>
</td>
<td colspan=2 align=left>
   <dsp:form action="../user/saved_orders.jsp" method="post">
   <dsp:input bean="ShoppingCart.handlerOrderId" paramvalue="order.id"
      type="hidden"/>
   <dsp:input bean="ShoppingCart.delete" type="submit" value="Delete"/> &nbsp;
   </dsp:form>

Once a saved order is made the current order, it is removed from the saved orders list.

Note: saved orders are different than purchase lists. Users create purchase lists while navigating the catalog. While they are browsing the catalog, they can add any product to their purchase lists or create new purchase lists and add items to them. Purchase lists are completely editable; users can add or delete items from them and they can delete the entire purchase lists. Purchase lists can be used again and again. When a purchase list is added to the current order, all the items in purchase list are actually added to the order. The purchase list itself is not removed after adding it to the order. Saved orders, however, can only be used once they are made the current order. We actually put the saved order into the checkout process. It becomes the current order and then no longer exists as a saved order.

 
loading table of contents...