You can also use the OrderLookup
servlet bean to retrieve a user’s incomplete orders (that is, shopping carts). OrderLookup
enables you to retrieve a single order, all orders assigned to a particular cost center (ATG Business Commerce only), all orders placed by a particular user, or all orders placed by a particular user that are in specific state, such as INCOMPLETE. For more information on OrderLookup
, see the Implementing Order Retrieval chapter.
Once the desired shopping cart is moved to ShoppingCart.current
, you can use a ForEach
servlet bean to iterate over the commerce items in the cart and display them. The following JSP code example illustrates how to do this. In the example, a checkbox is rendered beside each item to allow the user to remove any item from the cart; likewise, a textbox is rendered beside each item to allow the user to modify the quantity of any item.
<droplet bean="ForEach"> <param name="array" value="bean:ShoppingCart.current.commerceItems"> <param name="elementName" value="item"> <oparam name="output"> <tr valign=top> <td> <input type="checkbox" unchecked bean="CartModifierFormHandler.removalCatalogRefIds" value="param:item.catalogRefId"> </td> <td> <input size=4 name="param:item.catalogRefId" value="param:item.quantity"> </td> <td> <droplet src="product_fragment.jsp"> <param name="childProduct" value="param:item.auxiliaryData.productRef"> <%@ include file="product_fragment.jsp"%> </droplet> </oparam> </droplet>
cart.jsp
in the Motorprise reference application illustrates similar functionality. If you’ve installed ATG Business Commerce, you can access cart.jsp
at <ATG9dir>\MotorpriseJSP\j2ee-apps\motorprise\web-app\en\catalog\
. You can also open the page in the ACC’s Document Editor via the Pages and Components>J2EE Pages task area.