AddToCartLink not working

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
jsmits
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Wed Sep 30, 2009 11:57 am

AddToCartLink not working

Post by jsmits » Tue Oct 20, 2009 10:15 am

I had the AddToCartLink control working, but now when I try to use it I get an object reference not set to an instance of an object error. Error details:

Code: Select all

Line 87: 
Line 88:         MoreDetailsLink.Visible = !AC.Visible;
Line 89:         if (MoreDetailsLink.Visible) MoreDetailsLink.NavigateUrl = product.NavigateUrl;
Line 90:         SaveCustomViewState();
Line 91:     }
Source File: d:\Inetpub\ACDemo.com\ConLib\AddToCartLink.ascx.cs Line: 89

It looks like it is passing null in as a product, but I have no idea why. Can anyone provide insight into this error?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: AddToCartLink not working

Post by mazhar » Wed Oct 21, 2009 2:33 am

It may be due to some change you made in control's code file. If this isn't the case may be you upgraded your website but this file is still using old code. Other possibility may be that control is not attached to valid product id.

User avatar
jsmits
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Wed Sep 30, 2009 11:57 am

Re: AddToCartLink not working

Post by jsmits » Wed Oct 21, 2009 6:37 am

Thank you Mazhar. I don't think I modified the code. I am still using the evaluation license. I figured out what makes it happen, just not the why. If you can reproduce, maybe it is a bug...

When you change to a custom content page with just the addtocartlink control using the edit panel, the error occurs. If you edit the scriptlet in the edit panel and change the productId then save, the error goes away.

Can you reproduce?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: AddToCartLink not working

Post by mazhar » Wed Oct 21, 2009 8:00 am

This will surly cause trouble beacuse its not intended for isolated use. AddToCart link always requires a product id in order to operate. If you are using it alone on page something like

Code: Select all

[[ConLIb:AddToCartLink]] 
It means there is no valid product id available in the context and hence it will throw a null exception. If you know some valid product id then try it as below

Code: Select all

[[ConLIb:AddToCartLink ProductId="productid value here"]] 
replace productid value here with your product id.

User avatar
jsmits
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Wed Sep 30, 2009 11:57 am

Re: AddToCartLink not working

Post by jsmits » Wed Oct 21, 2009 8:37 am

Yeah, I have been using it with valid ProductId's, but for whatever reason I need to edit the product using the edit panel to get it to work. What I think happens, is if you change the content page away from the page with the AddtoCartLink control to something else, then change it back, it will throw the error until you edit it using the edit panel and click save. In fact, you don't even have to change the text, just open the scriptlet editor (not from within admin, only on the page) and click save.

I don't think this is really a big deal since I know what makes it happen and how to correct, but it is still odd behavior.

Post Reply