Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 8 of 8

Thread: Add To Cart on Default page not working V9

  1. #1
    cc9537 is offline Member
    Join Date
    May 2009
    Posts
    40

    Default Add To Cart on Default page not working V9

    Greetings,

    I changed the featuredproducts.xml.config. Where it used to display text that said click here for more information, I changed it to the add to cart button. The code in the XML is the exact same as the add to cart button in other unedited XML packages, and it displays the button just fine, but it does not work. When you click on the button it does nothing.

    Also, in the bottom of IE the status bar says done but with errors since I changed the featuredproducts.xml.config.

    I suspect it has to do with the new master pages and only one form per page, but how can I fix this?

    Clint.

  2. #2
    Rob is offline Senior Member
    Join Date
    Aug 2004
    Posts
    3,037

    Default

    investigating....response/resolution within 15 mins...
    AspDotNetStorefront
    Shopping Cart

  3. #3
    AspDotNetStorefront Staff - Scott's Avatar
    AspDotNetStorefront Staff - Scott is offline Administrator
    Join Date
    Mar 2007
    Location
    Ashland, OR
    Posts
    2,390

    Default

    Pretty sure I know what this....add to cart handling changed a bit in 9.x because of how master pages handle forms.

    First off, fire this up in Firefox with Firebug and see if the Javascript error says something about 'aspdnsf' being undefined.

    If that's the problem, you'll need to take a look at showproduct.aspx.cs and take the add to cart handling logic (HandleAddToCart method, etc) and copy that into default.aspx.cs (or whatever page you're displaying featured products on). That'll add in all the logic you need to extract the form input and add the item to the cart.

  4. #4
    cc9537 is offline Member
    Join Date
    May 2009
    Posts
    40

    Default Almost resolved

    Scott, thanks for a push in the right direction. I am glad to know I was right about what was causing it, but I didn't know where to go to fix it. I do know that I have spent a few days working on this, and I know I looked at default.cs before but I can not remember if I added handleaddtocart logic to it, but it was there when I opened it up today.

    What was missing was

    private bool IsAddToCartPostBack
    {
    get
    {
    return "AddToCart".Equals(CommonLogic.FormCanBeDangerousC ontent("__EVENTTARGET"),
    StringComparison.InvariantCultureIgnoreCase);
    }
    }

    and since I am using the minicart it was also missing

    if (AppLogic.AppConfigBool("Minicart.UseAjaxAddToCart "))
    {
    scrptMgr.Services.Add(new ServiceReference("~/actionservice.asmx"));
    }

    I do have one more problem, after adding this it adds stuff to the cart, but does not treat the minicart right. Instead, it reloads the page and shows the number of items in my minicart is incremented. It does not show the mini-cart.

    Can you point me in the direction of the code that shows the mini-cart instead of a reload.

    I copied the handleaddtocart section over again from the showproducts.cs. but that did not do it.


    Thanks for your help.

  5. #5
    adamw is offline Junior Member
    Join Date
    Jun 2010
    Posts
    10

    Default

    So I have an e-*.aspx page that has add to cart buttons and were working pre v9. I just put all the aforementioned code in my engine.aspx.cs file but still get the 'aspdnsf is undefined' javascript error. Any ideas?

  6. #6
    Asingh is offline Junior Member
    Join Date
    Dec 2010
    Posts
    3

    Default I have tired to copy but it is not working

    Hi There,

    i have tried and copied all event code nto default.aspx.cs file. but im still getting same error aspdnsf is not defined.

    Could you please guide me in to the right direction.

    Regards

    Anil

  7. #7
    maltschul is offline Junior Member
    Join Date
    May 2010
    Posts
    13

    Default

    Anil,

    I was receiving the same "aspdnsf is not defined" javascript error and found that my page was missing:

    Code:
    <script src="jscripts/product.js" type="text/javascript"></script>
    It seems this is dynamically added to product pages, but I have a custom XML page/package so had to add it manually.

    Unfortunately for me, while that fixed the javascript error, the products aren't actually being added to the cart after posting. I don't have source code so I can't make the mods mentioned above. I'll reply if I figure it out.

    -matt

  8. #8
    maltschul is offline Junior Member
    Join Date
    May 2010
    Posts
    13

    Default

    I determined that the HandleAddToCart code was not in the page template I was using. I was using a topic page with (!XmlPackage Name="page.all-products.xml.config"!) as the topic content to pull in my custom xml package. This worked in v8 but I things changed when I upgraded to v9.

    Since, in my case, I was simply trying to create a custom page to list out certain products, I created a new category, added my products I wanted on the page to that category, then moved my XML package customizations to an entity.mycustompage.xml.config. The category page templates have the HandleAddToCart functionality included already. That also meant I didn't need to manually include the Products.js script anymore.

    This was my best option I found since I don't have source code. Hope it helps.