The
CartModifierFormHandler is used to add items to and remove items from
an Order, modify the quantity of items in the Order, and prepare the
Order for the checkout process.
CartModifierFormHandler is an instance of class atg.commerce.order.purchase.CartModifierFormHandler; it is located in Nucleus at /atg/commerce/order/purchase/CartModifierFormHandler. Many of the methods (described below) in CartModifierFormHandler call OrderManager.updateOrder() to save the Order in its present state to the Order Repository. For information on OrderManager.updateOrder() and the updateOrder pipeline that it executes, see the Updating an Order with the OrderManager subsection of Saving Orders in this chapter.
The following sections describes the important methods in CartModifierFormHandler. As can be seen from the method descriptions that follow, the handleAddXXX and handleRemoveXXX methods of CartModifierFormHandler automatically reprice the Order whenever the user makes changes to it.
However, you should note that users can also make changes to their orders through other purchase process form handlers that do not reprice orders, such as the form handlers that create and manage shipping groups. In these situations, where the user can change the current Order in ways that affect its price, and where the form handler used to process those changes does not reprice the Order, you should use the RepriceOrderDroplet servlet bean to reprice the Order before displaying its price to the user.
When a customer adds an item to their shopping cart using CartModifierFormHandler, the submit button on the form submits to the handleAddItemToOrder method. Before any computation is done, the handleAddItemToOrder method invokes the preAddItemToOrder method. Additionally, after all computation is complete but before returning any information, the handleAddItemToOrder method invokes the postAddItemToOrder method.
CartModifierFormHandler.java
handleAddItemToOrder has following steps:
Create Order:
Order order = getOrder();
preAddItemToOrder - do validation for sku as active, check inventory etc...
addItemToOrder
postAddItemToOrder
updateOrder
RepeatingRequestMonitor rMonitor = getRepeatingRequestMonitor();
String cartHandler = "CartModFormHandler.addItemOrder";
if ((rMonitor == null) || (rMonitor .isUniqueRequestEntry(myHandleMethod))) {
Transaction sTransaction = null;
try {
sTransaction = ensureTransaction();
Order order = getOrder();
synchronized (order) {
preAddItemToOrder(pRequest, pResponse);
addItemToOrder(pRequest, pResponse);
postAddItemToOrder(pRequest, pResponse);
updateOrder(order, "Error", pRequest, pResponse);
}
return checkFormRedirect(getAddItemToOrderSuccessURL(),
getAddItemToOrderErrorURL(), pRequest, pResponse);
}
finally {
if (tr != null){
commitTransaction(tr);
}
if (rMonitor != null) {
rMonitor .removeRequestEntry(cartHandler);
}
CartModifierFormHandler is an instance of class atg.commerce.order.purchase.CartModifierFormHandler; it is located in Nucleus at /atg/commerce/order/purchase/CartModifierFormHandler. Many of the methods (described below) in CartModifierFormHandler call OrderManager.updateOrder() to save the Order in its present state to the Order Repository. For information on OrderManager.updateOrder() and the updateOrder pipeline that it executes, see the Updating an Order with the OrderManager subsection of Saving Orders in this chapter.
The following sections describes the important methods in CartModifierFormHandler. As can be seen from the method descriptions that follow, the handleAddXXX and handleRemoveXXX methods of CartModifierFormHandler automatically reprice the Order whenever the user makes changes to it.
However, you should note that users can also make changes to their orders through other purchase process form handlers that do not reprice orders, such as the form handlers that create and manage shipping groups. In these situations, where the user can change the current Order in ways that affect its price, and where the form handler used to process those changes does not reprice the Order, you should use the RepriceOrderDroplet servlet bean to reprice the Order before displaying its price to the user.
When a customer adds an item to their shopping cart using CartModifierFormHandler, the submit button on the form submits to the handleAddItemToOrder method. Before any computation is done, the handleAddItemToOrder method invokes the preAddItemToOrder method. Additionally, after all computation is complete but before returning any information, the handleAddItemToOrder method invokes the postAddItemToOrder method.
CartModifierFormHandler.java
handleAddItemToOrder has following steps:
Create Order:
Order order = getOrder();
preAddItemToOrder - do validation for sku as active, check inventory etc...
addItemToOrder
postAddItemToOrder
updateOrder
RepeatingRequestMonitor rMonitor = getRepeatingRequestMonitor();
String cartHandler = "CartModFormHandler.addItemOrder";
if ((rMonitor == null) || (rMonitor .isUniqueRequestEntry(myHandleMethod))) {
Transaction sTransaction = null;
try {
sTransaction = ensureTransaction();
Order order = getOrder();
synchronized (order) {
preAddItemToOrder(pRequest, pResponse);
addItemToOrder(pRequest, pResponse);
postAddItemToOrder(pRequest, pResponse);
updateOrder(order, "Error", pRequest, pResponse);
}
return checkFormRedirect(getAddItemToOrderSuccessURL(),
getAddItemToOrderErrorURL(), pRequest, pResponse);
}
finally {
if (tr != null){
commitTransaction(tr);
}
if (rMonitor != null) {
rMonitor .removeRequestEntry(cartHandler);
}
No comments:
Post a Comment