To modify an Order, you must supply either a CatalogRefId of a CommerceItem or a ShippingGroupCommerceItemRelationship ID. It is recommended that you modify an Order by ShippingGroupCommerceItemRelationship ID, especially if you intend to support complex product-SKU relationships, such as multiple CommerceItems with the same catalogRefId (SKU ID) or multiple shipping groups. For example, a customer could order 5 of a given item and choose to ship a quantity of 3 to a home address and the remaining 2 to a work address. In this example, to remove the items being shipped to the work address, you would modify (and ultimately remove) the ShippingGroupCommerceItemRelationship instead of modifying the CommerceItem.

The following subsections describes both order modification methods:

Modifying an Order by catalogRefId

Modifying orders by catalogRefId works for very simple sites. Because it does not provide the granularity necessary to delete just a part of a CommerceItem, it is not recommended for sites with complex features, such as multiple CommerceItems with the same catalogRefId or multiple shipping groups.

You can use the following CartModifierFormHandler methods to modify an Order by catalogRefId:

Refer to Understanding the CartModifierFormHandler for more information on these handle methods.

To change the quantities of items in an Order using the catalogRefIds of CommerceItems, call the CartModifierFormHandler.handleSetOrder() method for each CommerceItem whose quantity you want to change and pass in the catalogRefId and quantity for the CommerceItem. This is illustrated in the following JSP code:

<dsp:input bean='beanName' value='<dsp:valueof param="CommerceItem.quantity"/>'
type="text" name='<dsp:valueof param="CommerceItem.catalogRefId"/>'/>

Note that if no quantity is found for a CommerceItem, then the CommerceItem is removed from the Order.

To remove items from an Order using the catalogRefIds of CommerceItems, edit the JSPs that invoke the CartModifierFormHandler handle methods that delete items from the Order. Populate the form handler’s removalCatalogRefIds array with the catalogRefIds of the CommerceItems to be removed. For example, you can populate the array using following JSP code:

<dsp:input bean="CartModifierFormHandler.removalCatalogRefIds"
paramvalue="CommerceItem.catalogRefId" type="checkbox"/>
Modifying an Order by ShippingGroupCommerceItemRelationship ID

If your sites support complex product-SKU relationships (for example, multiple CommerceItems with the same catalogRefId) or multiple shipping groups, then it is recommended that you modify an Order using the IDs of the ShippingGroupCommerceItemRelationship objects in the Order. Doing so makes the changes at the CommerceItem-to-ShippingGroup level.

You can use the following CartModifierFormHandler methods to modify an Order by ShippingGroupCommerceItemRelationship ID:

Refer to Understanding the CartModifierFormHandler for more information on these handle methods.

To change the quantity of an item in the Order, pass the new quantity into the ShippingpingGroupCommerceItemRelationship, as shown in the following JSP example:

<dsp:input value='<dsp:valueof param="SgCiRelationship.quantity"/>'
type="text" name='<dsp:valueof param="SgCiRelationship.Id"/>'>

To delete an item from the Order, pass the ID of the associated ShippingGroupCommerceItemRelationship into the form handler’s removalRelationshipIds property, as shown in the following JSP example:

<dsp:input bean="CartModifierFormHandler.removalRelationshipIds"
paramvalue="SgCiRelationship.Id" type="checkbox"/>