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
Change One Page Checkout to not default delivery address
-
- Lieutenant Commander (LCDR)
- Posts: 95
- Joined: Sun Oct 04, 2015 5:45 pm
Re: Change One Page Checkout to not default delivery address
Edit Website/Checkout/OPC.aspx.cs file and locate following code.
and update it like
Save the changes and try again. Perform some tests to make sure every thing is working as expected.
Code: Select all
UseBillingAsShippingAddress.Checked = (shipment.Address.Id == _user.PrimaryAddress.Id);
Code: Select all
UseBillingAsShippingAddress.Checked = false; //(shipment.Address.Id == _user.PrimaryAddress.Id);
-
- Lieutenant Commander (LCDR)
- Posts: 95
- Joined: Sun Oct 04, 2015 5:45 pm
Re: Change One Page Checkout to not default delivery address
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
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
-
- Lieutenant Commander (LCDR)
- Posts: 95
- Joined: Sun Oct 04, 2015 5:45 pm
Re: Change One Page Checkout to not default delivery address
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;
}
}