As described in Modifying Orders and Checking Out Orders in this chapter, two form handlers in the ATG Commerce purchase process have handle methods that you can use to reprice an Order
:
CartModifierFormHandler
, which is used to modify orders by adding and removing items and changing item quantities.ExpressCheckoutFormHandler
, which manages and expedites the pre-checkout processing of orders.
However, you’ll need to reprice orders via some other mechanism if customers can make order changes that affect order price through other form handlers that do not reprice orders (for example, by making shipping changes via the form handlers that create and manage shipping groups), or if the orders are modified through some other means in ways that affect order price, such as the delivery of a promotion via a scenario.
If your site has any pages where you need to reprice an Order
, but you cannot do so through a form action and corresponding handle method, use the RepriceOrderDroplet
servlet bean. By default, the servlet bean is configured to invoke the repriceAndUpdateOrder
pipeline, which reprices the Order
by calling the repriceOrder
pipeline and then updates the Order
by calling OrderManager.updateOrder()
.
The RepriceOrderDroplet
servlet bean is an instance of atg.commerce.order.purchase.RepriceOrder
, which extends atg.service.pipeline.servlet.PipelineChainInvocation
. ATG Commerce provides an instance of RepriceOrder
, which is located in Nucleus at /atg/commerce/order/purchase/RepriceOrderDroplet
.
The RepriceOrder
class provides the required objects for executing a repricing pipeline as convenient properties. Typically, execution of a repricing pipeline requires the Order
, the Profile
, the OrderManager
, and the user’s PricingModelHolder
. RepriceOrder
is conveniently configured to reference these objects, which means that a page developer doesn’t need to supply them as input parameters every time the RepriceOrderDroplet
servlet bean is invoked. Consequently, the only required parameter that must be supplied is the pricing operation to execute. Acceptable pricing operations are defined in the atg.commerce.pricing.PricingConstants
interface; they are the following:
Pricing Operation | Pricing Constant |
---|---|
ORDER_TOTAL | PricingConstants.OP_REPRICE_ORDER_TOTAL |
ORDER_SUBTOTAL | PricingConstants.OP_REPRICE_ORDER_SUBTOTAL |
ORDER_SUBTOTAL_SHIPPING | PricingConstants.OP_REPRICE_ORDER_SUBTOTAL_SHIPPING |
ORDER_SUBTOTAL_TAX | PricingConstants.OP_REPRICE_ORDER_SUBTOTAL_TAX |
ITEMS | PricingConstants.OP_REPRICE_ITEMS |
SHIPPING | PricingConstants.OP_REPRICE_SHIPPING |
ORDER | PricingConstants.OP_REPRICE_ORDER |
TAX | PricingConstants.OP_REPRICE_TAX |
NO_REPRICE | PricingConstants.OP_NO_REPRICE |
The following code sample is taken from RepriceOrderDroplet.properties
and indicates its default configuration:
$class=atg.commerce.order.purchase.RepriceOrder $scope=request defaultPipelineManager=/atg/commerce/PipelineManager defaultChainId=repriceAndUpdateOrder order^=/atg/commerce/ShoppingCart.current profile=/atg/userprofiling/Profile orderManager=/atg/commerce/order/OrderManager userPricingModels=/atg/commerce/pricing/UserPricingModels
This default configuration enables a page developer to include the RepriceOrderDroplet
servlet bean on any shopping cart page that requires the repricing and updating of Orders
with the following JSP code:
<dsp:droplet name="RepriceOrderDroplet"> <dsp:param value="ORDER_SUBTOTAL" name="pricingOp"/> </dsp:droplet>
For information on all of the input, output, and open parameters of RepriceOrderDroplet
, see the RepriceOrder reference entry in Appendix: ATG Commerce Servlet Beans of the ATG Commerce Guide to Setting Up a Store. For information on the OrderManager.updateOrder()
method and the updateOrder
pipeline, see Updating an Order with the OrderManager in this chapter. For more information about pipelines, the PipelineManager
, and the transactional modes and transitions of the processors in the repriceOrder
pipeline, see the Commerce Processor Chains section.