Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 by Chris Hart, John Kauffman, David Sussman, Chris Ullman; ISBN: 9780764588501
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 12th, 2007, 10:26 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 13 Shopping Cart disappears after login

I'm wondering if anybody knows how to fix the shopping cart code to remember the anonymous shopping cart details after registering and logging in? When you aren't logged in, and add items to the cart and then log in, the cart items are gone. Thanks in advance.

BTW-It is from the VB code.
Reply With Quote
  #2 (permalink)  
Old June 14th, 2007, 12:34 PM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just in case anybody else runs into the same problem. I found the bug in the Wrox United code that doesn't migrate the Anonymous cart profile to the Authenticated User. In the "Full Application" there is a Global.asax file that migrates the Anonymous user.

EXISTING CODE...

Public Sub Profile_OnMigrateAnonymous(ByVal Sender As Object, ByVal e As ProfileMigrateEventArgs)

        ' get the profile for the anonymous user
        Dim anonProfile As ProfileCommon = Profile.GetProfile(e.AnonymousID)

        ' if they have a shopping cart, then migrate that to the authenticated user
        If anonProfile.Cart IsNot Nothing Then

            If Profile.Cart Is Nothing Then
                profile.Cart = New Wrox.Commerce.ShoppingCart()
                profile.Cart.Items.AddRange(anonProfile.Cart.Items )
            end if

            anonProfile.Cart = Nothing
        End If

        ProfileManager.DeleteProfile(e.AnonymousID)
        AnonymousIdentificationModule.ClearAnonymousIdenti fier()

    End Sub

MODIFIED CODE...


Public Sub Profile_OnMigrateAnonymous(ByVal Sender As Object, ByVal e As ProfileMigrateEventArgs)

        ' get the profile for the anonymous user
        Dim anonProfile As ProfileCommon = Profile.GetProfile(e.AnonymousID)

        ' if they have a shopping cart, then migrate that to the authenticated user
        If anonProfile.Cart IsNot Nothing Then

            profile.Cart.Items.AddRange(anonProfile.Cart.Items )

            If Profile.Cart Is Nothing Then
                profile.Cart = New Wrox.Commerce.ShoppingCart()
                profile.Cart.Items.AddRange(anonProfile.Cart.Items )
            end if

            anonProfile.Cart = Nothing
        End If

        ProfileManager.DeleteProfile(e.AnonymousID)
        AnonymousIdentificationModule.ClearAnonymousIdenti fier()

    End Sub

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 Shopping Cart michaelcode BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 9 January 25th, 2010 02:50 AM
Chapter 13: shopping cart problem mysecondlove BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 April 9th, 2008 06:48 PM
Ch.13 Builing a Shopping Cart seannie BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 3 February 7th, 2007 09:11 AM
Shopping Cart Script in Chapter 15 groovybaz PHP How-To 4 June 7th, 2006 08:21 AM



All times are GMT -4. The time now is 02:40 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.