Esempio n. 1
0
        public void InitializePageContent()
        {
            int AgeCartDays = AppLogic.AppConfigUSInt("AgeCartDays");

            if (AgeCartDays == 0)
            {
                AgeCartDays = 7;
            }

            ShoppingCart.Age(ThisCustomer.CustomerID, AgeCartDays, CartTypeEnum.ShoppingCart);

            cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
            shoppingcartaspx8.Text  = AppLogic.GetString("shoppingcart.aspx.8", SkinID, ThisCustomer.LocaleSetting);
            shoppingcartaspx10.Text = AppLogic.GetString("shoppingcart.aspx.10", SkinID, ThisCustomer.LocaleSetting);
            shoppingcartaspx9.Text  = AppLogic.GetString("shoppingcart.aspx.9", SkinID, ThisCustomer.LocaleSetting);

            shoppingcartcs31.Text          = AppLogic.GetString("shoppingcart.cs.117", SkinID, ThisCustomer.LocaleSetting);
            btnUpdateCart1.Text            = AppLogic.GetString("shoppingcart.cs.110", SkinID, ThisCustomer.LocaleSetting);
            btnUpdateCart2.Text            = AppLogic.GetString("shoppingcart.cs.110", SkinID, ThisCustomer.LocaleSetting);
            btnUpdateCart3.Text            = AppLogic.GetString("shoppingcart.cs.110", SkinID, ThisCustomer.LocaleSetting);
            btnUpdateCart4.Text            = AppLogic.GetString("shoppingcart.cs.110", SkinID, ThisCustomer.LocaleSetting);
            lblOrderNotes.Text             = AppLogic.GetString("shoppingcart.cs.66", SkinID, ThisCustomer.LocaleSetting);
            btnContinueShoppingTop.Text    = AppLogic.GetString("shoppingcart.cs.62", SkinID, ThisCustomer.LocaleSetting);
            btnContinueShoppingBottom.Text = AppLogic.GetString("shoppingcart.cs.62", SkinID, ThisCustomer.LocaleSetting);
            btnCheckOutNowTop.Text         = AppLogic.GetString("shoppingcart.cs.111", SkinID, ThisCustomer.LocaleSetting);
            btnCheckOutNowBottom.Text      = AppLogic.GetString("shoppingcart.cs.111", SkinID, ThisCustomer.LocaleSetting);

            bool reqOver13 = AppLogic.AppConfigBool("RequireOver13Checked");

            btnCheckOutNowTop.Enabled = !cart.IsEmpty() && !cart.RecurringScheduleConflict && (!reqOver13 || (reqOver13 && ThisCustomer.IsOver13)) || !ThisCustomer.IsRegistered;
            if (btnCheckOutNowTop.Enabled && AppLogic.MicropayIsEnabled() &&
                !AppLogic.AppConfigBool("MicroPay.HideOnCartPage") && cart.CartItems.Count == 1 &&
                cart.HasMicropayProduct() && ((CartItem)cart.CartItems[0]).Quantity == 0)
            {
                // We have only one item and it is the Micropay Product and the Quantity is zero
                // Don't allow checkout
                btnCheckOutNowTop.Enabled = false;
            }
            ErrorMsgLabel.Text = CommonLogic.IIF(!cart.IsEmpty() && (reqOver13 && !ThisCustomer.IsOver13 && ThisCustomer.IsRegistered), AppLogic.GetString("Over13OnCheckout", SkinID, ThisCustomer.LocaleSetting), String.Empty);

            btnCheckOutNowBottom.Enabled = btnCheckOutNowTop.Enabled;

            PayPalExpressSpan.Visible  = false;
            PayPalExpressSpan2.Visible = false;

            Decimal MinOrderAmount = AppLogic.AppConfigUSDecimal("CartMinOrderAmount");

            if (!cart.IsEmpty() && !cart.ContainsRecurringAutoShip)
            {
                // Enable PayPalExpress if using PayPalPro or PayPal Express is an active payment method.
                bool IncludePayPalExpress = false;

                if (AppLogic.AppConfigBool("PayPal.Express.ShowOnCartPage") && cart.MeetsMinimumOrderAmount(MinOrderAmount))
                {
                    if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWPAYPALPRO)
                    {
                        IncludePayPalExpress = true;
                    }
                    else
                    {
                        foreach (String PM in AppLogic.AppConfig("PaymentMethods").ToUpperInvariant().Split(','))
                        {
                            String PMCleaned = AppLogic.CleanPaymentMethod(PM);
                            if (PMCleaned == AppLogic.ro_PMPayPalExpress)
                            {
                                IncludePayPalExpress = true;
                                break;
                            }
                        }
                    }
                }

                if (IncludePayPalExpress)
                {
                    if (AppLogic.AppConfigExists("Mobile.PayPal.Express.ButtonImageURL"))
                    {
                        btnPayPalExpressCheckout.ImageUrl = AppLogic.AppConfig("Mobile.PayPal.Express.ButtonImageURL");
                    }
                    else
                    {
                        btnPayPalExpressCheckout.ImageUrl = AppLogic.AppConfig("PayPal.Express.ButtonImageURL");
                    }

                    btnPayPalExpressCheckout2.ImageUrl = btnPayPalExpressCheckout.ImageUrl;

                    if (AppLogic.AppConfigExists("Mobile.PayPal.Express.BillMeLaterButtonURL"))
                    {
                        btnPayPalBillMeLaterCheckout.ImageUrl = AppLogic.AppConfig("Mobile.PayPal.Express.BillMeLaterButtonURL");
                    }
                    else
                    {
                        btnPayPalBillMeLaterCheckout.ImageUrl = AppLogic.AppConfig("PayPal.Express.BillMeLaterButtonURL");
                    }

                    btnPayPalBillMeLaterCheckout.Visible   = btnPayPalBillMeLaterCheckout2.Visible = AppLogic.AppConfigBool("PayPal.Express.ShowBillMeLaterButton");
                    btnPayPalBillMeLaterCheckout2.ImageUrl = btnPayPalBillMeLaterCheckout.ImageUrl;

                    PayPalExpressSpan.Visible  = true;
                    PayPalExpressSpan2.Visible = true;
                }
            }

            AlternativeCheckouts.Visible  = PayPalExpressSpan.Visible;
            AlternativeCheckouts2.Visible = PayPalExpressSpan2.Visible;

            if (!AppLogic.AppConfigBool("Mobile.ShowAlternateCheckouts"))
            {
                AlternativeCheckouts.Visible      =
                    AlternativeCheckouts2.Visible = false;
            }

            Shipping.ShippingCalculationEnum ShipCalcID = Shipping.GetActiveShippingCalculationID();

            StringBuilder html = new StringBuilder("");

            html.Append("<script type=\"text/javascript\">\n");
            html.Append("function Cart_Validator(theForm)\n");
            html.Append("{\n");
            String cartJS = CommonLogic.ReadFile("jscripts/shoppingcart.js", true);

            foreach (CartItem c in cart.CartItems)
            {
                html.Append(cartJS.Replace("%SKU%", c.ShoppingCartRecordID.ToString()));
            }
            html.Append("return(true);\n");
            html.Append("}\n");
            html.Append("</script>\n");

            ValidationScript.Text = html.ToString();

            JSPopupRoutines.Text = AppLogic.GetJSPopupRoutines();

            ShippingInformation.Visible = (!AppLogic.AppConfigBool("SkipShippingOnCheckout") && !cart.IsAllFreeShippingComponents() && !cart.IsAllSystemComponents());
            AddresBookLlink.Visible     = ThisCustomer.IsRegistered;

            btnCheckOutNowTop.Visible = (!cart.IsEmpty());

            if (!cart.IsEmpty() && cart.HasCoupon() && !cart.CouponIsValid)
            {
                pnlCouponError.Visible = true;
                CouponError.Text       = cart.CouponStatusMessage + " (" + Server.HtmlEncode(CommonLogic.IIF(cart.Coupon.CouponCode.Length != 0, cart.Coupon.CouponCode, ThisCustomer.CouponCode)) + ")";
                cart.ClearCoupon();
            }

            if (!String.IsNullOrEmpty(errorMessage.Message) || ErrorMsgLabel.Text.Length > 0)
            {
                pnlErrorMsg.Visible = true;
                ErrorMsgLabel.Text += errorMessage.Message;
            }

            if (cart.InventoryTrimmed || this.InventoryTrimmed)
            {
                pnlInventoryTrimmedError.Visible = true;
                if (cart.TrimmedReason == InventoryTrimmedReason.RestrictedQuantities || TrimmedEarlyReason == InventoryTrimmedReason.RestrictedQuantities)
                {
                    InventoryTrimmedError.Text = AppLogic.GetString("shoppingcart.aspx.33", SkinID, ThisCustomer.LocaleSetting);
                }
                else
                {
                    InventoryTrimmedError.Text = AppLogic.GetString("shoppingcart.aspx.3", SkinID, ThisCustomer.LocaleSetting);
                }

                cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
                ctrlShoppingCart.DataSource = cart.CartItems;
                ctrlCartSummary.DataSource  = cart;
            }

            if (cart.RecurringScheduleConflict)
            {
                pnlRecurringScheduleConflictError.Visible = true;
                RecurringScheduleConflictError.Text       = AppLogic.GetString("shoppingcart.aspx.19", SkinID, ThisCustomer.LocaleSetting);
            }

            if (CommonLogic.QueryStringBool("minimumQuantitiesUpdated"))
            {
                pnlMinimumQuantitiesUpdatedError.Visible = true;
                MinimumQuantitiesUpdatedError.Text       = AppLogic.GetString("shoppingcart.aspx.7", SkinID, ThisCustomer.LocaleSetting);
            }

            if (!cart.MeetsMinimumOrderAmount(MinOrderAmount))
            {
                pnlMeetsMinimumOrderAmountError.Visible = true;
                MeetsMinimumOrderAmountError.Text       = String.Format(AppLogic.GetString("shoppingcart.aspx.4", SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CurrencyString(MinOrderAmount));
            }

            int MinQuantity = AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout");

            if (!cart.MeetsMinimumOrderQuantity(MinQuantity))
            {
                pnlMeetsMinimumOrderQuantityError.Visible = true;
                MeetsMinimumOrderQuantityError.Text       = String.Format(AppLogic.GetString("shoppingcart.cs.20", SkinID, ThisCustomer.LocaleSetting), MinQuantity.ToString(), MinQuantity.ToString());
            }

            int MaxQuantity = AppLogic.AppConfigUSInt("MaxCartItemsBeforeCheckout");

            if (cart.ExceedsMaximumOrderQuantity(MaxQuantity))
            {
                pnlExceedsMaximumOrderQuantityError.Visible = true;
                ExceedsMaximumOrderQuantityError.Text       = String.Format(AppLogic.GetString("shoppingcart.cs.119", SkinID, ThisCustomer.LocaleSetting), MaxQuantity.ToString());
            }

            if (AppLogic.MicropayIsEnabled() && AppLogic.AppConfigBool("Micropay.ShowTotalOnTopOfCartPage"))
            {
                pnlMicropay_EnabledError.Visible = true;
                Micropay_EnabledError.Text       = "<div align=\"left\">" + String.Format(AppLogic.GetString("account.aspx.10", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("account.aspx.11", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance)) + "</div>";
            }

            if (!cart.IsEmpty())
            {
                pnlOrderOptions.Visible = cart.AllOrderOptions.Count > 0;

                if (cart.GiftCardsEnabled)
                {
                    if (CouponCode.Text.Length == 0)
                    {
                        CouponCode.Text = cart.Coupon.CouponCode;
                    }

                    btnRemoveCoupon.Visible = CouponCode.Text.Length != 0;
                    pnlCoupon.Visible       = true;
                }
                else
                {
                    pnlCoupon.Visible = false;
                }

                pnlPromotion.Visible = cart.PromotionsEnabled;

                if (!AppLogic.AppConfigBool("DisallowOrderNotes"))
                {
                    OrderNotes.Text       = cart.OrderNotes;
                    pnlOrderNotes.Visible = true;
                }
                else
                {
                    pnlOrderNotes.Visible = false;
                }

                btnCheckOutNowBottom.Visible = true;
            }
            else
            {
                pnlOrderOptions.Visible      = false;
                pnlCoupon.Visible            = false;
                pnlOrderNotes.Visible        = false;
                btnCheckOutNowBottom.Visible = false;
            }

            if (AppLogic.AppConfigBool("SkipShippingOnCheckout") || cart.IsAllFreeShippingComponents() || cart.IsAllSystemComponents())
            {
                ctrlCartSummary.ShowShipping = false;
            }

            if (!cart.HasTaxableComponents() || AppLogic.CustomerLevelHasNoTax(ThisCustomer.CustomerLevelID))
            {
                ctrlCartSummary.ShowTax = false;
            }

            if (cart.ShippingThresHoldIsDefinedButFreeShippingMethodIDIsNot)
            {
                pnlErrorMsg.Visible = true;
                ErrorMsgLabel.Text += Server.HtmlEncode(AppLogic.GetString("shoppingcart.aspx.21", SkinID, ThisCustomer.LocaleSetting));
            }
        }
Esempio n. 2
0
        public void WriteShippingXML(XmlWriter writer, int VariantID, decimal Price, decimal Weight, int CountryID, int StateID, int ZoneID)
        {
            bool AnyShippingMethodsFound           = false;
            bool ShippingMethodToStateMapIsEmpty   = Shipping.ShippingMethodToStateMapIsEmpty();
            bool ShippingMethodToCountryMapIsEmpty = Shipping.ShippingMethodToCountryMapIsEmpty();
            bool ShippingMethodToZoneMapIsEmpty    = Shipping.ShippingMethodToZoneMapIsEmpty();

            int FreeShippingMethodID = 0;

            if (AppLogic.AppConfigUSInt("ShippingMethodIDIfFreeShippingIsOn") != 0)
            {
                FreeShippingMethodID = AppLogic.AppConfigUSInt("ShippingMethodIDIfFreeShippingIsOn");
            }

            bool ShippingIsFree = false;

            if (Price > AppLogic.AppConfigUSDecimal("FreeShippingThreshold"))
            {
                ShippingIsFree = true;
            }

            Shipping.ShippingCalculationEnum ShipCalcID = Shipping.GetActiveShippingCalculationID();
            decimal ExtraFee = AppLogic.AppConfigUSDecimal("ShippingHandlingExtraFee");

            switch (ShipCalcID)
            {
            case Shipping.ShippingCalculationEnum.CalculateShippingByWeight:
            {
                writer.WriteStartElement("Shipping");
                writer.WriteAttributeString("Method", "CalculateShippingByWeight");
                StringBuilder shipsql = new StringBuilder(4096);
                shipsql.Append("select * from ShippingMethod  with (NOLOCK)  where IsRTShipping=0 ");
                if (!ShippingMethodToStateMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap  with (NOLOCK)  where StateID=" + StateID + ")");
                }
                if (!ShippingMethodToCountryMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap  with (NOLOCK)  where CountryID=" + CountryID + ")");
                }
                if (!ShippingMethodToZoneMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap  with (NOLOCK)  where ShippingZoneID=" + ZoneID + ")");
                }
                shipsql.Append(" order by Displayorder");

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rs = DB.GetRS(shipsql.ToString(), con))
                    {
                        while (rs.Read())
                        {
                            int ThisID = DB.RSFieldInt(rs, "ShippingMethodID");
                            if (ShippingIsFree && ThisID == FreeShippingMethodID)
                            {
                                writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + AppLogic.GetString("shoppingcart.aspx.16", ThisCustomer.SkinID, ThisCustomer.LocaleSetting));
                            }
                            else
                            {
                                Decimal ThisShipCost = Shipping.GetShipByWeightCharge(ThisID, Weight) + ExtraFee;
                                if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                {
                                    AnyShippingMethodsFound = true;
                                    writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost));
                                }
                            }
                        }
                    }
                }

                if (!AnyShippingMethodsFound)
                {
                    writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code");
                }
                writer.WriteEndElement();
                break;
            }

            case Shipping.ShippingCalculationEnum.CalculateShippingByTotal:
            {
                writer.WriteStartElement("Shipping");
                writer.WriteAttributeString("Method", "CalculateShippingByTotal");
                StringBuilder shipsql = new StringBuilder(1024);
                shipsql.Append("select * from ShippingMethod  with (NOLOCK)  where IsRTShipping=0 ");
                if (!ShippingMethodToStateMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap  with (NOLOCK)  where StateID=" + StateID + ")");
                }
                if (!ShippingMethodToCountryMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap  with (NOLOCK)  where CountryID=" + CountryID + ")");
                }
                if (!ShippingMethodToZoneMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap  with (NOLOCK)  where ShippingZoneID=" + ZoneID + ")");
                }
                shipsql.Append(" order by Displayorder");

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rs = DB.GetRS(shipsql.ToString(), con))
                    {
                        while (rs.Read())
                        {
                            int ThisID = DB.RSFieldInt(rs, "ShippingMethodID");
                            if (ShippingIsFree && ThisID == FreeShippingMethodID)
                            {
                                writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE");
                            }
                            else
                            {
                                Decimal ThisShipCost = Shipping.GetShipByTotalCharge(ThisID, Price) + ExtraFee;         // exclude download items!
                                if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                {
                                    AnyShippingMethodsFound = true;
                                    writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost));
                                }
                            }
                        }
                    }
                }

                if (!AnyShippingMethodsFound)
                {
                    writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code");
                }
                writer.WriteEndElement();
                break;
            }

            case Shipping.ShippingCalculationEnum.UseFixedPrice:
            {
                writer.WriteStartElement("Shipping");
                writer.WriteAttributeString("Method", "UseFixedPrice");
                StringBuilder shipsql = new StringBuilder(1024);
                shipsql.Append("select * from ShippingMethod  with (NOLOCK)  where IsRTShipping=0 ");
                if (!ShippingMethodToStateMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap  with (NOLOCK)  where StateID=" + StateID + ")");
                }
                if (!ShippingMethodToCountryMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap  with (NOLOCK)  where CountryID=" + CountryID + ")");
                }
                if (!ShippingMethodToZoneMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap  with (NOLOCK)  where ShippingZoneID=" + ZoneID + ")");
                }
                shipsql.Append(" order by Displayorder");

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rs = DB.GetRS(shipsql.ToString(), con))
                    {
                        while (rs.Read())
                        {
                            int ThisID = DB.RSFieldInt(rs, "ShippingMethodID");
                            if (ShippingIsFree && ThisID == FreeShippingMethodID)
                            {
                                writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE");
                            }
                            else
                            {
                                Decimal ThisShipCost = (decimal)DB.RSFieldDecimal(rs, "FixedRate") + ExtraFee;
                                if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                {
                                    AnyShippingMethodsFound = true;
                                    writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost));
                                }
                            }
                        }
                    }
                }

                if (!AnyShippingMethodsFound)
                {
                    writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code");
                }
                writer.WriteEndElement();
                break;
            }

            case Shipping.ShippingCalculationEnum.AllOrdersHaveFreeShipping:
                AnyShippingMethodsFound = true;
                writer.WriteStartElement("Shipping");
                writer.WriteAttributeString("Method", "AllOrdersHaveFreeShipping");
                writer.WriteElementString("Method1", "All Orders Have Free Shipping");
                writer.WriteEndElement();
                break;

            case Shipping.ShippingCalculationEnum.UseFixedPercentageOfTotal:
            {
                writer.WriteStartElement("Shipping");
                writer.WriteAttributeString("Method", "UseFixedPercentageOfTotal");
                StringBuilder shipsql = new StringBuilder(1024);
                shipsql.Append("select * from ShippingMethod  with (NOLOCK)  where IsRTShipping=0 ");
                if (!ShippingMethodToStateMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap  with (NOLOCK)  where StateID=" + StateID + ")");
                }
                if (!ShippingMethodToCountryMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap  with (NOLOCK)  where CountryID=" + CountryID + ")");
                }
                if (!ShippingMethodToZoneMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap  with (NOLOCK)  where ShippingZoneID=" + ZoneID + ")");
                }
                shipsql.Append(" order by Displayorder");

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rs = DB.GetRS(shipsql.ToString(), con))
                    {
                        while (rs.Read())
                        {
                            int ThisID = DB.RSFieldInt(rs, "ShippingMethodID");
                            if (ShippingIsFree && ThisID == FreeShippingMethodID)
                            {
                                writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE");
                            }
                            else
                            {
                                Decimal ThisShipCost = Shipping.GetShipByFixedPercentageCharge(ThisID, Price) + ExtraFee;
                                if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                {
                                    AnyShippingMethodsFound = true;
                                    writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost));
                                }
                            }
                        }
                    }
                }

                if (!AnyShippingMethodsFound)
                {
                    writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code");
                }
                writer.WriteEndElement();
                break;
            }

            case Shipping.ShippingCalculationEnum.UseIndividualItemShippingCosts:
            {
                writer.WriteStartElement("Shipping");
                writer.WriteAttributeString("Method", "UseIndividualItemShippingCosts");
                StringBuilder shipsql = new StringBuilder(1024);
                shipsql.Append("select * from ShippingMethod  with (NOLOCK)  where IsRTShipping=0 ");
                if (!ShippingMethodToStateMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap  with (NOLOCK)  where StateID=" + StateID + ")");
                }
                if (!ShippingMethodToCountryMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap  with (NOLOCK)  where CountryID=" + CountryID + ")");
                }
                if (!ShippingMethodToZoneMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap  with (NOLOCK)  where ShippingZoneID=" + ZoneID + ")");
                }
                shipsql.Append(" order by Displayorder");

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rs = DB.GetRS(shipsql.ToString(), con))
                    {
                        while (rs.Read())
                        {
                            int ThisID = DB.RSFieldInt(rs, "ShippingMethodID");
                            if (ShippingIsFree && ThisID == FreeShippingMethodID)
                            {
                                writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE");
                            }
                            else
                            {
                                Decimal ThisShipCost = Shipping.GetVariantShippingCost(VariantID, ThisID) + ExtraFee;
                                if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                {
                                    AnyShippingMethodsFound = true;
                                    writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost));
                                }
                            }
                        }
                    }
                }

                if (!AnyShippingMethodsFound)
                {
                    writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code");
                }
                writer.WriteEndElement();
                break;
            }

            case Shipping.ShippingCalculationEnum.CalculateShippingByWeightAndZone:
            {
                writer.WriteStartElement("Shipping");
                writer.WriteAttributeString("Method", "CalculateShippingByWeightAndZone");
                StringBuilder shipsql = new StringBuilder(1024);
                shipsql.Append("select * from ShippingMethod  with (NOLOCK)  where IsRTShipping=0 ");
                if (!ShippingMethodToStateMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap  with (NOLOCK)  where StateID=" + StateID + ")");
                }
                if (!ShippingMethodToCountryMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap  with (NOLOCK)  where CountryID=" + CountryID + ")");
                }
                if (!ShippingMethodToZoneMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap  with (NOLOCK)  where ShippingZoneID=" + ZoneID + ")");
                }
                shipsql.Append(" order by Displayorder");

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rs = DB.GetRS(shipsql.ToString(), con))
                    {
                        while (rs.Read())
                        {
                            int ThisID = DB.RSFieldInt(rs, "ShippingMethodID");
                            if (ShippingIsFree && ThisID == FreeShippingMethodID)
                            {
                                writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE");
                            }
                            else
                            {
                                Decimal ThisShipCost = Shipping.GetShipByWeightAndZoneCharge(ThisID, Weight, ZoneID) + ExtraFee;
                                if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                {
                                    AnyShippingMethodsFound = true;
                                    writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost));
                                }
                            }
                        }
                    }
                }

                if (!AnyShippingMethodsFound)
                {
                    writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code");
                }
                writer.WriteEndElement();
                break;
            }

            case Shipping.ShippingCalculationEnum.CalculateShippingByTotalAndZone:
            {
                writer.WriteStartElement("Shipping");
                writer.WriteAttributeString("Method", "CalculateShippingByTotalAndZone");
                StringBuilder shipsql = new StringBuilder(1024);
                shipsql.Append("select * from ShippingMethod  with (NOLOCK)  where IsRTShipping=0 ");
                if (!ShippingMethodToStateMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap  with (NOLOCK)  where StateID=" + StateID + ")");
                }
                if (!ShippingMethodToCountryMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap  with (NOLOCK)  where CountryID=" + CountryID + ")");
                }
                if (!ShippingMethodToZoneMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap  with (NOLOCK)  where ShippingZoneID=" + ZoneID + ")");
                }
                shipsql.Append(" order by Displayorder");

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rs = DB.GetRS(shipsql.ToString(), con))
                    {
                        while (rs.Read())
                        {
                            int ThisID = DB.RSFieldInt(rs, "ShippingMethodID");
                            if (ShippingIsFree && ThisID == FreeShippingMethodID)
                            {
                                writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE");
                            }
                            else
                            {
                                Decimal ThisShipCost = Shipping.GetShipByTotalAndZoneCharge(ThisID, Price, ZoneID) + ExtraFee;
                                if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                {
                                    AnyShippingMethodsFound = true;
                                    writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost));
                                }
                            }
                        }
                    }
                }

                if (!AnyShippingMethodsFound)
                {
                    writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code");
                }
                writer.WriteEndElement();
                break;
            }

            case Shipping.ShippingCalculationEnum.CalculateShippingByTotalByPercent:
            {
                writer.WriteStartElement("Shipping");
                writer.WriteAttributeString("Method", "CalculateShippingByTotalByPercent");
                StringBuilder shipsql = new StringBuilder(1024);
                shipsql.Append("select * from ShippingMethod  with (NOLOCK)  where IsRTShipping=0 ");
                if (!ShippingMethodToStateMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToStateMap  with (NOLOCK)  where StateID=" + StateID + ")");
                }
                if (!ShippingMethodToCountryMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToCountryMap  with (NOLOCK)  where CountryID=" + CountryID + ")");
                }
                if (!ShippingMethodToZoneMapIsEmpty)
                {
                    shipsql.Append(" and ShippingMethodID in (select ShippingMethodID from ShippingMethodToZoneMap  with (NOLOCK)  where ShippingZoneID=" + ZoneID + ")");
                }
                shipsql.Append(" order by Displayorder");

                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rs = DB.GetRS(shipsql.ToString(), con))
                    {
                        while (rs.Read())
                        {
                            int ThisID = DB.RSFieldInt(rs, "ShippingMethodID");
                            if (ShippingIsFree && ThisID == FreeShippingMethodID)
                            {
                                writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": FREE");
                            }
                            else
                            {
                                Decimal ThisShipCost = Shipping.GetShipByTotalByPercentCharge(ThisID, Price) + ExtraFee;
                                if (ThisShipCost != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                                {
                                    AnyShippingMethodsFound = true;
                                    writer.WriteElementString("Method" + ThisID.ToString(), Shipping.GetShippingMethodDisplayName(ThisID, null) + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(ThisShipCost));
                                }
                            }
                        }
                    }
                }

                if (!AnyShippingMethodsFound)
                {
                    writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code");
                }
                writer.WriteEndElement();
                break;
            }

            case Shipping.ShippingCalculationEnum.UseRealTimeRates:
            {
                writer.WriteStartElement("Shipping");
                writer.WriteAttributeString("Method", "UseRealTimeRates");
                ShippingMethods SM = GetRates();

                if (SM.Count > 0)
                {
                    int ThisID = 1;
                    foreach (ShipMethod meth in SM)
                    {
                        if (meth.ServiceRate != System.Decimal.Zero || !AppLogic.AppConfigBool("FilterOutShippingMethodsThatHave0Cost"))
                        {
                            writer.WriteElementString("Method" + ThisID.ToString(), meth.ServiceName + ": " + Localization.CurrencyStringForDisplayWithoutExchangeRate(meth.ServiceRate));
                            ThisID++;
                        }
                    }
                }
                else if (SM.ErrorMsg.Length != 0)
                {
                    if (SM.ErrorMsg.IndexOf(AppLogic.AppConfig("RTShipping.CallForShippingPrompt")) != -1)
                    {
                        writer.WriteElementString("Method0", AppLogic.AppConfig("RTShipping.CallForShippingPrompt"));
                    }
                    else
                    {
                        writer.WriteElementString("Method0", SM.ErrorMsg);
                    }
                }
                else
                {
                    writer.WriteElementString("Method0", "No Matching Shipping Methods Found For That Country/State/Postal Code");
                }

                writer.WriteEndElement();
                break;
            }
            }
        }
        public void InitializePageContent()
        {
            int AgeCartDays = AppLogic.AppConfigUSInt("AgeCartDays");

            if (AgeCartDays == 0)
            {
                AgeCartDays = 7;
            }

            ShoppingCart.Age(ThisCustomer.CustomerID, AgeCartDays, CartTypeEnum.ShoppingCart);

            cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
            shoppingcartaspx8.Text  = AppLogic.GetString("shoppingcart.aspx.8", SkinID, ThisCustomer.LocaleSetting);
            shoppingcartaspx10.Text = AppLogic.GetString("shoppingcart.aspx.10", SkinID, ThisCustomer.LocaleSetting);
            shoppingcartaspx9.Text  = AppLogic.GetString("shoppingcart.aspx.9", SkinID, ThisCustomer.LocaleSetting);

            shoppingcartcs31.Text          = AppLogic.GetString("shoppingcart.cs.117", SkinID, ThisCustomer.LocaleSetting);
            btnUpdateCart1.Text            = AppLogic.GetString("shoppingcart.cs.110", SkinID, ThisCustomer.LocaleSetting);
            btnUpdateCart2.Text            = AppLogic.GetString("shoppingcart.cs.110", SkinID, ThisCustomer.LocaleSetting);
            btnUpdateCart3.Text            = AppLogic.GetString("shoppingcart.cs.110", SkinID, ThisCustomer.LocaleSetting);
            btnUpdateCart4.Text            = AppLogic.GetString("shoppingcart.cs.110", SkinID, ThisCustomer.LocaleSetting);
            lblOrderNotes.Text             = AppLogic.GetString("shoppingcart.cs.66", SkinID, ThisCustomer.LocaleSetting);
            btnContinueShoppingTop.Text    = AppLogic.GetString("shoppingcart.cs.62", SkinID, ThisCustomer.LocaleSetting);
            btnContinueShoppingBottom.Text = AppLogic.GetString("shoppingcart.cs.62", SkinID, ThisCustomer.LocaleSetting);
            btnCheckOutNowTop.Text         = AppLogic.GetString("shoppingcart.cs.111", SkinID, ThisCustomer.LocaleSetting);
            btnCheckOutNowBottom.Text      = AppLogic.GetString("shoppingcart.cs.111", SkinID, ThisCustomer.LocaleSetting);

            bool reqOver13 = AppLogic.AppConfigBool("RequireOver13Checked");

            btnCheckOutNowTop.Enabled = !cart.IsEmpty() && !cart.RecurringScheduleConflict && (!reqOver13 || (reqOver13 && ThisCustomer.IsOver13)) || !ThisCustomer.IsRegistered;
            if (btnCheckOutNowTop.Enabled && AppLogic.MicropayIsEnabled() &&
                !AppLogic.AppConfigBool("MicroPay.HideOnCartPage") && cart.CartItems.Count == 1 &&
                cart.HasMicropayProduct() && ((CartItem)cart.CartItems[0]).Quantity == 0)
            {
                // We have only one item and it is the Micropay Product and the Quantity is zero
                // Don't allow checkout
                btnCheckOutNowTop.Enabled = false;
            }
            btnCheckOutNowBottom.Enabled = btnCheckOutNowTop.Enabled;
            ErrorMsgLabel.Text           = CommonLogic.IIF(!cart.IsEmpty() && (reqOver13 && !ThisCustomer.IsOver13 && ThisCustomer.IsRegistered), AppLogic.GetString("Over13OnCheckout", SkinID, ThisCustomer.LocaleSetting), String.Empty);

            PayPalExpressSpan.Visible  = false;
            PayPalExpressSpan2.Visible = false;

            Decimal MinOrderAmount = AppLogic.AppConfigUSDecimal("CartMinOrderAmount");

            if (!cart.IsEmpty() && !cart.ContainsRecurringAutoShip)
            {
                // Enable PayPalExpress if using PayPalPro or PayPal Express is an active payment method.
                bool IncludePayPalExpress = false;

                if (AppLogic.AppConfigBool("PayPal.Express.ShowOnCartPage") && cart.MeetsMinimumOrderAmount(MinOrderAmount))
                {
                    if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWPAYPALPRO)
                    {
                        IncludePayPalExpress = true;
                    }
                    else
                    {
                        foreach (String PM in AppLogic.AppConfig("PaymentMethods").ToUpperInvariant().Split(','))
                        {
                            String PMCleaned = AppLogic.CleanPaymentMethod(PM);
                            if (PMCleaned == AppLogic.ro_PMPayPalExpress)
                            {
                                IncludePayPalExpress = true;
                                break;
                            }
                        }
                    }
                }

                if (IncludePayPalExpress)
                {
                    if (AppLogic.AppConfigBool("PayPal.Promo.Enabled") && cart.Total(true) >= AppLogic.AppConfigNativeDecimal("PayPal.Promo.CartMinimum") && cart.Total(true) <= AppLogic.AppConfigNativeDecimal("PayPal.Promo.CartMaximum"))
                    {
                        btnPayPalExpressCheckout.ImageUrl = AppLogic.AppConfig("PayPal.Promo.ButtonImageURL");
                    }
                    else if (AppLogic.AppConfigExists("Mobile.PayPal.Express.ButtonImageURL"))
                    {
                        btnPayPalExpressCheckout.ImageUrl = AppLogic.AppConfig("Mobile.PayPal.Express.ButtonImageURL");
                    }
                    else
                    {
                        btnPayPalExpressCheckout.ImageUrl = AppLogic.AppConfig("PayPal.Express.ButtonImageURL");
                    }

                    btnPayPalExpressCheckout2.ImageUrl = btnPayPalExpressCheckout.ImageUrl;
                    PayPalExpressSpan.Visible          = true;
                    PayPalExpressSpan2.Visible         = true;
                }
            }

            string googleimageurl;

            if (AppLogic.AppConfigExists("Mobile.GoogleCheckout.LiveCheckoutButton"))
            {
                googleimageurl = String.Format(AppLogic.AppConfig("Mobile.GoogleCheckout.LiveCheckoutButton"), AppLogic.AppConfig("GoogleCheckout.MerchantId"));
            }
            else
            {
                googleimageurl = String.Format(AppLogic.AppConfig("GoogleCheckout.LiveCheckoutButton"), AppLogic.AppConfig("GoogleCheckout.MerchantId"));
            }

            if (AppLogic.AppConfigBool("GoogleCheckout.UseSandbox"))
            {
                googleimageurl = String.Format(AppLogic.AppConfig("GoogleCheckout.SandBoxCheckoutButton"), AppLogic.AppConfig("GoogleCheckout.SandboxMerchantId"));
            }

            googleimageurl = CommonLogic.IsSecureConnection() ? googleimageurl.ToLower().Replace("http://", "https://") : googleimageurl;

            if (AppLogic.ProductIsMLExpress() == true)
            {
                googleimageurl = string.Empty;
            }

            btnGoogleCheckout.ImageUrl  = googleimageurl;
            btnGoogleCheckout2.ImageUrl = googleimageurl;

            bool ForceGoogleOff = false;

            if (cart.IsEmpty() || cart.ContainsRecurringAutoShip || !cart.MeetsMinimumOrderAmount(MinOrderAmount) || ThisCustomer.ThisCustomerSession["IGD"].Length != 0 || (AppLogic.AppConfig("GoogleCheckout.MerchantId").Length == 0 && AppLogic.AppConfig("GoogleCheckout.SandboxMerchantId").Length == 0))
            {
                GoogleCheckoutSpan.Visible  = false;
                GoogleCheckoutSpan2.Visible = false;
                ForceGoogleOff = true; // these conditions force google off period (don't care about other settings)
            }

            if (!AppLogic.AppConfigBool("GoogleCheckout.ShowOnCartPage"))
            {
                // turn off the google checkout, but not in a forced condition, as the mall may turn it back on
                GoogleCheckoutSpan.Visible  = false;
                GoogleCheckoutSpan2.Visible = false;
            }

            // allow the GooglerMall to turn google checkout back on, if not forced off prior and not already visible anyway:
            if (!ForceGoogleOff && !GoogleCheckoutSpan.Visible && (AppLogic.AppConfigBool("GoogleCheckout.GoogleMallEnabled") && Profile.GoogleMall != String.Empty))
            {
                GoogleCheckoutSpan.Visible  = true;
                GoogleCheckoutSpan2.Visible = true;
            }

            AlternativeCheckouts.Visible  = GoogleCheckoutSpan.Visible || PayPalExpressSpan.Visible;
            AlternativeCheckouts2.Visible = GoogleCheckoutSpan2.Visible || PayPalExpressSpan2.Visible;

            if (!AppLogic.AppConfigBool("Mobile.ShowAlternateCheckouts"))
            {
                AlternativeCheckouts.Visible      =
                    AlternativeCheckouts2.Visible = false;
            }

            if (!ForceGoogleOff)
            {
                // hide GC button for carts that don't qualify
                imgGoogleCheckoutDisabled.Visible = !GoogleCheckout.PermitGoogleCheckout(cart);
                btnGoogleCheckout.Visible         = !imgGoogleCheckoutDisabled.Visible;

                imgGoogleCheckout2Disabled.Visible = imgGoogleCheckoutDisabled.Visible;
                btnGoogleCheckout2.Visible         = btnGoogleCheckout.Visible;
            }

            Shipping.ShippingCalculationEnum ShipCalcID = Shipping.GetActiveShippingCalculationID();

            StringBuilder html = new StringBuilder("");

            html.Append("<script type=\"text/javascript\">\n");
            html.Append("function Cart_Validator(theForm)\n");
            html.Append("{\n");
            String cartJS = CommonLogic.ReadFile("jscripts/shoppingcart.js", true);

            foreach (CartItem c in cart.CartItems)
            {
                html.Append(cartJS.Replace("%SKU%", c.ShoppingCartRecordID.ToString()));
            }
            html.Append("return(true);\n");
            html.Append("}\n");
            html.Append("</script>\n");

            ValidationScript.Text = html.ToString();

            JSPopupRoutines.Text = AppLogic.GetJSPopupRoutines();

            ShippingInformation.Visible = (!AppLogic.AppConfigBool("SkipShippingOnCheckout") && !cart.IsAllFreeShippingComponents() && !cart.IsAllSystemComponents());
            AddresBookLlink.Visible     = ThisCustomer.IsRegistered;

            btnCheckOutNowTop.Visible = (!cart.IsEmpty());

            if (!cart.IsEmpty() && cart.HasCoupon() && !cart.CouponIsValid)
            {
                pnlCouponError.Visible = true;
                CouponError.Text       = cart.CouponStatusMessage + " (" + Server.HtmlEncode(CommonLogic.IIF(cart.Coupon.CouponCode.Length != 0, cart.Coupon.CouponCode, ThisCustomer.CouponCode)) + ")";
                cart.ClearCoupon();
            }

            if (!String.IsNullOrEmpty(errorMessage.Message) || ErrorMsgLabel.Text.Length > 0)
            {
                pnlErrorMsg.Visible = true;
                ErrorMsgLabel.Text += errorMessage.Message;
            }

            if (cart.InventoryTrimmed || this.InventoryTrimmed)
            {
                pnlInventoryTrimmedError.Visible = true;
                if (cart.TrimmedReason == InventoryTrimmedReason.RestrictedQuantities || TrimmedEarlyReason == InventoryTrimmedReason.RestrictedQuantities)
                {
                    InventoryTrimmedError.Text = AppLogic.GetString("shoppingcart.aspx.33", SkinID, ThisCustomer.LocaleSetting);
                }
                else
                {
                    InventoryTrimmedError.Text = AppLogic.GetString("shoppingcart.aspx.3", SkinID, ThisCustomer.LocaleSetting);
                }

                cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
                ctrlShoppingCart.DataSource = cart.CartItems;
                ctrlCartSummary.DataSource  = cart;
            }

            if (cart.RecurringScheduleConflict)
            {
                pnlRecurringScheduleConflictError.Visible = true;
                RecurringScheduleConflictError.Text       = AppLogic.GetString("shoppingcart.aspx.19", SkinID, ThisCustomer.LocaleSetting);
            }

            if (CommonLogic.QueryStringBool("minimumQuantitiesUpdated"))
            {
                pnlMinimumQuantitiesUpdatedError.Visible = true;
                MinimumQuantitiesUpdatedError.Text       = AppLogic.GetString("shoppingcart.aspx.7", SkinID, ThisCustomer.LocaleSetting);
            }

            if (!cart.MeetsMinimumOrderAmount(MinOrderAmount))
            {
                pnlMeetsMinimumOrderAmountError.Visible = true;
                MeetsMinimumOrderAmountError.Text       = String.Format(AppLogic.GetString("shoppingcart.aspx.4", SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CurrencyString(MinOrderAmount));
            }

            int MinQuantity = AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout");

            if (!cart.MeetsMinimumOrderQuantity(MinQuantity))
            {
                pnlMeetsMinimumOrderQuantityError.Visible = true;
                MeetsMinimumOrderQuantityError.Text       = String.Format(AppLogic.GetString("shoppingcart.cs.20", SkinID, ThisCustomer.LocaleSetting), MinQuantity.ToString(), MinQuantity.ToString());
            }

            if (AppLogic.MicropayIsEnabled() && AppLogic.AppConfigBool("Micropay.ShowTotalOnTopOfCartPage"))
            {
                pnlMicropay_EnabledError.Visible = true;
                Micropay_EnabledError.Text       = "<div align=\"left\">" + String.Format(AppLogic.GetString("account.aspx.10", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("account.aspx.11", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance)) + "</div>";
            }

            ctrlShoppingCart.HeaderTabImageURL = AppLogic.SkinImage("ShoppingCart.gif");

            if (!cart.IsEmpty())
            {
                pnlOrderOptions.Visible = cart.AllOrderOptions.Count > 0;

                if (cart.CouponsAllowed)
                {
                    if (CouponCode.Text.Length == 0)
                    {
                        CouponCode.Text = cart.Coupon.CouponCode;
                    }

                    btnRemoveCoupon.Visible = CouponCode.Text.Length != 0;
                    pnlCoupon.Visible       = true;
                }
                else
                {
                    pnlCoupon.Visible = false;
                }

                if (!AppLogic.AppConfigBool("DisallowOrderNotes"))
                {
                    OrderNotes.Text       = cart.OrderNotes;
                    pnlOrderNotes.Visible = true;
                }
                else
                {
                    pnlOrderNotes.Visible = false;
                }

                btnCheckOutNowBottom.Visible = true;
            }
            else
            {
                pnlOrderOptions.Visible      = false;
                pnlCoupon.Visible            = false;
                pnlOrderNotes.Visible        = false;
                btnCheckOutNowBottom.Visible = false;
            }

            if (AppLogic.AppConfigBool("SkipShippingOnCheckout") || cart.IsAllFreeShippingComponents() || cart.IsAllSystemComponents())
            {
                ctrlCartSummary.ShowShipping = false;
            }

            if (!cart.HasTaxableComponents() || AppLogic.CustomerLevelHasNoTax(ThisCustomer.CustomerLevelID))
            {
                ctrlCartSummary.ShowTax = false;
            }

            if (cart.ShippingThresHoldIsDefinedButFreeShippingMethodIDIsNot)
            {
                pnlErrorMsg.Visible = true;
                ErrorMsgLabel.Text += Server.HtmlEncode(AppLogic.GetString("shoppingcart.aspx.21", SkinID, ThisCustomer.LocaleSetting));
            }
        }