Share via


How to Add Items to a Basket

The site code that you write for your application uses objects in the Microsoft.CommerceServer.Runtime.Orders namespace to create and manage the customer’s shopping cart. This topic describes one possible scenario for using the Orders objects in your site code. For more information about the objects in the Microsoft.CommerceServer.Runtime.Orders namespace, see Orders Runtime Object Model.

One common variant of this scenario is to create the Basket when the user adds the first item to the shopping cart, instead of creating the Basket as soon as the user enters the site.

For more detailed information about creating and using the objects in the Microsoft.CommerceServer.Runtime.Orders namespace, see Working with Orders Runtime Objects.

To add items to a basket

  1. When a user first enters the site, create a Basket.

  2. When the user adds the first item to the shopping cart, create an OrderForm and add it to the OrderFormCollection in the Basket. Create a LineItem to represent the item that the user added to the shopping cart. Add the LineItem to the newly created OrderForm. Then run the Basket pipeline to make sure that information about the item, such as price and availability, has not changed since the user added the item to the shopping cart.

  3. When the user adds an additional item to the shopping cart, create a new LineItem to represent the item that the user added to the shopping cart. Add the LineItem to the OrderForm in the Basket’s OrderFormCollection. Then run the Basket pipeline to make sure that information about the items in the shopping cart has not changed since the user added the items to the shopping cart.

See Also

Other Resources

Orders System Runtime Scenarios

How to Check Out a Basket

Orders Runtime Object Model

Working with Orders Runtime Objects