PlaceOrder2.aspx - set default country in dropdownlist

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
niall08
Commander (CMDR)
Commander (CMDR)
Posts: 175
Joined: Tue Dec 09, 2008 10:29 am

PlaceOrder2.aspx - set default country in dropdownlist

Post by niall08 » Wed Jul 29, 2009 9:04 am

How do you set the default country in the dropdown list when placing an order in the admin interface, PlaceOrder2.aspx

niall08
Commander (CMDR)
Commander (CMDR)
Posts: 175
Joined: Tue Dec 09, 2008 10:29 am

Re: PlaceOrder2.aspx - set default country in dropdownlist

Post by niall08 » Thu Jul 30, 2009 6:16 am

Any ideas?

Can/should it be set to the default warehouse location?

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

Re: PlaceOrder2.aspx - set default country in dropdownlist

Post by mazhar » Thu Jul 30, 2009 7:23 am

Well in 7.0.1 it seems that we are just picking the first available country in list. As for as 7.0.3 is concerned on checkout page we first try to locate the default country from within any available user address other wise we pick the default warehouse country.

niall08
Commander (CMDR)
Commander (CMDR)
Posts: 175
Joined: Tue Dec 09, 2008 10:29 am

Re: PlaceOrder2.aspx - set default country in dropdownlist

Post by niall08 » Thu Jul 30, 2009 7:32 am

Any suggestions about how to do it in 7.0.1?

e.g. in the Page_Load

Code: Select all

if (!Page.IsPostBack)
        {

            // INITIALIZE THE BILLING ADDRESS
            if (_Basket.User != null && !_Basket.User.IsAnonymous)
            {
                BindBillingAddress();
                BindShippingAddress();
            }
            else
            {
                CustomerLookupButton.Visible = true;
                BillToCountryCode.SelectedValue = "GB";
            }
            UpdateShipMethod();
        }

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

Re: PlaceOrder2.aspx - set default country in dropdownlist

Post by mazhar » Thu Jul 30, 2009 7:43 am

It could be something like below. I haven't tested it you can try it.

Code: Select all

// INITIALIZE THE BILLING ADDRESS
            if (_Basket.User != null && !_Basket.User.IsAnonymous)
            {
                BindBillingAddress();
                BindShippingAddress();
                
                ListItem defaultCountry1 = BillToCountryCode.Items.FindByValue(Token.Instance.Store.DefaultWarehouse.Country.CountryCode);
                defaultCountry1.Selected = true;

                ListItem defaultCountry2 = ShipToCountryCode.Items.FindByValue(Token.Instance.Store.DefaultWarehouse.Country.CountryCode);
                defaultCountry2.Selected = true;
            }
            else
            {
                CustomerLookupButton.Visible = true;
            }
            UpdateShipMethod();

niall08
Commander (CMDR)
Commander (CMDR)
Posts: 175
Joined: Tue Dec 09, 2008 10:29 am

Re: PlaceOrder2.aspx - set default country in dropdownlist

Post by niall08 » Thu Jul 30, 2009 8:15 am

Thanks Mazhar - I'd seen a reference to "DefaultWarehouse" as a means of setting the default CountryCode somewhere in the code, but I couldn't remember where.

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

Re: PlaceOrder2.aspx - set default country in dropdownlist

Post by mazhar » Thu Jul 30, 2009 8:19 am

Go to OnePageCheckout code, I think you will find something similar there.

Post Reply