Skip to content

Instantly share code, notes, and snippets.

@adamjenkin
Created March 19, 2013 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamjenkin/5200380 to your computer and use it in GitHub Desktop.
Save adamjenkin/5200380 to your computer and use it in GitHub Desktop.
public override Basket GetBasket(bool create)
{
// Member is not logged on use default behavior
if (!Member.IsLoggedOn()) return base.GetBasket(create);
// Otherwise try and load a basket for the current member, create one if it doesn't exist
Basket basket = GetBasketForCurrentMember();
if(basket == null)
{
// no member specific basket, check anonymous basket held in cookie
// (Has basket on the OrderContext class checks for a basket in the cookie of the HttpConext)
if(this.HasBasket)
{
basket = this.GetBasket();
// Set the memberid property on this basket to convert it to a member basket
basket.PurchaseOrder["MemberId"] = Member.CurrentMemberId().ToString();
// Might need a save here?
// basket.PurchaseOrder.Save();
}
else
{
// no anonymous or member baskets, create a brand new one
basket = CreateBasket();
}
return basket;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment