You use the SaveOrderFormHandler to save the user’s current shopping cart, add the shopping cart to the user’s list of saved carts in ShoppingCart.saved, and construct a new, empty cart as the user’s current shopping cart in ShoppingCart.current.

Additionally, you can use the description property of SaveOrderFormHandler to set the description property of the Order; this enables users to name their shopping carts with meaningful names. If the user doesn’t provide a descriptive name, then the SaveOrderFormHandler automatically creates one using the user’s locale and the current date and time.

The following JSP code illustrates the use of SaveOrderFormHandler.

<dsp:importbean bean="/atg/commerce/order/purchase/SaveOrderFormHandler"/>

Order # <dsp:valueof bean="ShoppingCart.current.id"/>
  <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" value="Save order"
         type="submit"/>
    <dsp:input bean="SaveOrderFormHandler.saveOrderSuccessURL"
         value="../user/saved_orders.jsp" type="hidden"/>
    <dsp:input bean="SaveOrderFormHandler.saveOrderErrorURL"
         value="../user/save_order.jsp" type="hidden"/>
  </dsp:form>

For descriptions of the handle methods of SaveOrderFormHandler and detailed information on how an Order is saved to the Order Repository, see the Saving Orders section of the Configuring Purchase Process Services chapter in the ATG Commerce Programming Guide. For a JSP code example illustrating the use of SaveOrderFormHandler, see the Saving Orders section of the My Account chapter in the ATG Business Commerce Reference Application Guide.

The OrderLookup servlet bean retrieves one or more Order objects, depending on the supplied input parameters. You can use this servlet bean to retrieve:

The OrderLookup servlet bean that is provided with ATG Commerce is an instance of class atg.commerce.order.OrderLookup if you are using ATG Consumer Commerce, or atg.b2bcommerce.order.B2BOrderLookup if you are using ATG Business Commerce.

The behavior of the servlet bean is governed by several properties that are set in the OrderLookup component. You can use the Pages and Components > Components by Path area of the ATG Control Center to view and modify the OrderLookup component, which is located at /atg/commerce/order/. The following properties are important when configuring the OrderLookup servlet bean.

Property

Description

enableSecurity

If this property is set to false, any user can view any order.

If this property is set to true, users are restricted to viewing only their own orders. A user is considered to own an order if the profile ID associated with the order matches the profile ID of that user.

By default, this property is set to true.

 

orderManager

The path of the global OrderManager component that is responsible for all direct interactions with Order objects. For most stores, this is set to /atg/commerce/order/OrderManager.

 

profilePath

The path to the Profile object of the user that is currently logged in. For most stores, this is set to /atg/userprofiling/Profile.

 

openStates

This property contains a list of order states that indicate that an order is open. Because several order states can indicate that an order is open, you can use this property to specify those states. Consequently, when you query for all “open” orders, you retrieve all orders with states specified in this property. By default, this property is set to the following:

-- submitted
-- processing
-- pending_merchant_action
-- pending_customer_action

You can override this list of “open” states by using the optional openStates input parameter, which is described later in this section.

 

closedStates

This property contains a list of order states that indicate that an order is closed. Because several order states can indicate that an order is closed, you can use this property to specify those states. Consequently, when you query for all “closed” orders, you retrieve all orders with states specified in this property. By default, this property is set to the following:

-- no_pending_action

You can override this list of “closed” states by using the optional closedStates input parameter, which is described later in this section.

 

useRequestLocale

Error messages generated by this servlet bean can be localized. If this boolean property is set to true, the messages are localized to the locale requested by the user.

 

defaultLocale

This property specifies the default locale to use to localize error messages. The defaultLocale is used to localize the messages if useRequestLocale is set to false or if the user does not request a locale.

 

queryTotal

If this property is set to false, the servlet bean does not set the totalCount and total_count output parameters to the total number of orders. (The totalCount and total_count output parameters are described later in this section.)

 

The OrderLookup servlet bean takes the following input parameters:

Parameter

Description

orderId

The ID of the order to retrieve.

Note: If you are using ATG Consumer Commerce, either this or userId is required. If you are using ATG Business Commerce, either this, userId, or costCenterId is required.

userId

The ID of the user profile whose orders will be retrieved.

Note: If you are using ATG Consumer Commerce, either this or orderId is required. If you are using ATG Business Commerce, either this, orderId, or costCenterId is required.

costCenterId

(ATG Business Commerce only)

The ID of the cost center whose orders will be retrieved.

Note: This parameter applies to ATG Business Commerce only. Either this, orderId, or userId is required.

state

The desired state of the orders to retrieve.

This parameter can be used in conjunction with userId. You can specify one of the following:

-- any one of the states defined in atg.commerce.states.OrderStates (if you are using ATG Consumer Commerce) or atg.b2bcommerce.states.B2BorderStates (if you are using ATG Business Commerce)

-- open

-- closed

If you specify “open,” then all orders whose states are specified in the openStates property of the OrderLookup component are returned. If you specify “closed,” then all orders whose states are specified in the closedStates property of the OrderLookup component are returned. You can override either list of states by using the optional openStates or closedStates input parameter (see below).

