Change One Page Checkout to not default delivery address

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
dandersonMLT
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 95
Joined: Sun Oct 04, 2015 5:45 pm

Change One Page Checkout to not default delivery address

Post by dandersonMLT » Fri Mar 04, 2016 8:12 pm

When checking out as a guest One Page Checkout will first prompt the user for the billing address.
After postback, the page will refresh with the "This is also my delivery address" Checkbox checked.

If the user unchecks this checkbox, they are prompted to enter a delivery address.

I'd like to reverse this so that by default the user is prompted to enter a delivery address with the checkbox unchecked.
If the user wants to user the same delivery address, they could simply check the checkbox.
We are having too many customer not notice this checkbox and accidentally send orders to their billing address.

How could I accomplish this?

I am using R10.

Thanks,
Dave

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

Re: Change One Page Checkout to not default delivery address

Post by mazhar » Wed Mar 09, 2016 12:51 am

Edit Website/Checkout/OPC.aspx.cs file and locate following code.

Code: Select all

UseBillingAsShippingAddress.Checked = (shipment.Address.Id == _user.PrimaryAddress.Id);
and update it like

Code: Select all

UseBillingAsShippingAddress.Checked = false; //(shipment.Address.Id == _user.PrimaryAddress.Id);
Save the changes and try again. Perform some tests to make sure every thing is working as expected.

dandersonMLT
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 95
Joined: Sun Oct 04, 2015 5:45 pm

Re: Change One Page Checkout to not default delivery address

Post by dandersonMLT » Wed Mar 09, 2016 4:44 am

That was my first thought as well, however that line in in a if(!Page.IsPostBack) block which is inside another if(shipment.address.IsValid) block so it is never hit.
The first time the page loads shipment.address.isvalid is false so it never enters the block.
After billing address is entered, this value is true, but it is now Page.IsPostBack is true, so it never enters the block.

Therefore, the UseBillingAddressAsShippingAdress box is still checked.

Thanks,
Dave

dandersonMLT
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 95
Joined: Sun Oct 04, 2015 5:45 pm

Re: Change One Page Checkout to not default delivery address

Post by dandersonMLT » Wed Mar 09, 2016 4:46 am

This is the logic:

Code: Select all



if (shipment != null && shipment.Address != null && shipment.Address.IsValid)
            {
                SetFormattedShipAddress(shipment.Address);

                if (!Page.IsPostBack)
                {
                    UseBillingAsShippingAddress.Checked = (shipment.Address.Id == _user.PrimaryAddress.Id);
                }

                if (shipment.AddressId == _user.PrimaryAddress.Id)
                {
                    ShippingAddressTextPanel.Visible = false;
                }
            }

Post Reply