First, let me say how much I appreciate the prompt, thoughtful responses Scott provides in these forums. Your service is excellent.
This post is long and detailed, because I need to explain exactly what the problem is. I have spent a lot of time testing this, and my results partially contradict the scenarios Scott described. Before jumping into the detail, here's the executive summary. The cart settings are:
General Cart Setup: Show Login Screen – checked.
Confirmation Page Setup (Before Payment): Require Login: checked; Hide Login and Password: checked.
if a first-time visitor registers on the Welcome screen of the checkout sequence, everything is fine. But if a first-time visitor registers using the normal DNN skin "Register" link at the top of the page, the cart is broken, and will spawn new CustomerIDs every time that user places an order.
Here's the detailed walk-through:
Smith.BuyNow Settings
General Cart Setup: Show Login Screen – checked.
Confirmation Page Setup (Before Payment): Require Login: checked; Hide Login and Password: checked.
Scenario A – new user – registers during checkout process.
A.1 – first time at site.
1. Hit site. Do not log in.
2. Add item to cart. Checkout, Checkout.
3. Welcome screen. Create an Account / Sign in to Your Account – all fields blank.
4. Fill in username of abc, password, and confirm password. Continue.
6. On Pay screen, supply valid CC information. Next.
7. On Confirm screen, everything looks fine. Click Submit Order.
8. Thank You! Your order is confirmed. Order ID: 21. Shipping and billing information all as entered earlier. Close.
9. Logout.
In Smith_StoreOrders table, there is a new row with OrderID = 21, CustomerID = 13 (new), shipping info correct.
In Smith_Customers table, new row CustomerID = 13, DNNLogin = abc. Note: this is correct: it is not the email address. The email address is correctly recorded in the Smith_Customers.Email field.
In Users table, new row, UserID = 10, Username = abc. Blanks for FIrstName, LastName, and Email fields.
A.2 – subsequent visit to site.
Restarted IIS on the server. Logged off and logged back onto workstation PC.
1. Hit site. Logged in with username abc before using cart.
2. Add item to cart. Checkout, checkout.
3. Ship screen – all fields correctly populated.
4. On Pay screen, provide valid CC information. Next.
5. Confirm screen looks fine (no login area showing). Submit Order.
6. Thank you. Order ID: 22.
7. Logout
Smith_StoreOrders table, new row OrderID = 22, CustomerID = 13 (correct). Other fields identical to previous row.
Smith_Customer table – no new row, values unchanged for CustomerID = 13. Users table, no new row, values unchanged for UserID = 10.
Scenario B – new user, registers before using cart
B.1 – First time at site
1. Hit site. Click Register.
2. User Name: xyz
3. First name: Xerxes, Last Name: Zapata, Display name: Xerxes Zapata, email:
xyz@myofficetraining.com (a valid email address), provided password.
4. Click Register. DNN skin shows correct user name (Xerxes Zapata) at the top.
5. Add to cart, Checkout, Checkout.
7. Filled in other fields, Next.
8. Filled in CC info. Next, Submit Order.
9. On Confirm screen, everything looks fine. Click Submit Order.
10. Thank you. Order ID: 23
11. Logout.
Smith_StoreOrders, new row, OrderID = 23. CustomerID = 14 (new). Ship info correct.
Smith_Customer table, new row CustomerID = 14. DNNLogin =
xyz@myofficetraining.com. This is wrong. The user was a registered site user (steps 1 – 4). The DNNLogin should have been
xyz.
Users table, new row UserID = 11, all fields populated as per registration sequence. Username = xyz, email =
xyz@myofficetraining.com.
B.2 – Subsequent visit to site.
Restarted IIS on the server. Logged off and logged back onto workstation PC.
1. Hit site. Logged in with username xyz before using cart. DNN skin shows correct user name (Xerxes Zapata) at the top.
2. Add item to cart. Checkout, checkout.
3. Ship screen – Only First Name, Last Name and Email are pre-populated. Had to fill in address, city, etc. Why didn’t it remember this from last time?
4. On Pay screen, provide valid CC information. Next.
5. Confirm screen looks fine. Submit Order.
6. Thank you. Order ID: 24.
7. Logout
Smith_StoreOrders, new row OrderID = 24. CustomerID = 15 (!). This is wrong. It should be CustomerID 14. The code has created a new customer when it should have used the existing customer 14.
Smith_Customer, new row CustomerID = 15. DNNLogin =
xyz@myofficetraining.com. Note: all the fields for CustomerID 15 are identical to CustomerID 14.
B.3 – A third visit to the site by user xyz
Restarted IIS on the server. Logged off and logged back onto workstation PC.
1. Hit site. Logged in with username xyz before using cart. DNN skin shows correct user name (Xerxes Zapata) at the top.
2. Add item to cart. Checkout, checkout.
3. Ship screen – Only First Name, Last Name and Email are pre-populated. Had to fill in address, city, etc. Why didn’t it remember this from last time?
4. On Pay screen, provide valid CC information. Next.
5. Confirm screen looks fine. Submit Order.
6. Thank you. Order ID: 25.
7. Logout
Smith_StoreOrders, new row OrderID = 25. CustomerID = 16 (!). ARRGGHH! The code is creating a new customer every time xyz buys something having first logged into the site.
Smith_Customer, new row CustomerID = 16. DNNLogin =
xyz@myofficetraining.com. Note: all the fields for CustomerID 16 are identical to CustomerID 15 and 14.
B.4 – A fourth visit to the site by user xyz
Restarted IIS on the server. Logged off and logged back onto workstation PC.
This time, user xyz won’t log in until the shopping sequence has begun.
1. Hit site. Did NOT log in before using cart.
2. Add item to cart. Checkout, checkout.
3. Welcome screen. Create an Account and Sign In to Your Account panels have blank fields. Filled in the Sign In to Your Account UserName = xyz, password, clicked Sign In. DNN skin shows correct user name (Xerxes Zapata) at the top.
4. Ship screen – Only First Name, Last Name and Email are pre-populated. Had to fill in address, city, etc.
5. On Pay screen, provide valid CC information. Next.
6. Confirm screen looks fine. Submit Order.
7. Thank you. Order ID: 26.
8. Logout
Smith_StoreOrders, new row OrderID = 26. CustomerID = 17 (!). The code has again created a new customer.
Smith_Customer, new row CustomerID = 17. DNNLogin = xyz (!!!) Somehow, the code has recognized the Users.Username value for the logged in user when the user logs in at the cart Welcome screen, but does not pick it up if the user logs in via the usual DNN skin Login link before starting a buying sequence.
I repeated B3 (log in before shopping sequence) for this same user to see if the cart would recognize the user and stop generating new Customers. This time the Ship screen was fully populated (a good sign). Sure enough, the new orderID = 27 uses CustomerID 17 – the same one as last time. By loggin in during the checkout sequence, the problem has been cured.
Conclusions
Scenario A works. If a first time visitor registers during the checkout sequence, then the code recognizes that customer properly on future visits, and does not generate bogus new customers. But the code ought to populate the Users table with the user’s first name, last name and email address. This is not fatal, but if the user later goes in edits their profile, they might be surprised to see that they have no name or email address.
Scenario B is broken. If a first-time visitor registers before starting a shopping sequence, the cart will spawn a new customer ID for that user every time they place an order. The only way out of this is for the user to hit the site, do not log in, start shopping, and log in on the Welcome page of the checkout sequence. This cures the problem, and the cart will recognize the user correctly henceforth.
This is a problem for any site that provides extra content for logged in users. The user will normally go to the site, log in, then start using the site. At some point, they decide to buy something. Having already logged in, the cart will fail to recognize the returning customer, and will create a bogus new customer every time the user orders something.
The bug appears to be related to how the code populates the DNNLogin field. If a user is logged into the DNN site by the time the order is completed, the code should use the Users.Username value, which is easily available via the DNN framework. It should not matter when the user logs in – log in before shopping, registers during shopping, or log in during shopping. When the cart completes the order, it should simply ask the DNN framework for the logged in Username, and use that. The only time it should use an email address for the DNNLogin value would be when the site owner has configured the cart to allow shopping by non-registered visitors.