openStates

A comma-separated list of states that correspond to “open” state.

This parameter can be used in conjunction with the state input parameter when the state input parameter is set to “open.” Use this optional parameter when you want to override the configured list of states in the openStates property of the OrderLookup component.

closedStates

A comma-separated list of states that correspond to “closed” state.

This parameter can be used in conjunction with the state input parameter when the state input parameter is set to “closed.” Use this optional parameter when you want to override the configured list of states in the closedStates property of the OrderLookup component.

sortBy

A string that specifies an Order property by which to sort the orders.

This parameter can be used in conjunction with userId. When using this parameter, you can specify the name of any Order Repository property (that is, the name of any property defined in orderrepository.xml), such as id, state, or submittedDate.

sortAscending

True or false. This parameter is used in conjunction with the sortBy input parameter. If set to true, the Order objects in the resulting array are sorted in ascending order by the property specified in the sortBy input parameter. The default value is false.

numOrders

The number of orders to return for the given query.

startIndex

The index of the first order in the result set. This parameter is useful for cycling through a large number of orders.

queryTotal

Indicates whether the number of retrieved orders will be calculated into a total that’s accessible through the totalCount and total_count output parameters. Setting this property to false prevents the total count from being generated, regardless of the value specified in the queryTotal property. Omitting this parameter causes the default value, true, to be used. Use this parameter to ensure that queries to the database are made only when necessary.

queryTotalOnly

Indicates whether the total number of orders and the orders themselves are produced from the servlet bean. Setting this parameter to true makes the total number of retrieved orders available through the totalCount and total_count output parameters. The orders themselves are not retrieved or accessible. Use this parameter to ensure that queries to the database are made only when necessary.

Omitting this parameter, which is the same as setting it to false, saves a list of order objects to the output open parameter as well as the total number of orders to the totalCount and total_count output parameters.

If queryTotal=false (orders, no total) and queryTotalOnly=true (total, no orders), a total is generated only as specified in the queryTotalOnly parameter.

The OrderLookup servlet bean sets the following output parameters:

Parameter

Description

result

The array of Order objects. If the orderId input parameter was used, then this parameter contains a single Order object.

errorMsg

If an error occurred, this is the detailed error message for the user.

count

The size of the array of Order objects.

totalCount

If the queryTotal property is set to true, this parameter indicates the total number of orders that meet the criteria for the order lookup.

total_count

Identical to the totalCount output parameter.

startRange

The index number that marks the beginning of a range of orders. For example, if 5 orders were returned from a given OrderLookup query, the startRange is set to 1.

endRange

The index number that marks the end of a range of orders. For example, if 5 orders were returned from a given OrderLookup query with a startRange of 6, the endRange is set to 10.

nextIndex

The index of the first order in the next set of results. If the startIndex or numOrders input parameter was null, then this parameter will be null.

previousIndex

The index of the first order in the previous set of results. If the startIndex or numOrders input parameter was null, then this parameter will be null.

The OrderLookup servlet bean renders the following open parameters:

Parameter

Description

output

The oparam rendered if the orders are successfully retrieved.

empty

The oparam rendered if there are no orders to return.

error

The oparam rendered if an error occurs.

The following example describes how to use the OrderLookup servlet bean to retrieve all open orders for the current user and to display their IDs:

<dsp:droplet name="/atg/commerce/order/OrderLookup">
 <dsp:param bean="/atg/userprofiling/Profile.repositoryId" name="userId"/>
 <dsp:param value="open" name="state"/>
 <dsp:oparam name="output">
    <dsp:droplet name="/atg/dynamo/droplet/ForEach">
       <dsp:param param="result" name="array"/>
       <dsp:oparam name="outputStart">
            <OL>
       </dsp:oparam>
       <dsp:oparam name="outputEnd">
            </OL>
       </dsp:oparam>
       <dsp:oparam name="empty">
             No open orders.
       </dsp:oparam>
       <dsp:oparam name="output">
            <LI> <dsp:valueof param="element.id">no order number</dsp:valueof>
       </dsp:oparam>
     </dsp:droplet>
 </dsp:oparam>
 <dsp:oparam name="error">
        <span class=profilebig>ERROR:
          <dsp:valueof param="errorMsg">no error message</dsp:valueof>
        </span>
 </dsp:oparam>
</dsp:droplet>

The following example describes how to use the OrderLookup servlet bean to display information about a particular order with the ID of 123:

<dsp:droplet name="/atg/commerce/order/OrderLookup">
  <dsp:param value="123" name="orderId"/>
  <dsp:oparam name="error">
    <p>
    ERROR:
    <dsp:valueof param="errorMsg">no error message</dsp:valueof>
    <p>
  </dsp:oparam>
  <dsp:oparam name="output">
    <p>
    order #<dsp:valueof param="result.id">no order id</dsp:valueof>
    <p>
This order is in state:
<dsp:valueof param="result.stateAsString"/>
    <P>
    This order was placed on
      <dsp:valueof date="MMMMM d, yyyy" param="result.submittedDate"/>.
    <P>
  </dsp:oparam>
</dsp:droplet>
 
loading table of contents...