Anonymous and registered cart synchronization

In my previous e-commerce travels, I've taken the easy way out.  Not this time.  Need to do better.

Say Mary comes to my site and adds two red balls, and a silver whistle to her cart.  She signs in to her account and starts the checkout process, but then her 2 year old starts screaming bloody murder.  She shuts down and vows to come back later.  Well later turns out to be 2 weeks.  When she comes back to my site, she remembers what she wanted - two red balls and a silver whistle.  So, she adds those to her cart and also finds a really nice erector set for her son.  She clicks checkout, which redirects her to log in.  Upon logging in, things can get interesting....

Her "registered" account already had two red balls and a silver whistle from 2 weeks ago.  So here are the options:

1) wipe out whatever was in her "registered" cart and migrate over her items that she just added when she was an anonymous shopper.

or 

2) merge everything together, taking special care to add in the matched items as well as the unmatched items.

The easy way (from a programmers perspective) is to dump the "registered" accounts cart and just add in the items when she was just an anonymous shopper.  No need to mix and match, just dump, add, and move right along.  This would work great in this case, because Mary remembered what she wanted and re-added those items.

If I were to play the mix and match game, she'd end up with 4 red balls, 2 silver whistles, and a cool erector set in her cart.  If she doesn't pay attention to the quantity textbox, she might overbuy on red balls and whistles and trigger a refund.  Of course I'd like to think that everybody pays attention to what's going on in their shopping cart, but things slip though unseen.   Happens to us all.

Now, I'm not a lazy programmer.  I strive to give the best shopping experience possible.  So I've got to do better.  I could merge all the items together and throw up a message telling the shopper that some quantities have changed.   Another idea is to only keep what the shopper has added to his/her cart during this session and *if* they just so happen to click on the shopping cart image/link, then throw up a "hey you have items from a previous visit, would you like to keep them? "   I kind of like that idea, I can ask before doing an auto-merge.  That's simple enough.  But I have to give the shopper a great UX to go with my great prices so they keep coming back.

Of course, this is just one scenerio.   If you store cookies on the users machine, you could find the cookie and then hit the shopping cart table and automatically bring in any existing items.   I'm sure there are lots more crazy things people do and have done to them (think crashes).   So this is what I'm trying to think about today.  I think I'll jump on some sites today and see if I can find something cool I have not thought of.  After all, I know my competition does this to me :)

Any great ideas out there?

VS2010 beta 1 is here

VS2010 beta 1 and .net fx 4 ships!  I just downloaded it from MSDN.  Going to open up a project and see how it goes.

Here is a link for a first look of Visual Studio 2010

Linq to SQL insert SqlDateTime overflow

In my new e-commerce site, I am using Linq to SQL.  In all my tables I have modfiedOn and createdOn datetime columns.  When clicking on my "add to cart" button, I want to insert the items into my OrderItem table, but I kept on getting "SqlDateTime overflow.  Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.  These are set to automatically get the current utc date in my database upon insert like they've always been in the past, so I didn't see a problem.   But when stepping through my code, I noticed that these are set to a low value date of 1/1/0001 and sent into the database that way.   Ok, starting to make sense, so I set these dates myself through code and it worked, but why should I have to do that?

I played around with the "dbml" designer and found a property called "Auto Generated Value".  The description sounded just like what I wanted, "Value is auto-generated in database on insert".  Perfect, so I set both of these properties to true, recompiled, and problem solved.

 

TweetDeck on Windows 7 - where are you?

I just downloaded TweetDeck and signed in.   There is a problem that I just figured out how to solve.  The TweetDeck icon appears in the taskbar, but TweekDeck is nowhere to be found.  I am running a dual monitor setup and maybe that has something to do with it, but if you hover over the icon in the taskbar, and then right-click on the preview window that pops up, you gain access to the context menu that allows you to move.  Click move, then press shift-Up arrow and then grab your mouse while still holding the shift key down.  There it is!  Apparently it opens up way off the screen.  I hope they fix this soon.   This is the only Adobe Air app I have ever used...I wonder if they're all like that?   I need to find a good WPF/Silverlight client - I used Witty in the past, but as cool as it is/was, it did crash occasionally.

I'm now on Windows 7 RC

 

I'd been running Windows 7 beta 1 on our "home" pc since it came out.  I didn't want to touch my dev machine until Win 7 was more complete and ready to roll.  Now that Windows 7 RC is out, I thought I'd give it a shot on my main development machine.  After making a backup using Acronis 2009 Home, I booted from my newly downloaded Windows 7 RC DVD, the 64 bit version, formatted the drive, and installed the Ultimate edition.  Vista had a nice install, but this one is even better, and faster too.  One of my favorite things is that it recognizes you have a wireless connection and asks you to connect *during* the installation.  Not after!  So it was able to download the latest bits and apply then right away.

