• An order is a container for commerce items, shipping groups, payment groups and relationship objects.


  • OrderHolder holds all the incomplete and saved Order.


  • Shopping Cart component used to create, Save or retrieve orders.
  • ShoppingCart.Current holds the current order object.
  • ShoppingCart.saved holds the saved orders.


  • A commerce item is order item which holds the catalogRefId , quantity and productId.


OrderTools contains all the Order Items type and bean to Item descriptor map :
  • commerceItemTypeClassMap
  • orderTypeClassMap
  • shippingTypeClassMap
  • paymentTypeClassMap
  • beanNameToItemDescriptorMap

Order Repository

  • orderrepository is the layer between ATG Commerce and database Server.
  • beanNameToItemDescriptorMap property of OrderTools maps the Order Repository item descriptor to bean names.

Relationship Classes

  • ShippingGroupCommerceItemRelationShip, 
  • PaymentGroupCommerceItemRelationShip, 
  • PaymentGroupShipingGroupRelationShip, 
  • PaymentGroupOrderRelationShip

Form Handlers

  • CartModifierFormHandler
  • ShoppingCartFormHandler
  • ExpressCheckoutFormHandler


  • RepriceOrderDroplet
  • ShoppingGroupDroplet
  • PaymentGroupDroplet

Shipping Groups

  • HardgoodShippingGroup
  • ElectronicShippingGroup


Class holds all the business logic for manipulating an Order.
Like creating an Order, adding CommerceItems to it, assigning those items to a ShippingGroup and checking the Order out.

Example :
 OrderManager orderManager = getOrderManager();
 PricingTools pricingTools = getPricingTools();
 String profileId = "10000"; String catalogRefId1 = "sku-1"; String productId1 = "product-1";
 long quantity1 = 1;

 // create the Order and CommerceItems.
 Order order = orderManager.createOrder(profileId);
 CommerceItem item1 = orderManager.createCommerceItem(catalogRefId1, productId1, quantity1);

 // add the items to the Order
 item1 = orderManager .addItemToOrder(order, item1);

 // get the ShippingGroup and add the items to it
 ShippingGroup sg = (ShippingGroup) order.getShippingGroups().get(0);
 orderManager.addItemQuantityToShippingGroup(order, item1.getId(), sg.getId(), quantity1);

 // add the entire order amount to the PaymentGroup
 PaymentGroup pg = (PaymentGroup) order.getPaymentGroups().get(0);
 orderManager.addRemainingOrderAmountToPaymentGroup(order, pg.getId());

 // Compute the prices using pricing tools

 // checkout the Order
 PipelineResult pr = orderManager.processOrder(order);

Order Process

Create Order

  • OrderManager orderManager = (OrderManager) request.resolveName("/atg/commerce/order/OrderManager");
  • Order order =orderManager.createOrder(profileId);
Add Item to Cart :
  • addItemToOrder(String orderId, String productId, String skuId, long quantity) method of CartModifierFormHandler.

Display : 
  • retrieve all the items using ShoppingCart.current.commerceItems.

Update Quantity : 
  • check CheckForChangedQuantity property of CartModifierFormHandler (default true). If true, call handleSetOrderByCommerceId() to update quantity.

Remove Item from Cart : 
  • Set removalCommerceIds property of CartModifierFormHandler. To remove more than a item call handleSetOrder(). For single item, call handleRemoveItemFromOrder()

Save Order : 
  • Call handleSaveOrder() of SaveOrderFormHandler. After calling this method, Order will be saved to ShoppingCart.saved and new Order gets created.

Retrieve Saved Order : 
  • set Order Id to bean="ShoppingCart.handlerOrderId" and pass to ShoppingCart.switch. This will retrieve order from Order Repository.

Cancel Order :

  • <dsp:input bean="CancelOrderFormHandler.cancelOrder" type="submit" value="Cancel order"/>
  • <dsp:input bean="CancelOrderFormHandler.orderIdToCancel" beanvalue="ShoppingCart.current.id" type="hidden"/>

Checkout : 
  • When user wants to checkout, handleMoveToPurchaseInfo() method of CartModifierFormHandler invokes modifyOrder() to check any update in Order. Then call runProcessMoveToPurchaseInfo method gets called to run the appropriate pipeline chain.

Commit Order :

  • <dsp:input bean="CommitOrderFormHandler.commitOrder" type="submit" value="Place order "/>
  • This form handler calls OrderManager.processOrder to actually place the order. If placing the order succeeds, then sets the shopping cart lastOrder to the current (just submitted) order and the currentOrder to null.

Send items to multiple shipping addresses

  • call the handleSplitShippingInfos method of ShippingGroupFormHandler to split the item quantity to different shipping group. 
  • Then call handleApplyShippingGroups method ShippingGroupFormHandler.

Customize commerce Item properties :

If we want to update the properties of commerce Item. Below are the steps, we need to follow :
  • Create a component by extending CommerceItemImpl
              public class MyCommerceItem extends CommerceItemImpl
  • Add new property and create get/set api.
              private Timestamp updateDate;

              public Timestamp getUpdateDate() {
                 return (Timestamp)getPropertyValue(updateDatePropertyName);
              public void setUpdateDate(Timestamp updateDate) {
  • Modify orderrepository.xml. Modify commerceItem itemdescriptor. Add table of type auxiliary and add properties.
          <item-descriptor name="commerceItem">
      <table name="MY_COMMERCE_ITEM" type="auxiliary" id-column-name="COMMERCE_ITEM_ID">
<property name="updateDate" column-name="UPDATE_DATE" data-type="timestamp" category="UPDATE DATE" display-name="Update Date"/>
  • Modify OrderTools component. Update commerceItemTypeClassMap and beanNameToItemDescriptorMap.


Exceptions : ConcurrentUpdateException and InvalidVersionException - Click here to learn more


No comments :