private void PopulateForm()
        {
            AddressInfo address = checkoutOrderInfo.BillingAddress;

            if (address.NameFieldsAreEmpty && UserId > 0)
            {
                address.FirstName = UserInfo.FirstName;
                address.LastName  = UserInfo.LastName;
                address.Email     = UserInfo.Email;
            }
            if (address.AddressFieldsAreEmpty && UserId > 0)
            {
                address.Telephone = UserInfo.Profile.Telephone;

                address.Address1   = UserInfo.Profile.Street;
                address.Address2   = UserInfo.Profile.Unit;
                address.City       = UserInfo.Profile.City;
                address.Region     = UserInfo.Profile.Region;  // DNN seems to use full region name instead of abbreviation
                address.PostalCode = UserInfo.Profile.PostalCode;
                address.Country    = UserInfo.Profile.Country; // DNN seems to use full country name here

                // try to look up the Country Code based on the Country Name
                List <ListItem> countryListItems = DnnHelper.GetCountryListItems();
                ListItem        countryItem      = countryListItems.Find(c => c.Text == UserInfo.Profile.Country);
                if (countryItem != null)
                {
                    address.Country = countryItem.Value;
                }

                // try to look up the Region Code based on the Region Name
                List <ListItem> regionListItems = DnnHelper.GetRegionListItems(address.Country);
                ListItem        regionItem      = regionListItems.Find(r => r.Text == UserInfo.Profile.Region);
                if (regionItem != null)
                {
                    address.Region = regionItem.Value;
                }
            }

            //--- Set a default country
            string defaultCountry = StoreContext.CurrentStore.GetSetting(StoreSettingNames.DefaultCountryCode);

            if (string.IsNullOrEmpty(address.Country) && !string.IsNullOrEmpty(defaultCountry))
            {
                address.Country = defaultCountry;
            }

            chkCopyBillingAddress.Checked = checkoutOrderInfo.ShipToBillingAddress.GetValueOrDefault(false);
            chkCopyBillingAddress.Visible = !checkoutOrderInfo.HasOnlyDownloadableProducts;
            lblCopyBilling.Visible        = chkCopyBillingAddress.Visible;

            //--- Set the fields on the form
            billingAddressForm.SetAddressInfo(address);
        }
예제 #2
0
        protected void Page_Init(object sender, EventArgs e)
        {
            ControlPrefix = this.ID + "_";

            if (!IsPostBack)
            {
                //ddlRegion.Items.Clear();
                //ddlRegion.Items.Add(new ListItem() { Text = "-- Choose a Country --", Value = "" });
                litRegionCodeOptions.Text = @"<option value="""">--- Choose a Country ---</option>";

                SetCountryListItems(DnnHelper.GetCountryListItems());
            }
        }
        private void LoadStoreSettings()
        {
            DataModel.Store store = StoreContext.CurrentStore;

            txtStoreName.Text = store.Name;
            txtOrderCompletedEmailRecipient.Text = store.GetSetting(StoreSettingNames.OrderCompletedEmailRecipient);
            txtCustomerServiceEmail.Text         = store.GetSetting(StoreSettingNames.CustomerServiceEmailAddress);
            txtOrderNumberPrefix.Text            = store.GetSetting(StoreSettingNames.OrderNumberPrefix);

            ddlDefaultCountryCode.Items.Clear();
            ddlDefaultCountryCode.Items.AddRange(DnnHelper.GetCountryListItems().ToArray());
            ddlDefaultCountryCode.Items.Insert(0, "");
            ddlDefaultCountryCode.TrySetSelectedValue(store.GetSetting(StoreSettingNames.DefaultCountryCode));

            ddlCurrency.Items.Clear();
            ddlCurrency.Items.AddRange(CurrencyCollection.All().Select(x => new ListItem()
            {
                Value = x.Code, Text = string.Format("{0} - {1}", x.Code, x.Description)
            }).ToArray());
            ddlCurrency.Items.Insert(0, new ListItem());
            ddlCurrency.SelectedValue = store.GetSetting(StoreSettingNames.CurrencyCode);

            string ccTypes = store.GetSetting(StoreSettingNames.AcceptedCreditCards) ?? string.Empty;

            if (string.IsNullOrEmpty(ccTypes))
            {
                chklAcceptedCreditCards.SetAllSelected();
            }
            else
            {
                string[] ccTypesArray = ccTypes.Split(',');
                chklAcceptedCreditCards.SetSelectedValues(ccTypesArray);
            }

            chkLoadJQueryUi.Checked = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.IncludeJQueryUi)).GetValueOrDefault(true);

            // Store Location / Address
            txtStorePhone.Text      = store.GetSetting(StoreSettingNames.StorePhoneNumber);
            txtStoreStreet.Text     = store.GetSetting(StoreSettingNames.StoreAddressStreet);
            txtStoreCity.Text       = store.GetSetting(StoreSettingNames.StoreAddressCity);
            txtStoreRegion.Text     = store.GetSetting(StoreSettingNames.StoreAddressRegion);
            txtStorePostalCode.Text = store.GetSetting(StoreSettingNames.StoreAddressPostalCode);
            ddlStoreCountryCode.Items.Clear();
            ddlStoreCountryCode.Items.AddRange(DnnHelper.GetCountryListItems().ToArray());
            ddlStoreCountryCode.Items.Insert(0, "");
            ddlStoreCountryCode.TrySetSelectedValue(store.GetSetting(StoreSettingNames.StoreAddressCountryCode));

            chkCheckoutAllowAnonymous.Checked        = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.CheckoutAllowAnonymous)).GetValueOrDefault(true);
            chkCheckoutShowCreateAccountLink.Checked = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.CheckoutShowCreateAccountLink)).GetValueOrDefault(true);

            chkTaxShipping.Checked = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.TaxShipping)).GetValueOrDefault(true);

            chkSendPaymentCompleteEmail.Checked = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.SendPaymentCompleteEmail)).GetValueOrDefault(true);
            chkSendOrderReceivedEmail.Checked   = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.SendOrderReceivedEmail)).GetValueOrDefault(true);

            chkShowShippingEstimateBox.Checked = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.ShowShippingEstimate)).GetValueOrDefault(true);
            chkShowCouponBox.Checked           = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.ShowCouponBox)).GetValueOrDefault(true);
            chkQuantityAndPrice.Checked        = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.ShowPriceAndQuantityInCatalog)).GetValueOrDefault(false);

            chkShowPrices.Checked        = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.ShowPrices)).GetValueOrDefault(true);
            chkEnableCheckout.Checked    = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.EnableCheckout)).GetValueOrDefault(true);
            chkRequireOrderNotes.Checked = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.RequireOrderNotes)).GetValueOrDefault(false);

            chkForceSslCheckout.Checked  = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.ForceSslCheckout)).GetValueOrDefault(false);
            chkDisplaySiteCredit.Checked = WA.Parser.ToBool(store.GetSetting(StoreSettingNames.DisplaySiteCredit)).GetValueOrDefault(true);
            txtUrlToPostOrder.Text       = store.GetSetting(StoreSettingNames.UrlToPostCompletedOrder);
        }