It only took a few minutes and then was there was a lot of praying to make sure all my critical apps would 1) a version that works with Win 7 x64, 2) install and 3) actually work.  The main thing I was concerned about was my SonicWall VPN client.  After a little searching, I found a 64 bit beta client that installed and worked flawlessly.  Joy!  Next, my dev stack -  VS2008/SQL2008/Blend 2/Resharper 4.5/VisualSVN.  I knew from attending DevConnections and seeing Scott Guthrie and some of the other Microsofties that VS2008/SQL2008 would run fine on Win 7.  After a lengthy install, including service packs, those were up and running.  Next was Subversion/TortoiseSVN.  Flawless!  Joy again.  

Now, I occasionally need to maintain a .NET 1.1 web site, so I have been using Sun's excellent VirtualBox to run a Windows XP virtual machine from which I use VS2003.  Flawless install on Windows 7 RC and it runs great.

All my bread and butter apps were working just fine but them I remembered Microsoft Office.  I had no fear there, why would Office 2007 not work...well I've seen strange things before, but luckily that was a flawless install.  So now I have my email working.  Good to go.  Antivirus - how could I forget.  I downloaded Eset Nod32, the 64 bit version, and that went off without a hitch.

Lastly, I need to make money, so Quickbooks was on tap.  I have the latest 2009 version, and that was uneventful. 

So, now after a day of downtime, I am back in action.  I must say that my experience so far is very pleasant.  Windows 7 is a much improved, less intrusive, gorgeous OS.  Dual monitor support is better, the taskbar is nicer and less cluttered, and I just love the "shake" where you grab and window, shake it quickly, and it minimizes all others.   And drag a window to the left, right, and top of the screen.  Docking!  Love it.  More to report as I start using it more and more.  If there are any problems, I'll post here.

Subversion Hosting Revisited

My experiment with ProjectLocker.com has just ended.  They just couldn't get my trac instance set up right (all I want is email notifications!) and they only respond to your tickets when you pay them a buck for priority service.  So, since I'm within the 30 day window, I've asked for a refund.  I've instead signed onto Unfuddle.com and while they don't do trac, what they do have is simply brilliant.   I haven't needed to bug the support team, everything just works.  And it's fast!  They have a ticket system, message boards, milestones, and of course SVN and Git.  They have a pretty nice dashboard to manage your projects/repositories.   Of course it's all based on what service level you purchase.  So far, so good. More to come as I work with it more and get my team on board. 

 UPDATE: After two emails to ProjectLocker support, I did get my refund.  I did not however get refunded for the extra buck I had to pay to get my trac instance imported.  Oh well :(

MySQL for the ASP.NET and SQL Server developer

For a recent project, I was asked to create a ASP.NET web page, but use MySQL instead of SQL Server.  I have been using SQL Server since version 7.0 and have never used MySQL.  Let me sum up my experience with one word....excellent!  I went into the process knowing nothing and within a half hour, I had a new database created and I was writing C#.  The following steps are what I did, mostly for my future reference, but for anyone who is in my boat.

1.  A google search provided me with a link to the MySQL download page.  The current version is 5.1 and I downloaded the Windows MSI Installer (x86):

http://dev.mysql.com/downloads/mysql/5.1.html#win32

for x64, go here: http://dev.mysql.com/downloads/mysql/5.1.html#winx64

2.  Download and start it up.  I accepted all the defaults.

3. Get the MySQL GUI Tools here:

http://dev.mysql.com/downloads/gui-tools/5.0.html

4. For .NET development, you need the Connector/Net 6.0 tools:

http://dev.mysql.com/downloads/connector/net/6.0.html

Once you have that installed, you can open up the MySQL Administrator tool and log in.  By default, the server host is "localhost", the username is "root", and the password is whatever you set it to be.

Now you can open up Visual Studio 2008.  In your project, you are going to need a reference to MySql.Data so you can access MySQL.   And you'll need a ConnectionString.

<connectionStrings>
     <
add name="MyConnection" connectionString="SERVER=localhost;DATABASE=MyDatabase;UID=root;PASSWORD=sa;"/>
</
connectionStrings>

Once you've done that, you can write some ADO.NET code, just like you'd do with SQL Server.  Here is some code to return a MySqlDataReader from a query to a MySQL database: 

MySqlConnection connection = new MySqlConnection(ConnectionString);
MySqlCommand command = connection.CreateCommand();
command.CommandText = "select * from sometable where something= @Parameter";
command.Parameters.AddWithValue(
"@Parameter", somevalue);
connection.Open();
MySqlDataReader reader = command.ExecuteReader();

while (reader.Read())
{
     // Do something with the reader
}

connection.Close();

Happy programming!

A great reference I used to get started is heret http://www.globalnerdy.com/2009/05/04/installing-mysql-server-51-on-windows/