Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Note: This feature has been obsoleted in the latest version of the product.
This guideline provides basic order-related scenarios when working with the ECF API.
The following is an example of adding an entry to a cart.
void AddToCart(Entry entry)
{
decimal quantity = 5;
CartHelper cartHelper = new CartHelper(Cart.DefaultName);
cartHelper.AddEntry(entry, quantity, false);
}
You can 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, you need to 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);
}
You can 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. Refer to the source code in the the GetPromotions(this Entry entry) extension method to see how to do it.
You can use OrderContext.Current.GetPurchaseOrders to get all the orders for a registered customer (user).
PurchaseOrder[] orders;
if (SecurityContext.Current.CurrentUser != null)
{
orders = OrderContext.Current.GetPurchaseOrders(SecurityContext.Current.CurrentUserId).ToArray<PurchaseOrder>();
}
You can use OrderContext.Current.GetPurchaseOrderById to get a specific order detail.
int orderGroupId = 3;
PurchaseOrder orderDetail = OrderContext.Current.GetPurchaseOrderById(orderGroupId);
Last updated: Oct 21, 2014