Users can delete items from their orders or change the quantities of items on the Current Order page. They simply enter a new quantity in the Qty field to change the quantity or enter a checkmark in the Remove box to delete a line item. After entering these changes, they click the Update button.

In checkout/cart.jsp, we used a ForEach droplet to iterate over each line item in the order. The output displayed for each line item includes important information such as the current quantity, price, a link to the referenced product page, and the ability to change its quantity or delete it.

In order to update the order, we used the /atg/commerce/order/purchase/CartModifierFormHandler.setOrder handler method in checkout/cart.jsp. This handler method determines the submitted quantity of each CommerceItem, adjusting those whose quantities have been modified, and removing those whose quantities are not greater than zero.

Changing the Quantity of an Item

To change the quantity of an item in the order, the CartModifierFormHandler is provided a request parameter named after the CommerceItem.catalogRefId, whose value is the new quantity for that CommerceItem:

<input type="text" size="3"
  name="<dsp:valueof param='CommerceItem.catalogRefId'/>"
  value="<dsp:valueof param='CommerceItem.quantity'/>">
Deleting an Item

To selectively remove items from the order, we set the CartModifierFormHandler.removalCatalogRefIds property to an array of the catalogRefIds:

<%-- Display "remove" checkbox column --%>
<td align=middle>
   <dsp:getvalueof id="skuId" param="CommerceItem.catalogRefId">
      <dsp:input type="checkbox" bean=
         "CartModifierFormHandler.removalCatalogRefIds" value="<%=skuId%>"/>
   </dsp:getvalueof>
</td>
Updating the Order

After a user has modified quantities and marked items for removal, he or she may either update the shopping cart page by clicking Update or proceed with the checkout process by clicking Checkout. Both of these submit buttons invoke handlers that modify the order based on the changes in the request. The checkout button also redirects the user to checkout/shipping.jsp. The following code snippet illustrates the Update and Checkout handlers:

<%-- Update Order button: --%>
<dsp:input bean="CartModifierFormHandler.setOrder" type="submit"
value="Update"/>

<%--
GoTo this URL if user pushes RECALCULATE button and there are no errors:
--%>
<dsp:input bean="CartModifierFormHandler.setOrderSuccessURL" type="hidden"
   value="../checkout/cart.jsp"/> <%/* stay here */%>

<%--
GoTo this URL if user pushes RECALCULATE button and there are errors:
--%>
<dsp:input bean="CartModifierFormHandler.setOrderErrorURL" type="hidden"
   value="../checkout/cart.jsp"/> <%/* stay here */%>

<%-- CHECKOUT Order button: --%>
&nbsp; &nbsp;   <dsp:input bean="CartModifierFormHandler.moveToPurchaseInfo"
   type="submit" value="Checkout"/>

<dsp:input bean="CartModifierFormHandler.moveToPurchaseInfoSuccessURL"
   type="hidden" value="../checkout/shipping.jsp"/> <%-- move on to shipping --%>

For more information, see the Core Commerce Programming Guide.


Copyright © 1997, 2019 Oracle and/or its affiliates. All rights reserved. Legal Notices