Page 1 of 1

Change One Page Checkout to not default delivery address

Posted: Fri Mar 04, 2016 8:12 pm
by dandersonMLT
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

Re: Change One Page Checkout to not default delivery address

Posted: Wed Mar 09, 2016 12:51 am
by mazhar
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.

Re: Change One Page Checkout to not default delivery address

Posted: Wed Mar 09, 2016 4:44 am
by dandersonMLT
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

Re: Change One Page Checkout to not default delivery address

Posted: Wed Mar 09, 2016 4:46 am
by dandersonMLT
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;
                }
            }