Multiple Page Checkout

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
msalman
Ensign (ENS)
Ensign (ENS)
Posts: 14
Joined: Tue Jan 27, 2009 2:10 pm

Multiple Page Checkout

Post by msalman » Mon Feb 02, 2009 4:56 pm

Our client does not want to have a one page checkout.
Instead they want to have the payment information moved to a new page that shows a summary of the customer order and display the payment methods.
So basically one page checkout page should have a continue button that should redirect the user to the payment page where they can view a summary of the order, select a payment method and place the order.

I found Conlib/PaymentPage.ascx to be doing a similar thing. It displays a summary of customer order and the payment methods. I initially thought to just add a button to this page that would redirect to the payment page on the click event but then I figured out that in case of anonymous users, one page checkout control is also firing logic to create a new user. If I just redirect the user to the payment page, the logic to create a new customer won't be fired. I customized the code a bit to take into account this aspect. The problem that is trobling me now is that once the new user is created, the basket shipment information is not getting updated for the new user. I thought the line of code "User.Migrate(oldUser, newUser, true);" in the function "CheckedOut" would migrate all the basket information of the anonymous user to the new user but it's not doing that. When I redirect to payment page, I cannot see the shipment information at all.

I might be able to do what I want by adding some more custom code but I would like to find out if Able-Commerce has any recommended way for this scenario.

Thanks.

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

Re: Multiple Page Checkout

Post by mazhar » Tue Feb 03, 2009 7:23 am

It should work, A few days back I wrote some code for a forum post available here
viewtopic.php?f=44&t=9561
I used Basket class's Transfer method and it worked great. Something like

Code: Select all

Basket.Transfer(userId, Token.Instance.User.UserId)
You can give a try to this as well.

msalman
Ensign (ENS)
Ensign (ENS)
Posts: 14
Joined: Tue Jan 27, 2009 2:10 pm

Re: Multiple Page Checkout

Post by msalman » Tue Feb 03, 2009 9:51 am

I have looked into this example and tried it but Basket.Transfer just copies the basket information for the new user which "User.Migrate" is already doing. It does not copies over the shipment information which I require on the payment page. I have done something like the following to achieve what I want. I would like to have a review of this code.
After the following lines of code in Conlib/OnePageCheckout.ascx.cs

User.Migrate(oldUser, newUser, true);
Token.Instance.InitUserContext(newUser);

I added the following

BasketShipment shipment = new BasketShipment();
shipment.BasketId = oldUser.Basket.Shipments[0].BasketId;
shipment.WarehouseId = oldUser.Basket.Shipments[0].WarehouseId;
shipment.ShipMethodId = oldUser.Basket.Shipments[0].ShipMethodId;
shipment.AddressId = oldUser.Basket.Shipments[0].AddressId;
shipment.ShipMessage = oldUser.Basket.Shipments[0].ShipMessage;
shipment.Save();

string sql = String.Format("update ac_BasketItems set basketShipmentId = {0} where basketId = {1}", shipment.BasketShipmentId, shipment.BasketId);
Microsoft.Practices.EnterpriseLibrary.Data.Database database = Token.Instance.Database;
database.ExecuteNonQuery(CommandType.Text, sql);


So all I am doing is that once the new user is created and his basket is updated(User.Migrate), I add a shipment record based on the shipment information of the old(anonymous) user and then I update the BasketShipmentId I just created in the "ac_BasketItems" table. After the basket shipment is created for the new user, I redirect to payment page and the payment page(Conlib/PaymentPage.ascx) now displays the shipment information.

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: Multiple Page Checkout

Post by sohaib » Tue Feb 03, 2009 10:04 am

All you need to do in order to enable multi page checkout is to set the content scriptlet of the Checkout/Default.aspx page to 'Checkout Page with Login'.

msalman
Ensign (ENS)
Ensign (ENS)
Posts: 14
Joined: Tue Jan 27, 2009 2:10 pm

Re: Multiple Page Checkout

Post by msalman » Tue Feb 03, 2009 10:28 am

This is helpful but not fits my situation. This multiple page checkout forces the users to create an account and fill in their shipping information before proceeding to checkout. We do not want to force the user to create an account before proceeding to checkout. The one page checkout that I am using is still good enough as it allows anonumous checkout. I just want to take the payment option out of that page and redirect the users to a payment page and the payment page should display them a summary of the order and the payment options.

Post Reply