Reversing UseShipping and UseBilling address radio btns

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
User avatar
voir
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 24
Joined: Mon Jun 09, 2008 4:25 pm
Location: Belingham, WA US

Reversing UseShipping and UseBilling address radio btns

Post by voir » Thu Feb 26, 2009 4:31 pm

Depending on the contents of the cart I need to change the default checked button when selecting between Use Billing and Use Shipping address on checkout. When I tried it seemed to work but then checkout halts at the point someone enters their gift card number or credit card number, being redirected to a blank billing address screen. Can anyone help :?:

OnePageCheckout Conlib

Code: Select all

        
        //MAKE SURE THERE ARE ITEMS IN THE BASKET
        Basket basket = Token.Instance.User.Basket;
        bool hasItems = false;

        foreach (BasketItem item in basket.Items)
        {
            if (item.OrderItemType == OrderItemType.Product)
            {
                hasItems = true;
                break;
            }
        }
        if (!hasItems)
        {
            //THERE ARE NO PRODUCTS, SEND THEN TO SEE EMPTY BASKET
            Response.Redirect(NavigationHelper.GetBasketUrl());
        }

bool SwitchRequired = false;
        
        foreach (BasketItem basketItem in basket.Items)
        {
            BasketItemLicenseAgreementCollection basketItemLicenseAgreements = new BasketItemLicenseAgreementCollection(basketItem, LicenseAgreementMode.OnAddToBasket);
            if ((basketItemLicenseAgreements.Count > 0))
            {
                try
                {
                    foreach (BasketItemInput oii in basketItem.Inputs)
                    {
                        if ((oii.InputField.Name.StartsWith("Buying a Gift")) && (oii.InputValue.StartsWith("Yes")))
                        {
                            SwitchRequired = true;
                        }
                    }
                }
                catch { }

            }
        }
        if (SwitchRequired)
        {
            UseBillingAddress.Checked = false;
            UseShippingAddress.Checked = true;
            UseShippingAddressLabel.Text = "Use Shipping Address (Recommended for Gift Memberships)";
            UseShippingAddressLabel.ToolTip = "If your order contains more than one Gift or shipping destination, use the [Multiple Destinations] button";
        }
Then later

Code: Select all

    private void InitializeShippingAddress()
    {
        //CHECK WHETHER TO SHOW SHIPPING ADDRESS FORM
        if (Request.Form[UseShippingAddress.UniqueID] == "UseBillingAddress")
        {
            
                UseBillingAddress.Checked = true;
                this.ShipToAddressId = -1;
        }
        else if (Request.Form[UseShippingAddress.UniqueID] == "UseShippingAddress")
        {
            UseBillingAddress.Checked = false;
        }
        else
        {
            if (UseShippingAddressLabel.Text.Contains("Gift Memberships"))
            {
                UseBillingAddress.Checked = false;
            }
            else
            {
                UseBillingAddress.Checked = (ShipToAddressId < 0);
            }
        }
        UseShippingAddress.Checked = !UseBillingAddress.Checked;

Post Reply