|
VB.NET • Enable Shopping Basket Functionality Listing 1. You can use the Orders namespace to add a catalog item to the user's default shopping basket and to display the shopping basket by data binding to an ASP.NET DataGrid. You could extend the use of this basket to create wish lists, buying templates, and so on. The first section of this code adds an item to a user's shopping basket; the second section displays basket items. Using Microsoft.CommerceServer.Runtime;
Using Microsoft.CommerceServer.Runtime.Orders;
Basket b = _
CommerceContext.Current.OrderSystem.GetBasket _
(new Guid(CommerceContext.Current.UserID));
LineItem li = new LineItem();
li.ProductCatalog = "Adventure Works Catalog";
li.Quantity = 1;
li.ProductCategory = "crampons";
li.ProductID = "AW109-15";
b.OrderForms["default"].LineItems.Add(li);
b.Save();
using Microsoft.CommerceServer.Runtime;
Using Microsoft.CommerceServer.Runtime.Orders;
Basket b = _
CommerceContext.Current.OrderSystem.GetBasket _
(new Guid(CommerceContext.Current.UserID));
PipelineInfo info = new PipelineInfo("basket");
info["catalog_language"] = @"en-US";
info["CacheName"] = @"Discounts";
info.Profiles.Add("User", _
CommerceContext.Current.UserProfile);
b.RunPipeline(info);
DataGrid1.DataSource = _
b.OrderForms["default"].LineItems;
DataGrid1.DataBind();
|