Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
The following guidelines show order-related scenarios when working with the ECF API.
C#
void AddToCart(Entry entry)
{
decimal quantity = 5;
CartHelper cartHelper = new CartHelper(Cart.DefaultName);
cartHelper.AddEntry(entry, quantity, false);
}
Create a CartHelper instance with the name CartHelper.DefaultName to get items in the cart.
IEnumerable<LineItem> GetCartItems()
{
CartHelper cart = new CartHelper(Cart.DefaultName);
return cart.LineItems;
}
To add a product to cart, create an instance of CartHelper first. Then, call AddEntry to add a specific CatalogEntry to the cart.
void AddToWishList(Entry entry)
{
decimal quantity = 5;
CartHelper cart = new CartHelper(CartHelper.WishListName);
cart.AddEntry(entry, quantity, false);
}
Create a new CartHelper with name CartHelper.WishListName to get all items in a wish list.
IEnumerable<LineItem> GetWishListItems()
{
CartHelper wishList = new CartHelper(CartHelper.WishListName);
return wishList.LineItems;
}
Getting promotions for an entry is an advanced case. See the source code in the GetPromotions(this Entry entry) extension method to see how to do it.
Use OrderContext.Current.GetPurchaseOrders to get all orders for a registered customer (user).
PurchaseOrder[] orders;
if (SecurityContext.Current.CurrentUser != null)
{
orders = OrderContext.Current.GetPurchaseOrders(SecurityContext.Current.CurrentUserId).ToArray<PurchaseOrder>();
}
Use OrderContext.Current.GetPurchaseOrderById to get detail for a specific order.
int orderGroupId = 3;
PurchaseOrder orderDetail = OrderContext.Current.GetPurchaseOrderById(orderGroupId);
Last updated: Oct 12, 2015