Radio Button List for Shipping Methods on One Page Checkout

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
Richard47
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 47
Joined: Thu Nov 04, 2010 1:15 pm

Radio Button List for Shipping Methods on One Page Checkout

Post by Richard47 » Mon Dec 03, 2012 6:05 pm

Has anyone setup a Radio Button List for Shipping Methods on One Page Checkout on the Gold version yet. I know someone came up with one on the 7xx version.

Thanks in advance
Richard
www.somethingmorestore.com

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Radio Button List for Shipping Methods on One Page Checkout

Post by AbleMods » Thu Dec 13, 2012 8:54 am

Able Gold no longer has a 'One Page Checkout'. The checkout in Gold is now broken up into separate pages, so it's much easier to make changes such as this one.

First, find the /Checkout/ folder in your site and edit the ShipMethod.aspx file. Find this line of code:

Code: Select all

<asp:DropDownList ID="ShipMethodsList" runat="server" DataValueField="Key" DataTextField="Value"></asp:DropDownList>
and change it to look like this:

Code: Select all

<asp:RadioButtonList ID="ShipMethodsList" runat="server" DataValueField="Key" DataTextField="Value"></asp:RadioButtonList>
Now save the file. The next step is to change the programming code for this page. Find the ShipMethod.aspx.cs file in the same /Checkout/ folder. Edit the file and find this code:

Code: Select all

        protected void ShipmentRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //CAST DATA ITEM
            BasketShipment shipment = (BasketShipment)e.Item.DataItem;
            
            //UPDATE SHIPPING WEIGHT
            Literal shipWeight = (Literal)e.Item.FindControl("ShipWeight");
            if (shipWeight != null)
            {
                shipWeight.Text = string.Format(weightFormat, shipment.Items.TotalWeight());
            }
            //SHOW SHIPPING METHODS            
            DropDownList ShipMethodsList = (DropDownList)e.Item.FindControl("ShipMethodsList");
Now replace that code with this code:

Code: Select all

        protected void ShipmentRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //CAST DATA ITEM
            BasketShipment shipment = (BasketShipment)e.Item.DataItem;
            
            //UPDATE SHIPPING WEIGHT
            Literal shipWeight = (Literal)e.Item.FindControl("ShipWeight");
            if (shipWeight != null)
            {
                shipWeight.Text = string.Format(weightFormat, shipment.Items.TotalWeight());
            }
            //SHOW SHIPPING METHODS            
            // BEGIN MOD:  AbleMods.com
            // 12/13/2012
            // use radio buttons for ship methods
            RadioButtonList ShipMethodsList = (RadioButtonList)e.Item.FindControl("ShipMethodsList");
            // END MOD: AbleMods.com
Once that is done, we have one more change to make in the same file. Find this code:

Code: Select all

        protected void ContinueButton_Click(object sender, EventArgs e)
        {
            //LOOP SHIPMENTS, GET SHIPPING METHODS
            Basket basket = AbleContext.Current.User.Basket;
            IList<BasketShipment> shipments = basket.Shipments;
            _ShipmentIndex = 0;
            bool allMethodsValid = true;
            foreach (BasketShipment shipment in shipments)
            {
                // shipment.ShipMethod = ShipMethodDataSource.Load(AlwaysConvert.ToInt(Request.Form["ShipMethod" + _ShipmentIndex]));
                DropDownList ShipMethodsList = ShipmentRepeater.Items[_ShipmentIndex].FindControl("ShipMethodsList") as DropDownList;
and replace it with this code:

Code: Select all

        protected void ContinueButton_Click(object sender, EventArgs e)
        {
            //LOOP SHIPMENTS, GET SHIPPING METHODS
            Basket basket = AbleContext.Current.User.Basket;
            IList<BasketShipment> shipments = basket.Shipments;
            _ShipmentIndex = 0;
            bool allMethodsValid = true;
            foreach (BasketShipment shipment in shipments)
            {
                // shipment.ShipMethod = ShipMethodDataSource.Load(AlwaysConvert.ToInt(Request.Form["ShipMethod" + _ShipmentIndex]));
                // BEGIN MOD:  AbleMods.com
                // 12/13/2012
                // Use radio buttons for ship methods
                RadioButtonList ShipMethodsList = ShipmentRepeater.Items[_ShipmentIndex].FindControl("ShipMethodsList") as RadioButtonList;
                // END MOD: AbleMods.com
Now save the file and test your page. You should be all set!
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Richard47
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 47
Joined: Thu Nov 04, 2010 1:15 pm

Re: Radio Button List for Shipping Methods on One Page Checkout

Post by Richard47 » Thu Dec 13, 2012 9:21 am

This works like a Champ Joe. Thanks a bunch.

Richard
www.somethingmorestore.com

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Radio Button List for Shipping Methods on One Page Checkout

Post by AbleMods » Thu Dec 13, 2012 9:25 am

Glad to be of help.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
compunerdy
Admiral (ADM)
Admiral (ADM)
Posts: 1283
Joined: Sun Nov 18, 2007 3:55 pm

Re: Radio Button List for Shipping Methods on One Page Checkout

Post by compunerdy » Mon Feb 11, 2013 2:32 pm

There is one issue with this..

If no shipping method is selected and you click continue the order item images, etc get all messed up on the page. This is not noticeable on the drop down because a shipping method is always selected.

Richard47
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 47
Joined: Thu Nov 04, 2010 1:15 pm

Re: Radio Button List for Shipping Methods on One Page Checkout

Post by Richard47 » Tue Feb 12, 2013 2:46 pm

hmm you are correct. Hope there is a better fix than setting a default as this kinda defeats the whole purpose of the radio button.
People just do not read.
Richard

ChipWV
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 88
Joined: Tue Feb 03, 2009 12:51 pm

Re: Radio Button List for Shipping Methods on One Page Checkout

Post by ChipWV » Wed Feb 13, 2013 9:11 am

When Joe set this up for me in our 7.06 store, we had the default set to the cheapest valid method. If the customer flew through the checkout process without reading, they would get the cheapest method. If they paid attention, and preferred a different method, it was opt in to pay for a more expensive method. This has work well for us over the past year and a half that we've been using it.

I have requested this as a feature or improvement in AC Gold to be the default display for shipping. If you'd like this feature add your vote on this thread:
viewtopic.php?f=45&t=16951

Thanks
Chip
http://www.OVISonline.com

Post Reply