PurchaseProcessHelper contains the common functionality required by
the purchase process form handlers as well as commerce web services.
getPurchaseProcessHelper().adjustItemRelationshipsForQuantityChange(order,item,quantity)
getPurchaseProcessHelper().deleteItems();
getPurchaseProcessHelper().addItemsToOrder();
getPurchaseProcessHelper().getFirstShippingGroup();
getPurchaseProcessHelper().createOrder();
getPurchaseProcessHelper().runProcessAddItemToOrder()
CartModifierFormHandler uses PurchaseProcessHelper to interact with pipeline processors and CommerceItemManager while adding/editing the cart.
addItemToOrder() method retrieves the list of items to add by calling CartModifierFormHandler.getItems(), and calls CartModifierFormHandler.getCatalogKey() to determine which catalog to use. Then, for each item to add to the Order, the method uses the PurchaseProcessHelper class to do the following:
Creates a CommerceItem using the commerceItemType, catalogRefId, productId and quantity found in the current array element from getItems(). Adds the created CommerceItem to the order. Copies custom values from the current item’s value Dictionary to the new CommerceItem. Calls the PurchaseProcessHelper.getShippingGroupForItem() method to get a shipping group of the appropriate type. The type can be determined in one of three ways.
Calls PurchaseProcessHelper.addItemToShippingGroup(), which calls CommerceItemManager.addItemQuantityToShippingGroup() which in turn takes the given quantity of the CommerceItem and the given ShippingGroup and creates a ShippingGroupCommerceItemRelationship of type SHIPPINGQUANTITY.
For information on the SHIPPINGQUANTITY type of ShippingGroupCommerceItemRelationship, see Relationship Types in the Using Relationship Objects section of the Working With Purchase Process Objects chapter.
Calls createConfigurableSubitems(), which is an empty method that can be overridden as needed by sites that use configurable commerce items.
Calls processGiftAddition(), which checks if the item that was added to the order is a gift (that is, the item’s input giftlistId or giftlistItemId property is non-null). If the item is a gift, processGiftAddition() calls GiftListManager.addGiftToOrder() to perform additional gift list processing.
After the above steps have been taken for all the new items, addItemToOrder() calls runProcessRepriceOrder(), which reprices the Order by executing the pipeline set in CartModifierFormHandler.repriceOrderChainId. Then, for each new item addItemToOrder() calls runProcessAddItemToOrder(), which executes the pipeline set in CartModifierFormHandler.addItemToOrderChainId. Finally, the method fires a scenario event of type ItemAddedToOrder for each new item.
getPurchaseProcessHelper().adjustItemRelationshipsForQuantityChange(order,item,quantity)
getPurchaseProcessHelper().deleteItems();
getPurchaseProcessHelper().addItemsToOrder();
getPurchaseProcessHelper().getFirstShippingGroup();
getPurchaseProcessHelper().createOrder();
getPurchaseProcessHelper().runProcessAddItemToOrder()
CartModifierFormHandler uses PurchaseProcessHelper to interact with pipeline processors and CommerceItemManager while adding/editing the cart.
addItemToOrder() method retrieves the list of items to add by calling CartModifierFormHandler.getItems(), and calls CartModifierFormHandler.getCatalogKey() to determine which catalog to use. Then, for each item to add to the Order, the method uses the PurchaseProcessHelper class to do the following:
Creates a CommerceItem using the commerceItemType, catalogRefId, productId and quantity found in the current array element from getItems(). Adds the created CommerceItem to the order. Copies custom values from the current item’s value Dictionary to the new CommerceItem. Calls the PurchaseProcessHelper.getShippingGroupForItem() method to get a shipping group of the appropriate type. The type can be determined in one of three ways.
- Passed in to PurchaseProcessHelper from the CartModifierFormHandler.getItems()[ ].shippingGroupType. The passed-in type is used along with the item’s gift information (if any) to determine the correct shipping group to which the item should be added.
- Use the first shipping group of the passed-in type (if that information is available) or the first shipping group on the order, regardless of the item type. If this is the desired behavior (perhaps you only sell goods with one shipping group type, and the default is always the correct type), set the addItemToDefaultShippingGroup property of the /atg/commerce/order/purchase/PurchaseProcessHelper component to true. This property is set to true by default.
- PurchaseProcessHelper can determine the correct group from the item type (based on the SKU’s fulfiller property value) and gift information. To use this behavior, set the addItemToDefaultShippingGroup property of the /atg/commerce/order/purchase/PurchaseProcessHelper component to false.
Calls PurchaseProcessHelper.addItemToShippingGroup(), which calls CommerceItemManager.addItemQuantityToShippingGroup() which in turn takes the given quantity of the CommerceItem and the given ShippingGroup and creates a ShippingGroupCommerceItemRelationship of type SHIPPINGQUANTITY.
For information on the SHIPPINGQUANTITY type of ShippingGroupCommerceItemRelationship, see Relationship Types in the Using Relationship Objects section of the Working With Purchase Process Objects chapter.
Calls createConfigurableSubitems(), which is an empty method that can be overridden as needed by sites that use configurable commerce items.
Calls processGiftAddition(), which checks if the item that was added to the order is a gift (that is, the item’s input giftlistId or giftlistItemId property is non-null). If the item is a gift, processGiftAddition() calls GiftListManager.addGiftToOrder() to perform additional gift list processing.
After the above steps have been taken for all the new items, addItemToOrder() calls runProcessRepriceOrder(), which reprices the Order by executing the pipeline set in CartModifierFormHandler.repriceOrderChainId. Then, for each new item addItemToOrder() calls runProcessAddItemToOrder(), which executes the pipeline set in CartModifierFormHandler.addItemToOrderChainId. Finally, the method fires a scenario event of type ItemAddedToOrder for each new item.
No comments:
Post a Comment