The CartModifierFormHandler.deleteItems
method deletes items that have their CommerceItemIds
in the RemovalCommerceIds
array. The quantity of the line item that contains the removal request is compared with the total quantity of the commerce item on the page. If the quantities match, the CommerceItemIds
is kept in the RemovalCatalogRefIds
array to be removed from the page. If the quantities do not match, the system adjusts the quantity accordingly and removes the CommerceItemId
from the RemovalCommerceIds
array.
Before the deleteItems
method removes all items with IDs in the removalCommerceIds
array, it runs the prepareLineItemsForRemoval
method to return the valid array of IDs to remove, as well as verify if the IDs require partial or complete removal. The prepareLineItemsForRemoval
method populates the removalLineItem
map that contains a set of IDs and reduction-quantity. The reduction-quantity is subtracted from the original quantity to provide the new quantity available in the shopping cart. Once the deleteItems
method removes the necessary elements, it processes the removalLineItems
map to adjust the quantities of items that were partially removed.
For detailed information on how the CartMofidiferFormHandler
works, refer to the Core Commerce Programming Guide.
Removing Commerce Items Split Across Multiple Lines
When configuring a JSP page that removes a commerce item, it is important to note if the commerce item is displayed across multiple lines in the UI, as in a group discount promotion. If you are using a droplet that allows items to be split across lines, such as the UnitPriceDetailsDroplet
, you should populate the removalCommerceIds
array with the commerceIds
, followed by an input delimiter, and then followed by the line item quantity. The CartModifierFormHandler
uses the inputDelimiter
property to indicate that items are displayed across multiple lines. For example:
<dsp:input iclass="atg_store_textButton atg_store_actionDelete" type="submit" name="remove_ci_${nameSuffix}${inputDelimiter}${currentItemQuantity}" bean="CartModifierFormHandler.removeItemFromOrder" value="${deleteButtonTitle}" submitvalue="${currentItemId}${inputDelimiter}${currentItemQuantity}"/>
The default value for the inputDelimiter
property is #
; however, you can modify the variable’s value in the CartModifierFormHandler.properties
file.