Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Add To cart Error.

Vote:
 

Hi whenever i am trying to add cart . I am getting following error.

Error:

Object reference not set to an instance of an object.

public Entry Entry { get; set; }

public Func<Entry, bool> FilterAction { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
// getcart();
}

protected void btnBuy_Click(object sender, EventArgs e)
{
CartHelper test = new CartHelper(Cart.DefaultName);


if (Entry != null)
{
Entry entry = Entry;

if (FilterAction != null)
{
entry = Entry.Entries.Entry.FirstOrDefault(FilterAction);
test.AddEntry(entry);
}

}

}

 

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   Mediachase.Commerce.Website.Helpers.CartHelper.CreateLineItem(Entry entry, Decimal quantity, String warehouseCode) +853
   Mediachase.Commerce.Website.Helpers.CartHelper.AddEntry(Entry entry, Decimal quantity, Boolean fixedQuantity, String warehouseCode, CartHelper[] helpersToRemove) +718
   Mediachase.Commerce.Website.Helpers.CartHelper.AddEntry(Entry entry, Decimal quantity, Boolean fixedQuantity, CartHelper[] helpersToRemove) +79
   Mediachase.Commerce.Website.Helpers.CartHelper.AddEntry(Entry entry) +143
   DemoTest.Sample.Units.ProductDetail.SharedModule.AddToCart.btnBuy_Click(Object sender, EventArgs e) in C:\EPiServer\DemoVisualStudioCTP17\wwwroot\Sample\Units\ProductDetail\SharedModule\AddToCart.ascx.cs:43
   System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +116
   System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +101
   System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +9642610
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724

I am geeting Entry properly. but I am not able to find the attribute which i am missing.

can anyone suggest me ? Which thing i am missing over here ?

Thanks in advance.

regards,
Paragi

 

 

 

 

#77714
Nov 25, 2013 12:06
Vote:
 

Try asking this in the EPiServer Commerce forum.

Also it appears you're working with the CTP17 version which should be discussed in the TAP forums instead of the open forums.

#79680
Dec 30, 2013 11:07
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.