示例#1
0
        private void PerformPageAccessLogic()
        {
            if (!_checkOutMode)
            {
                return;
            }

            // -----------------------------------------------------------------------------------------------
            // NOTE ON PAGE LOAD LOGIC:
            // We are checking here for required elements to allowing the customer to stay on this page.
            // Many of these checks may be redundant, and they DO add a bit of overhead in terms of db calls, but ANYTHING really
            // could have changed since the customer was on the last page. Remember, the web is completely stateless. Assume this
            // page was executed by ANYONE at ANYTIME (even someone trying to break the cart).
            // It could have been yesterday, or 1 second ago, and other customers could have purchased limitied inventory products,
            // coupons may no longer be valid, etc, etc, etc...
            // -----------------------------------------------------------------------------------------------

            if (_cart.IsEmpty())
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (_cart.InventoryTrimmed)
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("shoppingcart.aspx.1", SkinID, ThisCustomer.LocaleSetting, true)));
            }

            string couponCode         = string.Empty;
            string couponErrorMessage = string.Empty;

            if (_cart.HasCoupon(ref couponCode) && !_cart.IsCouponValid(ThisCustomer, couponCode, ref couponErrorMessage))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&discountvalid=false");
            }

            if (!_cart.MeetsMinimumOrderAmount(AppLogic.AppConfigUSDecimal("CartMinOrderAmount")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (!_cart.MeetsMinimumOrderWeight(AppLogic.AppConfigUSDecimal("MinOrderWeight")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (!_cart.MeetsMinimumOrderQuantity(AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            pnlCheckoutImage.Visible = true;
            CheckoutImage.ImageUrl   = AppLogic.LocateImageURL("skins/skin_" + SkinID.ToString() + "/images/step_2.gif");
        }
示例#2
0
        private void InitializeShoppingCart()
        {
            _cart = new InterpriseShoppingCart(base.EntityHelpers, ThisCustomer.SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);
            if (_cart.CartItems.Count > 0)
            {
                _cart.BuildSalesOrderDetails();
                _cartHasCouponAndIncludesFreeShipping = _cart.CouponIncludesFreeShipping();
            }
            else
            {
                Response.Redirect("shoppingcart.aspx");
            }

            if (_cart.InventoryTrimmed)
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("shoppingcart.aspx.1", SkinID, ThisCustomer.LocaleSetting, true)));
            }

            string couponCode = string.Empty;
            string error      = string.Empty;

            bool hasCoupon = _cart.HasCoupon(ref couponCode);

            if (hasCoupon && _cart.IsCouponValid(ThisCustomer, couponCode, ref error))
            {
                panelCoupon.Visible   = true;
                litCouponEntered.Text = couponCode;
            }
            else
            {
                panelCoupon.Visible = false;
                if (!error.IsNullOrEmptyTrimmed())
                {
                    Response.Redirect("shoppingcart.aspx?resetlinkback=1&discountvalid=false");
                }
            }
        }
示例#3
0
        private void InitializeShoppingCart()
        {
            _cart = new InterpriseShoppingCart(base.EntityHelpers, ThisCustomer.SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);

            string couponCode = string.Empty;
            bool   hasCoupon  = _cart.HasCoupon(ref couponCode);

            if (hasCoupon)
            {
                panelCoupon.Visible   = true;
                litCouponEntered.Text = couponCode;
            }
            else
            {
                panelCoupon.Visible = false;
            }

            try
            {
                // Always compute the vat since we need to display the vat even if the the vat enabled = true
                _cart.BuildSalesOrderDetails(false, true, couponCode);
                _cartHasCouponAndIncludesFreeShipping = _cart.CouponIncludesFreeShipping(couponCode);
            }
            catch (InvalidOperationException ex)
            {
                if (ex.Message == AppLogic.GetString("shoppingcart.cs.35", 1, ThisCustomer.LocaleSetting, true))
                {
                    Response.Redirect("shoppingcart.aspx?resetlinkback=1&discountvalid=false");
                }
                else
                {
                    throw ex;
                }
            }
            catch (Exception ex) { throw ex; }
        }
示例#4
0
        private void PerformPageAccessLogic()
        {
            // -----------------------------------------------------------------------------------------------
            // NOTE ON PAGE LOAD LOGIC:
            // We are checking here for required elements to allowing the customer to stay on this page.
            // Many of these checks may be redundant, and they DO add a bit of overhead in terms of db calls, but ANYTHING really
            // could have changed since the customer was on the last page. Remember, the web is completely stateless. Assume this
            // page was executed by ANYONE at ANYTIME (even someone trying to break the cart).
            // It could have been yesterday, or 1 second ago, and other customers could have purchased limitied inventory products,
            // coupons may no longer be valid, etc, etc, etc...
            // -----------------------------------------------------------------------------------------------

            if (ThisCustomer.IsCreditOnHold)
            {
                Response.Redirect("shoppingcart.aspx");
            }

            if (AppLogic.AppConfigBool("RequireOver13Checked") && !ThisCustomer.IsOver13)
            {
                Response.Redirect("shoppingcart.aspx?errormsg=" + Server.UrlEncode(AppLogic.GetString("checkout.over13required", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
            }

            if (ThisCustomer.IsNotRegistered && !AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout"))
            {
                Response.Redirect("createaccount.aspx?checkout=true");
            }
            if (ThisCustomer.PrimaryBillingAddressID == String.Empty || ThisCustomer.PrimaryShippingAddressID == String.Empty)
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("checkoutpayment.aspx.1", SkinID, ThisCustomer.LocaleSetting)));
            }

            SectionTitle = AppLogic.GetString("checkoutshippingmult.aspx.1", SkinID, ThisCustomer.LocaleSetting);

            if (_cart.IsEmpty())
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (_cart.HasRegistryItems())
            {
                Response.Redirect("shoppingcart.aspx");
            }

            if (_cart.InventoryTrimmed)
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("shoppingcart.aspx.1", SkinID, ThisCustomer.LocaleSetting)));
            }

            string couponCode         = string.Empty;
            string couponErrorMessage = string.Empty;

            if (_cart.HasCoupon(ref couponCode) && !_cart.IsCouponValid(ThisCustomer, couponCode, ref couponErrorMessage))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&discountvalid=false");
            }

            if (!_cart.MeetsMinimumOrderAmount(AppLogic.AppConfigUSDecimal("CartMinOrderAmount")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (!_cart.MeetsMinimumOrderQuantity(AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (_cart.IsNoShippingRequired() || !Shipping.MultiShipEnabled() || (_cart.NumItems() > AppLogic.MultiShipMaxNumItemsAllowed()) || _cart.NumItems() == 1)
            {
                // not allowed then:
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("checkoutshippingmult.aspx.3", SkinID, ThisCustomer.LocaleSetting)));
            }

            if (ThisCustomer.PrimaryShippingAddress == null ||
                CommonLogic.IsStringNullOrEmpty(ThisCustomer.PrimaryShippingAddress.AddressID))
            {
                // not allowed here anymore!
                Response.Redirect("shoppingcart.aspx?errormsg=" + Server.UrlEncode(AppLogic.GetString("checkoutshippingmult.aspx.2", SkinID, ThisCustomer.LocaleSetting)));
            }
        }
示例#5
0
        public void ProcessCart(bool DoingFullCheckout)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            ThisCustomer.RequireCustomerRecord();
            CartTypeEnum cte = CartTypeEnum.ShoppingCart;

            if (CommonLogic.QueryStringCanBeDangerousContent("CartType").Length != 0)
            {
                cte = (CartTypeEnum)CommonLogic.QueryStringUSInt("CartType");
            }
            cart = new InterpriseShoppingCart(null, 1, ThisCustomer, cte, string.Empty, false, true);

            if (!Page.IsPostBack)
            {
                string couponCode = string.Empty;
                if (cart.HasCoupon(ref couponCode))
                {
                    CouponCode.Text = couponCode;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(CouponCode.Text))
                {
                    cart.ClearCoupon();
                }
            }

            // check if credit on hold
            if (ThisCustomer.IsCreditOnHold)
            {
                Response.Redirect("shoppingcart.aspx");
            }

            if (cart.IsEmpty())
            {
                // can't have this at this point:
                switch (cte)
                {
                case CartTypeEnum.ShoppingCart:
                    Response.Redirect("shoppingcart.aspx");
                    break;

                case CartTypeEnum.WishCart:
                    Response.Redirect("wishlist.aspx");
                    break;

                case CartTypeEnum.GiftRegistryCart:
                    Response.Redirect("giftregistry.aspx");
                    break;

                default:
                    Response.Redirect("shoppingcart.aspx");
                    break;
                }
            }

            //Make it a method
            UpdateCartItems();

            // save coupon code, no need to reload cart object
            // will update customer record also:
            if (cte == CartTypeEnum.ShoppingCart)
            {
                if (!string.IsNullOrEmpty(CouponCode.Text))
                {
                    string errorMessage = string.Empty;
                    if (cart.IsCouponValid(ThisCustomer, CouponCode.Text, ref errorMessage))
                    {
                        cart.ApplyCoupon(CouponCode.Text);
                    }
                    else
                    {
                        // NULL out the coupon for this cusotmer...
                        InterpriseHelper.ClearCustomerCoupon(ThisCustomer.CustomerCode, ThisCustomer.IsRegistered);

                        ErrorMsgLabel.Text = errorMessage;
                        CouponCode.Text    = string.Empty;
                        return;
                    }
                }

                // check for upsell products
                if (CommonLogic.FormCanBeDangerousContent("Upsell").Length != 0)
                {
                    foreach (string s in CommonLogic.FormCanBeDangerousContent("Upsell").Split(','))
                    {
                        int ProductID = Localization.ParseUSInt(s);
                        if (ProductID == 0)
                        {
                            continue;
                        }

                        string itemCode = InterpriseHelper.GetInventoryItemCode(ProductID);
                        string shippingAddressID;

                        shippingAddressID = CommonLogic.IIF(ThisCustomer.IsNotRegistered, string.Empty, ThisCustomer.PrimaryShippingAddressID);

                        var umInfo = InterpriseHelper.GetItemDefaultUnitMeasure(itemCode);
                        cart.AddItem(ThisCustomer, shippingAddressID, itemCode, ProductID, 1, umInfo.Code, CartTypeEnum.ShoppingCart);
                    }
                }

                bool hasCheckedOptions = false;

                if (pnlOrderOptions.Visible)
                {
                    // Process the Order Options
                    foreach (RepeaterItem ri in OrderOptionsList.Items)
                    {
                        hasCheckedOptions = true;
                        DataCheckBox cbk = (DataCheckBox)ri.FindControl("OrderOptions");
                        if (cbk.Checked)
                        {
                            string      itemCode  = (string)cbk.Data;
                            HiddenField hfCounter = ri.FindControl("hfItemCounter") as HiddenField;
                            TextBox     txtNotes  = ri.FindControl("txtOrderOptionNotes") as TextBox;

                            string strNotes = HttpUtility.HtmlEncode(txtNotes.Text);
                            string notes    = CommonLogic.IIF((strNotes != null), CommonLogic.CleanLevelOne(strNotes), string.Empty);

                            //check the length of order option notes
                            //should not exceed 1000 characters including spaces
                            int maxLen = 1000;
                            if (notes.Length > maxLen)
                            {
                                notes = notes.Substring(0, maxLen);
                            }

                            string unitMeasureCode = string.Empty;

                            // check if the item has only 1 unit measure
                            // hence it's rendered as a label
                            // else it would be rendered as a drop down list
                            Label lblUnitMeasureCode = ri.FindControl("lblUnitMeasureCode") as Label;
                            if (null != lblUnitMeasureCode && lblUnitMeasureCode.Visible)
                            {
                                unitMeasureCode = lblUnitMeasureCode.Text;
                            }
                            else
                            {
                                // it's rendered as combobox because the item has multiple unit measures configured
                                DropDownList cboUnitMeasureCode = ri.FindControl("cboUnitMeasureCode") as DropDownList;
                                if (null != cboUnitMeasureCode && cboUnitMeasureCode.Visible)
                                {
                                    unitMeasureCode = cboUnitMeasureCode.SelectedValue;
                                }
                            }

                            if (CommonLogic.IsStringNullOrEmpty(unitMeasureCode))
                            {
                                throw new ArgumentException("Unit Measure not specified!!!");
                            }

                            //check if this Order Option has Restricted Quantity and Minimum Order Qty set.
                            decimal itemQuantity = 1;

                            using (var con = DB.NewSqlConnection())
                            {
                                con.Open();
                                using (var reader = DB.GetRSFormat(con, "SELECT iw.RestrictedQuantity, iw.MinOrderQuantity FROM InventoryItem i with (NOLOCK) INNER JOIN InventoryItemWebOption iw with (NOLOCK) ON i.ItemCode = iw.ItemCode AND iw.WebsiteCode = {0} WHERE i.ItemCode = {1}", DB.SQuote(InterpriseHelper.ConfigInstance.WebSiteCode), DB.SQuote(itemCode)))
                                {
                                    if (reader.Read())
                                    {
                                        string  restrictedQuantitiesValue = DB.RSField(reader, "RestrictedQuantity");
                                        decimal minimumOrderQuantity      = Convert.ToDecimal(DB.RSFieldDecimal(reader, "MinOrderQuantity"));
                                        if (!CommonLogic.IsStringNullOrEmpty(restrictedQuantitiesValue))
                                        {
                                            string[] quantityValues = restrictedQuantitiesValue.Split(',');
                                            if (quantityValues.Length > 0)
                                            {
                                                int  ctr  = 0;
                                                bool loop = true;
                                                while (loop)
                                                {
                                                    int    quantity      = 0;
                                                    string quantityValue = quantityValues[ctr];
                                                    if (int.TryParse(quantityValue, out quantity))
                                                    {
                                                        if (quantity >= minimumOrderQuantity)
                                                        {
                                                            itemQuantity = quantity;
                                                            loop         = false;
                                                        }
                                                    }
                                                    ctr++;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (minimumOrderQuantity > 0)
                                            {
                                                itemQuantity = minimumOrderQuantity;
                                            }
                                        }
                                    }
                                }
                            }
                            // Add the selected Order Option....
                            Guid cartItemId = Guid.Empty;
                            cart.AddItem(ThisCustomer, ThisCustomer.PrimaryShippingAddressID, itemCode, int.Parse(hfCounter.Value), itemQuantity, unitMeasureCode, CartTypeEnum.ShoppingCart);
                        }
                    }
                }

                if (hasCheckedOptions)
                {
                    //refresh the option items
                    RenderOrderOptions();
                }

                if (OrderNotes.Visible)
                {
                    string sOrderNotes = CommonLogic.CleanLevelOne(OrderNotes.Text);
                    //check the length of order notes
                    //should not exceed 255 characters including spaces
                    if (sOrderNotes.Length > DomainConstants.ORDER_NOTE_MAX_LENGTH)
                    {
                        sOrderNotes = sOrderNotes.Substring(0, DomainConstants.ORDER_NOTE_MAX_LENGTH);
                    }

                    DB.ExecuteSQL(
                        String.Format("UPDATE Customer SET Notes = {0} WHERE CustomerCode = {1}",
                                      sOrderNotes.ToDbQuote(),
                                      ThisCustomer.CustomerCode.ToDbQuote())
                        );
                }
            }
            bool validated = true;

            if (cart.InventoryTrimmed)
            {
                // inventory got adjusted, send them back to the cart page to confirm the new values!
                ErrorMsgLabel.Text += Server.UrlDecode(AppLogic.GetString("shoppingcart.cs.43", SkinID, ThisCustomer.LocaleSetting));
                validated           = false;
            }
            cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false, true);

            if (AppLogic.AppConfigBool("ShowShipDateInCart") && AppLogic.AppConfigBool("ShowStockHints"))
            {
                cart.BuildSalesOrderDetails();
            }

            if (cte == CartTypeEnum.WishCart)
            {
                Response.Redirect("wishlist.aspx");
            }
            if (cte == CartTypeEnum.GiftRegistryCart)
            {
                Response.Redirect("giftregistry.aspx");
            }

            if (DoingFullCheckout)
            {
                if (!cart.MeetsMinimumOrderAmount(AppLogic.AppConfigUSDecimal("CartMinOrderAmount")))
                {
                    validated = false;
                }

                if (!cart.MeetsMinimumOrderQuantity(AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout")))
                {
                    validated = false;
                }

                string couponCode         = string.Empty;
                string couponErrorMessage = string.Empty;
                if (cart.HasCoupon(ref couponCode) && !cart.IsCouponValid(ThisCustomer, couponCode, ref couponErrorMessage))
                {
                    validated = false;
                }

                //One page checkout is not implemented in mobile.

                //if (AppLogic.AppConfigBool("Checkout.UseOnePageCheckout") && !cart.HasMultipleShippingAddresses())
                //{
                //    Response.Redirect("checkout1.aspx");
                //}

                if (validated)
                {
                    if (ThisCustomer.IsRegistered && (ThisCustomer.PrimaryBillingAddressID == string.Empty)) // || !ThisCustomer.HasAtLeastOneAddress()
                    {
                        Response.Redirect("selectaddress.aspx?add=true&setPrimary=true&checkout=true&addressType=Billing");
                    }

                    if (ThisCustomer.IsRegistered && (ThisCustomer.PrimaryShippingAddressID == string.Empty)) //  || !ThisCustomer.HasAtLeastOneAddress()
                    {
                        Response.Redirect("selectaddress.aspx?add=true&setPrimary=true&checkout=False&addressType=Shipping");
                    }

                    if (ThisCustomer.IsNotRegistered || ThisCustomer.PrimaryBillingAddressID == string.Empty || ThisCustomer.PrimaryShippingAddressID == string.Empty || !ThisCustomer.HasAtLeastOneAddress())
                    {
                        Response.Redirect("checkoutanon.aspx?checkout=true");
                    }
                    else
                    {
                        if (AppLogic.AppConfigBool("SkipShippingOnCheckout") ||
                            !cart.HasShippableComponents())
                        {
                            cart.MakeShippingNotRequired();
                            Response.Redirect("checkoutpayment.aspx");
                        }

                        if ((cart.HasMultipleShippingAddresses() && cart.NumItems() <= AppLogic.MultiShipMaxNumItemsAllowed() && cart.CartAllowsShippingMethodSelection))
                        {
                            Response.Redirect("checkoutshippingmult.aspx");
                        }
                        else
                        {
                            Response.Redirect("checkoutshipping.aspx");
                        }
                    }
                }
                InitializePageContent();
            }
        }
示例#6
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);
            }
        }
