Tuesday, January 22, 2013

Repricing Orders : ATG

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>

No comments:

Popular Posts