Class Name

atg.commerce.order.AddItemToCartServlet

Component(s)

/atg/commerce/order/AddItemToCartServlet

The AddItemToCartServlet servlet bean adds an item to a shopping cart via a URL. This enables product information, such as the SKU and quantity of an item, to be passed as part of a URL to Core Commerce from a third-party application.

AddItemToCartServlet is called by a servlet in the request-handling pipeline, CommerceCommandServlet (class atg.commerce.order.CommerceCommandServlet). When CommerceCommandServlet receives a dcs_action input parameter of addItemToCart, it calls AddItemToCartServlet.

If only the required parameters for AddItemToCartServlet are supplied, then the servlet bean creates and adds to the cart a commerce item of class atg.commerce.order.CommerceItemImpl. If additional parameters are supplied, then AddItemToCartServlet functions differently depending on which optional parameters are supplied.

Refer to Adding an Item to an Order Via a URL in the Working With Purchase Process Objects chapter in the Core Commerce Programming Guide for more information on the implementation and behavior of both CommerceCommandServlet and AddItemToCartServlet.

Input Parameters

url_catalog_ref_id (Required)
The SKU of the item to add to the cart.

url_product_id (Required)
The product ID of the item to add to the cart.

url_quantity (Required)
The quantity of the item to add to the cart. When adding a quantity request, ensure that you match the type of quantity with the SKU or product. If a SKU or product uses fractional quantities, use 1.0 or 2.0 to represent quantities. If the product or SKU does not use fractional quantities, use whole numbers.

url_shipping_group_id
The ID of the shipping group to which to add the item.

url_item_type
The commerce item type to use to create the commerce item.

url_commerce_item_id
The ID of a commerce item that is removed from the order. Use this parameter when you want to replace one item in the cart with another.

dcs_ci_*
An identifier for setting a CommerceItem property.

If a parameter with this prefix is supplied, then the CommerceItem property to which it refers is set to the given value in the commerce item. For example, if the dcs_ci_catalogKey parameter is supplied with a given value of en_US, then the catalogKey property is set to en_US.

dcs_subsku

An identifier for setting a configurable property of a CommerceItem. The format is:

dcs_subsku=sku id, product id, quantity

The quantity portion of this parameter reflects the quantity of the item which will be added to a single ConfigurableCommerceItem. For example, if you are adding a computer with 2 hard drives, the quantity would be 2. If you were adding 1000 computers, each with 2 hard drives, the quantity would still be 2. Core Commerce handles the multiplication.

To add two different computer configurations, you must issue two separate requests to add each of the configurations as separate ConfigurableCommerceItems. For example, dcs_subsku=sku10001,prod10001,2&dcs_subsku=sku10002,prod10002,1 causes the servlet to add a CommerceItem with SKU/product combination sku10001, prod10001 with a quantity of 2 and SKU/product combination sku10002, prod10002 with a quantity of 1 to the ConfigurableCommerceItem.

Output Parameters

None. AddItemToCartServlet is called by a servlet in the request-handling pipeline, CommerceCommandServlet.

Open Parameters

None. AddItemToCartServlet is called by a servlet in the request-handling pipeline, CommerceCommandServlet.

Example

No JSP example is provided. AddItemToCartServlet is called by a servlet in the request-handling pipeline, CommerceCommandServlet.


Copyright © 1997, 2016 Oracle and/or its affiliates. All rights reserved. Legal Notices