示例#7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            if (AppLogic.AppConfigBool("RequireOver13Checked") && !ThisCustomer.IsOver13)
            {
                Response.Redirect("shoppingcart.aspx?errormsg=" + Server.UrlEncode(AppLogic.GetString("checkout.over13required", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
            }

            if (ThisCustomer.IsCreditOnHold)
            {
                Response.Redirect("shoppingcart.aspx");
            }

            RequireSecurePage();

            // -----------------------------------------------------------------------------------------------
            // NOTE ON PAGE LOAD LOGIC:
            // We are checking here for required elements to allowing the customer to stay on this page.
            // Many of these checks may be redundant, and they DO add a bit of overhead in terms of db calls, but ANYTHING really
            // could have changed since the customer was on the last page. Remember, the web is completely stateless. Assume this
            // page was executed by ANYONE at ANYTIME (even someone trying to break the cart).
            // It could have been yesterday, or 1 second ago, and other customers could have purchased limitied inventory products,
            // coupons may no longer be valid, etc, etc, etc...
            // -----------------------------------------------------------------------------------------------
            ThisCustomer.RequireCustomerRecord();
            if (ThisCustomer.IsNotRegistered &&
                !AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") &&
                !AppLogic.AppConfigBool("Checkout.UseOnePageCheckout"))
            {
                Response.Redirect("createaccount.aspx?checkout=true");
            }
            if (ThisCustomer.IsRegistered && (ThisCustomer.PrimaryBillingAddressID == String.Empty || ThisCustomer.PrimaryShippingAddressID == String.Empty))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("checkoutpayment.aspx.1", SkinID, ThisCustomer.LocaleSetting)));
            }

            SectionTitle = AppLogic.GetString("checkoutreview.aspx.1", SkinID, ThisCustomer.LocaleSetting);
            cart         = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, String.Empty, false, true);

            if (cart.IsEmpty())
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (cart.HasRegistryItems())
            {
                Response.Redirect("shoppingcart.aspx");
            }

            if (cart.InventoryTrimmed)
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + Server.UrlEncode(AppLogic.GetString("shoppingcart.aspx.1", SkinID, ThisCustomer.LocaleSetting)));
            }

            string couponCode         = string.Empty;
            string couponErrorMessage = string.Empty;

            if (cart.HasCoupon(ref couponCode) && !cart.IsCouponValid(ThisCustomer, couponCode, ref couponErrorMessage))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&discountvalid=false");
            }

            if (!cart.MeetsMinimumOrderAmount(AppLogic.AppConfigUSDecimal("CartMinOrderAmount")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (!cart.MeetsMinimumOrderQuantity(AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout")))
            {
                Response.Redirect("shoppingcart.aspx?resetlinkback=1");
            }

            if (!IsPostBack)
            {
                InitializePageContent();
            }
        }