With the roll out of the e-commerce Framework API in version 9, there has been many customers interested in implementing this API on its own and in tandem with the Ektron e-commerce server controls. The example presented below is for working with an e-commerce Basket Manager.
This code will allow you to create a basket data object for a user that either is and isn’t logged in. This basket data can then be passed to the checkout server control for a seamless checkout experience.
Ektron.Cms.Framework.Commerce.BasketManager basMan = new Ektron.Cms.Framework.Commerce.BasketManager()
BasketData basket = new BasketData();
UserManager userMan = new UserManager();
long userID = userMan.RequestInformation.UserId;
//for the code below to work properly you must make
//sure a Default basket is already created for the shopper before getting it back.
if (userID > 0) //customer has a user id
{
basket = basMan.GetDefault(userID);
basMan.SetDefault(basket.Id, userID);
}
else //customer that is not logged in
{
string _shopperGUID = Ektron.Cms.CommonApi.GetVisitorID(Page);
basket = basMan.GetDefault(_shopperGUID);
basket.IsDefault = true;
basket.ShopperId = _shopperGUID;
basMan.Update(basket);
}
Please sign in to leave a comment.