Tuesday, March 5, 2013

Adding an Item to an Order via a URL : ATG




The CommerceCommandServlet provides a foundation for URL-based actions. Out of the box, you can allow a user to add an item to his or her order by clicking a URL. Because this process is part of the Request-handling pipeline (which handles all ATG requests and responses), each time a page is requested, the request will be checked to see if it includes commerce item information.



Consider the following example request URL:

http://immuraliraj.blogspott.com/yourpage.jsp?action=additemtocart&url_catalog_ref_
id=sku10001&url_product_id=prod10001&url_quantity=1&dcs_ci_catalogKey=en_
US&dcs_subsku=sku10001,prod10001,2&dcs_subsku=sku10002,prod10002,1


The action flag notifies the request-handling pipeline of the action to be performed, and additional parameters give the specifics for the action. The following table explains the URL elements:


Click on the image and see the clear picture:






As indicated, the first four parameters listed in the table above are required. If no other parameters are supplied, the servlet creates a CommerceItem and adds it to the cart.

If a dcs_subsku parameter is in the URL, then the base SKU/product is represented in a ConfigurableCommerceItem object and the subSKU is represented in a SubSkuCommerceItem object. SubSkuCommerceItem is a subclass of CommerceItemImpl.

If all required parameters and shipping_group_id are supplied, then the item is added to the ShippingGroup with the specified ID.

No comments:

Popular Posts