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

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

            ShoppingCart.Age(ThisCustomer.CustomerID, AgeCartDays, CartTypeEnum.ShoppingCart);
            shoppingcartaspx8.Text  = AppLogic.GetString("shoppingcart.aspx.6", SkinID, ThisCustomer.LocaleSetting);
            shoppingcartaspx10.Text = AppLogic.GetString("shoppingcart.aspx.8", SkinID, ThisCustomer.LocaleSetting);
            shoppingcartaspx11.Text = AppLogic.GetString("shoppingcart.aspx.9", SkinID, ThisCustomer.LocaleSetting);
            shoppingcartaspx9.Text  = AppLogic.GetString("shoppingcart.aspx.7", SkinID, ThisCustomer.LocaleSetting);
            shoppingcartcs27.Text   = AppLogic.GetString("shoppingcart.cs.5", SkinID, ThisCustomer.LocaleSetting);
            shoppingcartcs28.Text   = AppLogic.GetString("shoppingcart.cs.6", SkinID, ThisCustomer.LocaleSetting);
            shoppingcartcs29.Text   = AppLogic.GetString("shoppingcart.cs.7", SkinID, ThisCustomer.LocaleSetting);
            shoppingcartcs31.Text   = AppLogic.GetString("shoppingcart.cs.9", SkinID, ThisCustomer.LocaleSetting);

            //removed for mobile design
            //btnUpdateCart1.Text = AppLogic.GetString("shoppingcart.cs.33", SkinID, ThisCustomer.LocaleSetting);
            //btnUpdateCart2.Text = AppLogic.GetString("shoppingcart.cs.33", SkinID, ThisCustomer.LocaleSetting);
            //btnUpdateCart3.Text = AppLogic.GetString("shoppingcart.cs.33", SkinID, ThisCustomer.LocaleSetting);
            //btnUpdateCart4.Text = AppLogic.GetString("shoppingcart.cs.33", SkinID, ThisCustomer.LocaleSetting);

            lblOrderNotes.Text          = AppLogic.GetString("shoppingcart.cs.13", SkinID, ThisCustomer.LocaleSetting);
            btnContinueShoppingTop.Text = AppLogic.GetString("shoppingcart.cs.12", SkinID, ThisCustomer.LocaleSetting);
            //btnContinueShoppingBottom.Text = AppLogic.GetString("shoppingcart.cs.12", SkinID, ThisCustomer.LocaleSetting);
            btnCheckOutNowTop.Text    = AppLogic.GetString("shoppingcart.cs.34", SkinID, ThisCustomer.LocaleSetting);
            btnCheckOutNowBottom.Text = AppLogic.GetString("shoppingcart.cs.34", SkinID, ThisCustomer.LocaleSetting);
            OrderNotes.Attributes.Add("onkeyup", "return imposeMaxLength(this, 255);");
            RedirectToShoppingCart = false;

            if (cart == null)
            {
                cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);
                if (!Page.IsPostBack)
                {
                    if (cart.HasRegistryItems())
                    {
                        cart.RemoveRegistryItems();
                        ErrorMsgLabel.Text    = AppLogic.GetString("mobile.shoppingcart.error.1", SkinID, ThisCustomer.LocaleSetting).ToHtmlDecode();
                        ErrorMsgLabel.Visible = true;
                        cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);
                    }

                    string couponCode         = string.Empty;
                    string couponErrorMessage = string.Empty;
                    if (cart.HasCoupon(ref couponCode) &&
                        cart.IsCouponValid(ThisCustomer, couponCode, ref couponErrorMessage))
                    {
                        CouponCode.Text = couponCode;
                    }
                    else
                    {
                        if (!couponErrorMessage.IsNullOrEmptyTrimmed())
                        {
                            ErrorMsgLabel.Text = couponErrorMessage.ToHtmlDecode();
                        }
                        cart.ClearCoupon();
                    }

                    //check customer IsCreditHold

                    if (ThisCustomer.IsCreditOnHold && cart != null)
                    {
                        ErrorMsgLabel.Text = AppLogic.GetString("shoppingcart.aspx.18", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                        cart.ClearCoupon();
                        RedirectToShoppingCart = true;
                    }
                    else
                    {
                        if (AppLogic.AppConfigBool("ShowShipDateInCart") && AppLogic.AppConfigBool("ShowStockHints") && cart != null)
                        {
                            cart.BuildSalesOrderDetails();
                        }
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(CouponCode.Text))
                    {
                        cart.ClearCoupon();
                    }
                }
            }

            if (cart.IsEmpty())
            {
                btnUpdateCart1.Visible       = false;
                AlternativeCheckouts.Visible = false;
            }
            else
            {
                cart.BuildSalesOrderDetails();
            }

            string BACKURL = AppLogic.GetCartContinueShoppingURL(SkinID, ThisCustomer.LocaleSetting);
            var    html    = new StringBuilder("");

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

            foreach (var c in cart.CartItems)
            {
                string itemJS = string.Empty;

                itemJS = cartJS.Replace("%MAX_QUANTITY_INPUT%", AppLogic.MAX_QUANTITY_INPUT_NoDec).Replace("%ALLOWED_QUANTITY_INPUT%", AppLogic.GetQuantityRegularExpression(c.ItemType, true));
                itemJS = itemJS.Replace("%DECIMAL_SEPARATOR%", Localization.GetNumberDecimalSeparatorLocaleString(ThisCustomer.LocaleSetting)).Replace("%LOCALE_ZERO%", Localization.GetNumberZeroLocaleString(ThisCustomer.LocaleSetting));
                html.Append(itemJS.Replace("%SKU%", c.m_ShoppingCartRecordID.ToString()));
            }
            html.Append("return(true);\n");
            html.Append("}\n");
            html.Append("function imposeMaxLength(theControl, maxLength)\n");
            html.Append("{\n");
            html.Append("theControl.value = theControl.value.substring(0, maxLength);\n");
            html.Append("}\n");
            html.Append("</script>\n");

            string x = ThisCustomer.LocaleSetting;

            ValidationScript.Text = html.ToString();
            //JSPopupRoutines.Text = AppLogic.GetJSPopupRoutines();

            string XmlPackageName = AppLogic.AppConfig("XmlPackage.ShoppingCartPageHeader");

            if (XmlPackageName.Length != 0)
            {
                XmlPackage_ShoppingCartPageHeader.Text = AppLogic.RunXmlPackage(XmlPackageName, base.GetParser, ThisCustomer, SkinID, String.Empty, null, true, true);
            }

            string XRI = AppLogic.LocateImageURL(SkinImagePath + "redarrow.gif");

            redarrow1.ImageUrl = XRI;
            redarrow2.ImageUrl = XRI;
            redarrow3.ImageUrl = XRI;
            redarrow4.ImageUrl = XRI;

            ShippingInformation.Visible = (!AppLogic.AppConfigBool("SkipShippingOnCheckout"));
            AddresBookLlink.Visible     = (ThisCustomer.IsRegistered);

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

            if (!IsPostBack)
            {
                if (CommonLogic.QueryStringCanBeDangerousContent("ErrorMsg").Length != 0 || ErrorMsgLabel.Text.Length > 0)
                {
                    if (CommonLogic.QueryStringCanBeDangerousContent("ErrorMsg").IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1)
                    {
                        throw new ArgumentException("SECURITY EXCEPTION");
                    }
                    pnlErrorMsg.Visible = true;
                    ErrorMsgLabel.Text += Server.HtmlEncode(CommonLogic.QueryStringCanBeDangerousContent("ErrorMsg"));
                }
            }

            if (cart.InventoryTrimmed)
            {
                pnlInventoryTrimmedError.Visible = true;
                InventoryTrimmedError.Text       = AppLogic.GetString("shoppingcart.aspx.1", SkinID, ThisCustomer.LocaleSetting);
            }

            if (cart.MinimumQuantitiesUpdated)
            {
                pnlMinimumQuantitiesUpdatedError.Visible = true;
                MinimumQuantitiesUpdatedError.Text       = AppLogic.GetString("shoppingcart.aspx.5", SkinID, ThisCustomer.LocaleSetting);
            }

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

            if (!cart.MeetsMinimumOrderAmount(MinOrderAmount))
            {
                pnlMeetsMinimumOrderAmountError.Visible = true;
                string amountFormatted = InterpriseHelper.FormatCurrencyForCustomer(MinOrderAmount, ThisCustomer.CurrencyCode);
                MeetsMinimumOrderAmountError.Text = String.Format(AppLogic.GetString("shoppingcart.aspx.2", SkinID, ThisCustomer.LocaleSetting), amountFormatted);
            }

            int quantityDecimalPlaces = InterpriseHelper.GetInventoryDecimalPlacesPreference();

            NumberFormatInfo formatter = (new CultureInfo(ThisCustomer.LocaleSetting)).NumberFormat;

            // setup the formatter
            formatter.NumberDecimalDigits  = quantityDecimalPlaces;
            formatter.PercentDecimalDigits = quantityDecimalPlaces;

            MeetsMinimumOrderQuantityError.Text = string.Empty;
            decimal MinQuantity = AppLogic.AppConfigUSDecimal("MinCartItemsBeforeCheckout");

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

            //ShoppingCartGif.ImageUrl = AppLogic.LocateImageURL(SkinImagePath + "ShoppingCart.gif");
            CartItems.Text = cart.RenderHTMLLiteral(new MobileShoppingCartPageLiteralRenderer());
            //CartSubTotal.Text = cart.RenderHTMLLiteral(new ShoppingCartPageSummaryLiteralRenderer());

            if (!cart.IsEmpty())
            {
                //ShoppingCartorderoptions_gif.ImageUrl = AppLogic.LocateImageURL(SkinImagePath + "ShoppingCartorderoptions.gif");
                string strXml = String.Empty;
                pnlErrorMsg.Visible = true;

                if (AppLogic.AppConfigBool("RequireOver13Checked") && ThisCustomer.IsRegistered && !ThisCustomer.IsOver13)
                {
                    btnCheckOutNowTop.Enabled    = false;
                    btnCheckOutNowBottom.Enabled = false;
                    ErrorMsgLabel.Text           = AppLogic.GetString("over13oncheckout", SkinID, ThisCustomer.LocaleSetting);
                    return;
                }

                btnCheckOutNowBottom.Enabled = btnCheckOutNowTop.Enabled;

                DisplayUpsellProducts(cart);

                if (cart.CouponsAllowed)
                {
                    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;

                if (ThisCustomer.IsNotRegistered)
                {
                    pnlCoupon.Visible     = false;
                    pnlOrderNotes.Visible = false;
                }
            }
            else
            {
                pnlOrderOptions.Visible   = false;
                pnlUpsellProducts.Visible = false;
                pnlCoupon.Visible         = false;
                pnlOrderNotes.Visible     = false;
            }
            btnContinueShoppingTop.OnClientClick = "self.location='" + BACKURL + "'";
            CartPageFooterTopic.SetContext       = this;
            String XmlPackageName2 = AppLogic.AppConfig("XmlPackage.ShoppingCartPageFooter");

            if (XmlPackageName2.Length != 0)
            {
                XmlPackage_ShoppingCartPageFooter.Text = AppLogic.RunXmlPackage(XmlPackageName2, base.GetParser, ThisCustomer, SkinID, String.Empty, null, true, true);
            }
        }