You are on page 1of 3

Shopping Cart Document

Shopping cart page basic functionalities: Adding items to cart. View item details in the cart. Change the quantity of items added to the cart. Remove items from cart. All the basic functionalities of shopping cart are provided by CartModifierFormHandler (OOTB Component). CartModifierFormHandler contains order property linked to the user's current order. Order Processing: Order processing will be done by 4 layers. Base Layer Business Layer Pipelines Order Repository.
Contains core object: Order. CommerceItem. Shipping Groups. Payment Groups. Relationships.

Base Layer

Creates new order. Add item to order. Removes the item. Creates the relationship among base classes.

Business Layer

Pipelines

Executes the series of processors Example:Save order to db. Validate order. Process order.

Order Repository
Provides order persistence. Includes item descriptors like: order. credit card. payment status.

While saving an item to cart Business layer will be invoked,which will creates the new order and creates the relationship among core objects of ATG Commerce(CommerceItem,Shipping Groups,Payment Groups,Relationships).Business layer is responsible for adding items to the order and removing items too. After adding an item to the order pipelines will executes the series of processors like validating the order,validating the shipping and payment details. Then after order is persisted in the order repository by saving the order to the database.

Updating the items in the cart: After clicking on update link in the cart page handleSetOrderByCommerceId() method of CartModifierFormHandler is called. handleSetOrderByCommerceId(): Performs the actual work necessary to save an Order. It calls modifyOrderByCommerceId() to validate the users changes and modify the Order. It then calls runProcessSetOrder(), which executes the pipeline set in CartModifierFormHandler.setOrderChainId. Finally, it calls OrderManager.updateOrder(). modifyOrderByCommerceId():The modifyOrderByCommerceId() method modifies the Order based on the changes made in the request. It iterates over each CommerceItem in the Order. For each CommerceItem, it retrieves the current quantity by calling getQuantity() and passing in the commerceItemId (SKU ID) of the item Next, the method checks if the catalogRefId of the current item is in the removalCommerceIds list. If it is, then the quantity of the current item is set to zero. Then, the quantity of the current item is assessed and one of two actions occurs: If the quantity is greater than zero, the method sets the quantity in the CommerceItem. If the quantity is less than or equal to zero, then it removes the CommerceItem and any associated Relationship objects from the Order. RunProcessSetOrder():This method runs the pipeline set in CartModifierFormHandler.setOrderChainId. By default, this property is set to setOrder. Removing items from the cart: handleRemoveItemFromOrder() method is called after clicking on remove link of line item in the cart page. handleRemoveItemFromOrder():Removes items from the Order by CommerceItem ID. This handle method calls deleteItems() to delete the items from the Order and then calls OrderManager.updateOrder(). DeleteItems():Deletes from the Order all CommerceItems whose IDs are in the removalCommerceIds property. The method also removes all associated ShippingGroupCommerceItemRelationships and calls runProcessRepriceOrder(), which reprices the Order by executing the pipeline set in CartModifierFormHandler.repriceOrderChainId. Finally, the method fires a scenario event of type ItemRemovedFromOrder.

RunProcessRepriceOrder(): Runs the pipeline to execute whenever the order needs to be repriced. The pipeline to run is set in CartModifierFormHandler.repriceOrderChainId.

You might also like