This guideline provides basic order-related scenarios when working with the ECF API.
Note: This feature has been obsoleted in the latest version of the product.
Adding an entry to a cart
The following is an example of adding an entry to a cart.
C#
void AddToCart(Entry entry)
{
decimal quantity = 5;
CartHelper cartHelper = new CartHelper(Cart.DefaultName);
cartHelper.AddEntry(entry, quantity, false);
}
Getting cart items
You can create a CartHelper instance with the name CartHelper.DefaultName to get items in the cart.
C#
IEnumerable<LineItem> GetCartItems()
{
CartHelper cart = new CartHelper(Cart.DefaultName);
return cart.LineItems;
}
Adding an entry to a wish list
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.
C#
void AddToWishList(Entry entry)
{
decimal quantity = 5;
CartHelper cart = new CartHelper(CartHelper.WishListName);
cart.AddEntry(entry, quantity, false);
}
Getting wish list items
You can create a new CartHelper with name CartHelper.WishListName to get all items in a wish list.
C#
IEnumerable<LineItem> GetWishListItems()
{
CartHelper wishList = new CartHelper(CartHelper.WishListName);
return wishList.LineItems;
}
Getting promotions for an entry
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.
Getting the order history
You can use OrderContext.Current.GetPurchaseOrders to get all the orders for a registered customer (user).
C#
PurchaseOrder[] orders;
if (SecurityContext.Current.CurrentUser != null)
{
orders = OrderContext.Current.GetPurchaseOrders(SecurityContext.Current.CurrentUserId).ToArray<PurchaseOrder>();
}
Getting the order detail
You can use OrderContext.Current.GetPurchaseOrderById to get a specific order detail.
C#
int orderGroupId = 3;
PurchaseOrder orderDetail = OrderContext.Current.GetPurchaseOrderById(orderGroupId);
Do you find this information helpful? Please log in to provide feedback.