Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SectionTitle = "Wallet";

            RequireSecurePage();
            ThisCustomer.RequireCustomerRecord();
        }
Exemple #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            String PM = AppLogic.CleanPaymentMethod(AppLogic.ro_PMPayPal);

            AppLogic.ValidatePM(PM); // this WILL throw a hard security exception on any problem!

            ThisCustomer.RequireCustomerRecord();
            if (!ThisCustomer.IsRegistered && !AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout"))
            {
                Response.Redirect("createaccount.aspx?checkout=true");
            }

            SectionTitle = AppLogic.GetString("paypalcancel.aspx.1", SkinID, ThisCustomer.LocaleSetting);
            int OrderNumber = CommonLogic.QueryStringUSInt("OrderNumber");

            if (OrderNumber != 0 && AppLogic.AppConfigBool("PayPal.UseInstantNotification"))
            {
                if (!Order.OrderHasCleared(OrderNumber))
                {
                }
            }
            Label1.Text = AppLogic.GetString("paypalcancel.aspx.2", SkinID, ThisCustomer.LocaleSetting);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            bool phoneCustomer = ((HttpContext.Current.Items["IsBeingImpersonated"] != null) && ((string)HttpContext.Current.Items["IsBeingImpersonated"] == "true"));

            if (phoneCustomer)
            {
                Response.Redirect("checkoutshipping.aspx");
            }

            SectionTitle = AppLogic.GetString("smartcheckout.aspx.164", SkinID, Customer.Current.LocaleSetting);

            Response.CacheControl = "private";
            Response.Expires      = -1;
            Response.AddHeader("pragma", "no-cache");

            RequireSecurePage();
            ThisCustomer.RequireCustomerRecord();

            if (!Page.IsPostBack)
            {
                ((SkinBase)Page).OPCShoppingCart.ValidProceedCheckout(); // will not come back from this if any issue. they are sent back to the cart page!
            }

            if (AppLogic.AppConfigBool("PayPal.Express.UseIntegratedCheckout"))
            {
                ltPayPalIntegratedCheckout.Text = AspDotNetStorefrontGateways.Processors.PayPalController.GetExpressCheckoutIntegratedScript(false);
            }
        }
Exemple #4
0
        private void ProcessViewProductWhoViewed()
        {
            int sessionLifetime = AppLogic.AppConfigUSInt("ViewedProductsSessionLifetime");

            if (sessionLifetime == null)
            {
                sessionLifetime = 1;
            }

            if (!ThisCustomer.HasCustomerRecord)
            {
                ThisCustomer.RequireCustomerRecord();
            }

            DateTime expirationdatetime = DateTime.Now.AddDays(-sessionLifetime);
            string   updatevieweditems  =
                string.Format("exec UpdateRecordsEcommerceViewedItems @ExpirationDate = {0}, @WebSiteCode = {1}, @ContactCode = {2}, @ItemCode = {3}, @CurrentDate = {4}, @SessionID = {5}",
                              DB.SQuote(Localization.DateTimeStringForDB(expirationdatetime)),
                              DB.SQuote(InterpriseHelper.ConfigInstance.WebSiteCode),
                              DB.SQuote(ThisCustomer.ContactCode),
                              DB.SQuote(_itemCode),
                              DB.SQuote(Localization.DateTimeStringForDB(DateTime.Now)),
                              ThisCustomer.CurrentSessionID);

            DB.ExecuteSQL(updatevieweditems);
        }
        private void PerformPageAccessLogic()
        {
            ReturnURL = CommonLogic.QueryStringCanBeDangerousContent("ReturnURL");
            if (ReturnURL.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1)
            {
                throw new ArgumentException("SECURITY EXCEPTION");
            }

            AddressTypeString = CommonLogic.QueryStringCanBeDangerousContent("AddressType");
            if (AddressTypeString.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1)
            {
                throw new ArgumentException("SECURITY EXCEPTION");
            }

            ThisCustomer.RequireCustomerRecord();

            if (CommonLogic.QueryStringBool("editaddress") && !ThisCustomer.IsRegistered)
            {
                string url = CommonLogic.IIF(AppLogic.AppConfigBool("Checkout.UseOnePageCheckout"), "checkout1.aspx", String.Format("createaccount.aspx?checkout=true&skipreg=true&editaddress=true"));
                Response.Redirect(url);
            }

            if (!Shipping.MultiShipEnabled())
            {
                RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
            }

            if (AddressTypeString.Length != 0)
            {
                AddressType = (AddressTypes)Enum.Parse(typeof(AddressTypes), AddressTypeString, true);
            }
            if (AddressType == AddressTypes.Unknown)
            {
                AddressType       = AddressTypes.Shipping;
                AddressTypeString = "Shipping";
            }

            custAddresses = new Addresses();
            custAddresses.LoadCustomer(ThisCustomer, AddressType);

            if (AddressType == AddressTypes.Shipping)
            {
                ButtonImage = AppLogic.LocateImageURL("skins/Skin_" + SkinID.ToString() + "/images/usethisshippingaddress.gif", ThisCustomer.LocaleSetting);
            }
            else
            {
                ButtonImage = AppLogic.LocateImageURL("skins/Skin_" + SkinID.ToString() + "/images/usethisbillingaddress.gif", ThisCustomer.LocaleSetting);
            }
        }
Exemple #6
0
        private void PerformPageAccessLogic()
        {
            ReturnURL = CommonLogic.QueryStringCanBeDangerousContent("ReturnURL");
            if (ReturnURL.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1)
            {
                throw new ArgumentException("SECURITY EXCEPTION");
            }
            AddressTypeString = CommonLogic.QueryStringCanBeDangerousContent("AddressType");
            if (AddressTypeString.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1)
            {
                throw new ArgumentException("SECURITY EXCEPTION");
            }

            ThisCustomer.RequireCustomerRecord();
            if (!Shipping.MultiShipEnabled())
            {
                RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
            }

            if (AddressTypeString.Length != 0)
            {
                AddressType = (AddressTypes)Enum.Parse(typeof(AddressTypes), AddressTypeString, true);
            }
            if (AddressType == AddressTypes.Unknown)
            {
                AddressType       = AddressTypes.Shipping;
                AddressTypeString = "Shipping";
            }

            custAddresses = new Addresses();
            custAddresses.LoadCustomer(ThisCustomer, AddressType);

            if (AddressType == AddressTypes.Shipping)
            {
                ButtonImage = AppLogic.LocateImageURL("skins/Skin_" + SkinID.ToString() + "/images/usethisshippingaddress.gif", ThisCustomer.LocaleSetting);
            }
            else
            {
                ButtonImage = AppLogic.LocateImageURL("skins/Skin_" + SkinID.ToString() + "/images/usethisbillingaddress.gif", ThisCustomer.LocaleSetting);
            }
        }
        /// <summary>
        /// Performs the necessary action for this control per postback
        /// </summary>
        /// <param name="selectedValue"></param>
        protected override void DoPostbackRoutine(string selectedValue)
        {
            ThisCustomer.RequireCustomerRecord();
            ThisCustomer.LocaleSetting = selectedValue;

            String CurrencySetting = AppLogic.GetLocaleDefaultCurrency(selectedValue);

            if (CommonLogic.IsStringNullOrEmpty(CurrencySetting))
            {
                CurrencySetting = CommonLogic.QueryStringCanBeDangerousContent("Currency");
            }
            if (CommonLogic.IsStringNullOrEmpty(CurrencySetting))
            {
                CurrencySetting = Localization.GetPrimaryCurrency();
            }

            AppLogic.CheckForScriptTag(CurrencySetting);
            CurrencySetting = Localization.CheckCurrencySettingForProperCase(CurrencySetting);
            ThisCustomer.CurrencySetting = CurrencySetting;

            RefreshPage();
        }
        private void HandleKitUpdate()
        {
            ThisCustomer.RequireCustomerRecord();
            AppLogic.ProcessKitForm(ThisCustomer, ProductID);
            if (CommonLogic.FormUSInt("CartRecID") > 0)
            {
                switch (ShoppingCart.CartTypeFromRecID(CommonLogic.FormUSInt("CartRecID")))
                {
                case CartTypeEnum.GiftRegistryCart:
                    Response.Redirect(ResolveClientUrl("~/giftregistry.aspx"));
                    break;

                case CartTypeEnum.ShoppingCart:
                    Response.Redirect(ResolveClientUrl("~/shoppingcart.aspx"));
                    break;

                case CartTypeEnum.WishCart:
                    Response.Redirect(ResolveClientUrl("~/wishlist.aspx"));
                    break;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            bool phoneCustomer = ((HttpContext.Current.Items["IsBeingImpersonated"] != null) && ((string)HttpContext.Current.Items["IsBeingImpersonated"] == "true"));

            if (phoneCustomer)
            {
                Response.Redirect("checkoutshipping.aspx");
            }

            Response.CacheControl = "private";
            Response.Expires      = -1;
            Response.AddHeader("pragma", "no-cache");

            RequireSecurePage();
            ThisCustomer.RequireCustomerRecord();

            if (!Page.IsPostBack)
            {
                ShoppingCart cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);

                cart.ValidProceedCheckout();                 // will not come back from this if any issue. they are sent back to the cart page!
            }
        }
Exemple #10
0
        /// <summary>
        /// Performs the necessary action for this control per postback
        /// </summary>
        /// <param name="selectedValue"></param>
        protected override void DoPostbackRoutine(string selectedValue)
        {
            String VATSetting = Customer.ValidateVATSetting(selectedValue);
            String vtr        = "";

            ThisCustomer.RequireCustomerRecord();

            VATSettingEnum vt = (VATSettingEnum)System.Int32.Parse(VATSetting);

            ThisCustomer.VATSettingRAW = vt;

            Exception vatServiceException;

            if (vtr.Length != 0 && !AppLogic.VATRegistrationIDIsValid(ThisCustomer, vtr, out vatServiceException))
            {
                vtr = String.Empty;
            }
            if (ThisCustomer.VATRegistrationID != vtr)
            {
                ThisCustomer.SetVATRegistrationID(vtr);
            }

            RefreshPage();
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            ThisCustomer.RequireCustomerRecord();

            String ReturnURL = CommonLogic.QueryStringCanBeDangerousContent("ReturnURL");

            AppLogic.CheckForScriptTag(ReturnURL);

            CartTypeEnum CartType = CartTypeEnum.ShoppingCart;

            if (CommonLogic.FormNativeInt("IsWishList") == 1 || CommonLogic.QueryStringUSInt("IsWishList") == 1)
            {
                CartType = CartTypeEnum.WishCart;
            }
            if (CommonLogic.FormNativeInt("IsGiftRegistry") == 1 || CommonLogic.QueryStringUSInt("IsGiftRegistry") == 1)
            {
                CartType = CartTypeEnum.GiftRegistryCart;
            }
            if (AppLogic.HideForWholesaleSite(ThisCustomer.CustomerLevelID))
            {
                Response.Redirect("Default.aspx");
            }

            if (!ThisCustomer.IsRegistered && AppLogic.AppConfigBool("DisallowAnonCustomerToCreateWishlist") && AppLogic.ProductIsMLExpress() == false)
            {
                string ErrMsg = string.Empty;

                ErrorMessage er;

                if (CommonLogic.FormNativeInt("IsWishList") == 1 || CommonLogic.QueryStringUSInt("IsWishList") == 1)
                {
                    ErrMsg = AppLogic.GetString("signin.aspx.27", 1, ThisCustomer.LocaleSetting);
                    er     = new ErrorMessage(ErrMsg);
                    Response.Redirect("signin.aspx?ErrorMsg=" + er.MessageId + "&ReturnUrl=" + Security.UrlEncode(ReturnURL));
                }

                if (CommonLogic.FormNativeInt("IsGiftRegistry") == 1 || CommonLogic.QueryStringUSInt("IsGiftRegistry") == 1)
                {
                    ErrMsg = AppLogic.GetString("signin.aspx.28", 1, ThisCustomer.LocaleSetting);
                    er     = new ErrorMessage(ErrMsg);
                    Response.Redirect("signin.aspx?ErrorMsg=" + er.MessageId + "&ReturnUrl=" + Security.UrlEncode(ReturnURL));
                }
            }

            // if editing, nuke what was there, it will be replaced from what was submitted now from the product page.
            // NOTE. if a kit or pack was "edited", you don't have to do this, and ShoppingCartRecID is not material (and should not be in the form post)
            // kits and packs are "moved" from active cart to temp cart records, so they won't have a cart record id to begin with. They are built in the KitCart and CustomCart tables instead
            int ShoppingCartRecID = CommonLogic.FormUSInt("CartRecID"); // only used for (non kit or pack) product/order edits from prior cart record

            if (ShoppingCartRecID == 0)
            {
                ShoppingCartRecID = CommonLogic.QueryStringUSInt("CartRecID");
            }
            if (ShoppingCartRecID != 0)
            {
                DB.ExecuteSQL("delete from ShoppingCart where ShoppingCartRecID=" + ShoppingCartRecID.ToString() + " and CustomerID=" + ThisCustomer.CustomerID.ToString() + " and CartType=" + ((int)CartType).ToString() + " and StoreID = " + AppLogic.StoreID());
            }

            int ShippingAddressID = CommonLogic.QueryStringUSInt("ShippingAddressID"); // only used for multi-ship

            if (ShippingAddressID == 0)
            {
                ShippingAddressID = CommonLogic.FormNativeInt("ShippingAddressID");
            }
            if ((ShippingAddressID == 0 || !ThisCustomer.OwnsThisAddress(ShippingAddressID)) && ThisCustomer.PrimaryShippingAddressID != 0)
            {
                ShippingAddressID = ThisCustomer.PrimaryShippingAddressID;
            }

            int ProductID = CommonLogic.QueryStringUSInt("ProductID");

            if (ProductID == 0)
            {
                ProductID = CommonLogic.FormUSInt("ProductID");
            }

            int VariantID = CommonLogic.QueryStringUSInt("VariantID");

            if (VariantID == 0)
            {
                VariantID = CommonLogic.FormUSInt("VariantID");
            }
            if (ProductID == 0)
            {
                ProductID = AppLogic.GetVariantProductID(VariantID);
            }

            // if no VariantID is located, get the default variantID for the product
            if (VariantID == 0)
            {
                VariantID = AppLogic.GetDefaultProductVariant(ProductID);
            }

            int Quantity = CommonLogic.QueryStringUSInt("Quantity");

            if (Quantity == 0)
            {
                Quantity = CommonLogic.FormNativeInt("Quantity");
            }
            if (Quantity == 0)
            {
                Quantity = 1;
            }

            VariantStyleEnum VariantStyle = (VariantStyleEnum)CommonLogic.QueryStringUSInt("VariantStyle");

            if (CommonLogic.QueryStringCanBeDangerousContent("VariantStyle").Length == 0)
            {
                VariantStyle = (VariantStyleEnum)CommonLogic.FormNativeInt("VariantStyle");
            }

            decimal CustomerEnteredPrice = CommonLogic.FormNativeDecimal("Price");

            if (CustomerEnteredPrice == System.Decimal.Zero)
            {
                CustomerEnteredPrice = CommonLogic.QueryStringNativeDecimal("Price");
            }
            if (!AppLogic.VariantAllowsCustomerPricing(VariantID))
            {
                CustomerEnteredPrice = System.Decimal.Zero;
            }
            if (CustomerEnteredPrice < System.Decimal.Zero)
            {
                CustomerEnteredPrice = -CustomerEnteredPrice;
            }
            int CustomerID = ThisCustomer.CustomerID;

            if (Currency.GetDefaultCurrency() != ThisCustomer.CurrencySetting && CustomerEnteredPrice != 0)
            {
                CustomerEnteredPrice = Currency.Convert(CustomerEnteredPrice, ThisCustomer.CurrencySetting, Localization.StoreCurrency());
            }


            // QueryString params override Form Params!

            String ChosenColor            = String.Empty;
            String ChosenColorSKUModifier = String.Empty;
            String ChosenSize             = String.Empty;
            String ChosenSizeSKUModifier  = String.Empty;
            String TextOption             = CommonLogic.FormCanBeDangerousContent("TextOption");

            if (CommonLogic.QueryStringCanBeDangerousContent("TextOption").Length != 0)
            {
                TextOption = Security.HtmlEncode(CommonLogic.QueryStringCanBeDangerousContent("TextOption"));
            }


            // the color & sizes coming in here are MUST be in the Master WebConfig Locale ALWAYS!
            if (CommonLogic.QueryStringCanBeDangerousContent("Color").Length != 0)
            {
                String[] ColorSel = CommonLogic.QueryStringCanBeDangerousContent("Color").Split(',');
                try
                {
                    ChosenColor = Security.HtmlEncode(ColorSel[0]);
                }
                catch { }
                try
                {
                    ChosenColorSKUModifier = Security.HtmlEncode(ColorSel[1]);
                }
                catch { }
            }

            if (ChosenColor.Length == 0 && CommonLogic.FormCanBeDangerousContent("Color").Length != 0)
            {
                String[] ColorSel = CommonLogic.FormCanBeDangerousContent("Color").Split(',');
                try
                {
                    ChosenColor = Security.HtmlEncode(ColorSel[0]).Trim();
                }
                catch { }
                try
                {
                    ChosenColorSKUModifier = Security.HtmlEncode(ColorSel[1]);
                }
                catch { }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("Size").Length != 0)
            {
                String[] SizeSel = CommonLogic.QueryStringCanBeDangerousContent("Size").Split(',');
                try
                {
                    ChosenSize = Security.HtmlEncode(SizeSel[0]).Trim();
                }
                catch { }
                try
                {
                    ChosenSizeSKUModifier = Security.HtmlEncode(SizeSel[1]);
                }
                catch { }
            }

            if (ChosenSize.Length == 0 && CommonLogic.FormCanBeDangerousContent("Size").Length != 0)
            {
                String[] SizeSel = CommonLogic.FormCanBeDangerousContent("Size").Split(',');
                try
                {
                    ChosenSize = Security.HtmlEncode(SizeSel[0]).Trim();
                }
                catch { }
                try
                {
                    ChosenSizeSKUModifier = Security.HtmlEncode(SizeSel[1]);
                }
                catch { }
            }


            if (VariantStyle == VariantStyleEnum.ERPWithRollupAttributes)
            {
                String match  = "<GroupAttributes></GroupAttributes>";
                String match2 = "<GroupAttributes></GroupAttributes>";
                if (ChosenSize.Trim().Length != 0 && ChosenColor.Trim().Length != 0)
                {
                    match  = "<GroupAttributes><GroupAttributeName=\"Attr1\"Value=\"" + ChosenSize + "\"/><GroupAttributeName=\"Attr2\"Value=\"" + ChosenColor + "\"/></GroupAttributes>";
                    match2 = "<GroupAttributes><GroupAttributeName=\"Attr1\"Value=\"" + ChosenColor + "\"/><GroupAttributeName=\"Attr2\"Value=\"" + ChosenSize + "\"/></GroupAttributes>";
                }
                else if (ChosenSize.Trim().Length != 0 && ChosenColor.Trim().Length == 0)
                {
                    match = "<GroupAttributes><GroupAttributeName=\"Attr1\"Value=\"" + ChosenSize + "\"/></GroupAttributes>";
                }
                else if (ChosenSize.Trim().Length == 0 && ChosenColor.Trim().Length != 0)
                {
                    match = "<GroupAttributes><GroupAttributeName=\"Attr1\"Value=\"" + ChosenColor + "\"/></GroupAttributes>";
                }

                // reset variant id to the proper attribute match!
                using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                {
                    con.Open();
                    using (IDataReader rsERP = DB.GetRS("select VariantID,ExtensionData2 from ProductVariant with (NOLOCK) where VariantID=" + VariantID.ToString(), con))
                    {
                        while (rsERP.Read())
                        {
                            String thisVariantMatch = DB.RSField(rsERP, "ExtensionData2").Replace(" ", "").Trim();
                            match = Regex.Replace(match, "\\s+", "", RegexOptions.Compiled);

                            match2 = Regex.Replace(match2, "\\s+", "", RegexOptions.Compiled);

                            thisVariantMatch = Regex.Replace(thisVariantMatch, "\\s+", "", RegexOptions.Compiled);
                            if (match.Equals(thisVariantMatch, StringComparison.InvariantCultureIgnoreCase) ||
                                match2.Equals(thisVariantMatch, StringComparison.InvariantCultureIgnoreCase))
                            {
                                VariantID = DB.RSFieldInt(rsERP, "VariantID");
                                break;
                            }
                        }
                    }
                }
            }

            ShoppingCart cart = new ShoppingCart(1, ThisCustomer, CartType, 0, false);

            if (Quantity > 0)
            {
                if (AppLogic.IsAKit(ProductID))
                {
                    // -- new kit format -- //
                    bool productIsUsingKit2XmlPackage = !CommonLogic.IsStringNullOrEmpty(CommonLogic.FormCanBeDangerousContent("KitItems"));
                    if (productIsUsingKit2XmlPackage)
                    {
                        if (CommonLogic.FormBool("IsEditKit") && CommonLogic.FormUSInt("CartRecID") > 0)
                        {
                            int cartId = CommonLogic.FormUSInt("CartRecID");
                            AppLogic.ClearKitItems(ThisCustomer, ProductID, VariantID, cartId);
                        }

                        KitComposition preferredComposition = KitComposition.FromForm(ThisCustomer, ProductID, VariantID);

                        String tmp      = DB.GetNewGUID();
                        int    NewRecID = cart.AddItem(ThisCustomer, ShippingAddressID, ProductID, VariantID, Quantity, string.Empty, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier, TextOption, CartType, false, false, 0, System.Decimal.Zero, preferredComposition);
                    }
                    else
                    {
                        String tmp      = DB.GetNewGUID();
                        int    NewRecID = cart.AddItem(ThisCustomer, ShippingAddressID, ProductID, VariantID, Quantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier, TextOption, CartType, false, false, 0, System.Decimal.Zero);
                    }
                }
                else
                {
                    cart.AddItem(ThisCustomer, ShippingAddressID, ProductID, VariantID, Quantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier, TextOption, CartType, false, false, 0, CustomerEnteredPrice);
                }
            }

            // handle upsell products:
            String UpsellProducts = CommonLogic.FormCanBeDangerousContent("UpsellProducts").Trim();

            if (UpsellProducts.Length != 0 && CartType == CartTypeEnum.ShoppingCart)
            {
                foreach (String s in UpsellProducts.Split(','))
                {
                    String PID = s.Trim();
                    if (PID.Length != 0)
                    {
                        int UpsellProductID = 0;
                        try
                        {
                            UpsellProductID = Localization.ParseUSInt(PID);
                            if (UpsellProductID != 0)
                            {
                                int UpsellVariantID = AppLogic.GetProductsFirstVariantID(UpsellProductID);
                                if (UpsellVariantID != 0)
                                {
                                    // this variant COULD have one size or color, so set it up like that:
                                    String Sizes             = String.Empty;
                                    String SizeSKUModifiers  = String.Empty;
                                    String Colors            = String.Empty;
                                    String ColorSKUModifiers = String.Empty;

                                    using (SqlConnection con = new SqlConnection(DB.GetDBConn()))
                                    {
                                        con.Open();
                                        using (IDataReader rs = DB.GetRS("select Sizes,SizeSKUModifiers,Colors,ColorSKUModifiers from ProductVariant  with (NOLOCK)  where VariantID=" + UpsellVariantID.ToString(), con))
                                        {
                                            if (rs.Read())
                                            {
                                                Sizes             = DB.RSFieldByLocale(rs, "Sizes", Localization.GetDefaultLocale());
                                                SizeSKUModifiers  = DB.RSFieldByLocale(rs, "SizeSKUModifiers", Localization.GetDefaultLocale());
                                                Colors            = DB.RSFieldByLocale(rs, "Colors", Localization.GetDefaultLocale());
                                                ColorSKUModifiers = DB.RSFieldByLocale(rs, "ColorSKUModifiers", Localization.GetDefaultLocale());
                                            }
                                        }
                                    }

                                    // safety check:
                                    if (Sizes.IndexOf(',') != -1)
                                    {
                                        Sizes            = String.Empty;
                                        SizeSKUModifiers = String.Empty;
                                    }
                                    // safety check:
                                    if (Colors.IndexOf(',') != -1)
                                    {
                                        Colors            = String.Empty;
                                        ColorSKUModifiers = String.Empty;
                                    }
                                    cart.AddItem(ThisCustomer, ShippingAddressID, UpsellProductID, UpsellVariantID, 1, Colors, ColorSKUModifiers, Sizes, SizeSKUModifiers, String.Empty, CartType, false, false, 0, System.Decimal.Zero);
                                    Decimal PR = AppLogic.GetUpsellProductPrice(ProductID, UpsellProductID, ThisCustomer.CustomerLevelID);
                                    DB.ExecuteSQL("update shoppingcart set IsUpsell=1, ProductPrice=" + Localization.CurrencyStringForDBWithoutExchangeRate(PR) + " where CartType=" + ((int)CartType).ToString() + " and CustomerID=" + ThisCustomer.CustomerID.ToString() + " and ProductID=" + UpsellProductID.ToString() + " and VariantID=" + UpsellVariantID.ToString() + " and convert(nvarchar(1000),ChosenColor)='' and convert(nvarchar(1000),ChosenSize)='' and convert(nvarchar(1000),TextOption)=''");
                                }
                            }
                        }
                        catch { }
                    }
                }
            }

            cart = null;

            AppLogic.eventHandler("AddToCart").CallEvent("&AddToCart=true&VariantID=" + VariantID.ToString() + "&ProductID=" + ProductID.ToString() + "&ChosenColor=" + ChosenColor + "&ChosenSize=" + ChosenSize);

            if (AppLogic.AppConfig("AddToCartAction").Equals("STAY", StringComparison.InvariantCultureIgnoreCase) &&
                ReturnURL.Length != 0)
            {
                Response.Redirect(ReturnURL);
            }
            else
            {
                if (ReturnURL.Length == 0)
                {
                    ReturnURL = String.Empty;
                    if (Request.UrlReferrer != null)
                    {
                        ReturnURL = Request.UrlReferrer.AbsoluteUri; // could be null
                    }
                    if (ReturnURL == null)
                    {
                        ReturnURL = String.Empty;
                    }
                }
                if (CartType == CartTypeEnum.WishCart)
                {
                    Response.Redirect("wishlist.aspx?ReturnUrl=" + Security.UrlEncode(ReturnURL));
                }
                if (CartType == CartTypeEnum.GiftRegistryCart)
                {
                    Response.Redirect("giftregistry.aspx?ReturnUrl=" + Security.UrlEncode(ReturnURL));
                }
                Response.Redirect("ShoppingCart.aspx?add=true&ReturnUrl=" + Security.UrlEncode(ReturnURL));
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            MobileHelper.RedirectPageWhenMobileIsDisabled("~/address.aspx", ThisCustomer);

            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            RequireSecurePage();
            ThisCustomer.RequireCustomerRecord();

            if (!ThisCustomer.IsRegistered)
            {
                Response.Redirect("mobilecreateaccount.aspx?" + BuildRedirectQuerystring());
            }

            SectionTitle     = AppLogic.GetString("createaccount.aspx.1", SkinID, ThisCustomer.LocaleSetting);
            Checkout         = CommonLogic.QueryStringBool("checkout");
            SkipRegistration = CommonLogic.QueryStringBool("skipreg");
            checkouttype     = CommonLogic.QueryStringCanBeDangerousContent("checkouttype");

            if (CommonLogic.QueryStringCanBeDangerousContent("addresstype").ToLower() == "shipping")
            {
                AddType = AddressTypes.Shipping;
            }

            MPAddressHeader.Text = AddType.ToString() + " Info";

            switch (AddType)
            {
            case AddressTypes.Shipping:
                btnUseForBothAddressTypes.Visible = false;
                btnUseForOneAddress.Text          = AppLogic.GetString("Mobile.GetAddress.ShipTo", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                btnUseForOneAddress.CssClass      = "fullwidthshortgreen action";
                break;

            default:
                btnUseForBothAddressTypes.Text = AppLogic.GetString("Mobile.GetAddress.Both", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                btnUseForOneAddress.Text       = AppLogic.GetString("Mobile.GetAddress.NewShip", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
                break;
            }

            if (Checkout)
            {
                SectionTitle = AppLogic.GetString("createaccount.aspx.2", SkinID, ThisCustomer.LocaleSetting) + SectionTitle;
                ShoppingCart cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
                cart.ValidProceedCheckout();
            }

            AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") &&
                                             !AppLogic.AppConfigBool("SkipShippingOnCheckout");
            ReturnURL = CommonLogic.QueryStringCanBeDangerousContent("ReturnURL");
            AppLogic.CheckForScriptTag(ReturnURL);
            ErrorMsgLabel.Text = "";

            if (!IsPostBack)
            {
                AddAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);
                InitializePageContent();
            }

            #region vortx init xmlpackage
            CheckoutHeader.Text = Vortx.MobileFramework.MobileXSLTExtensionBase.GetCheckoutHeader("address");
            #endregion
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = -1;
            Response.AddHeader("pragma", "no-cache");

            RequireSecurePage();

            SectionTitle = AppLogic.GetString("checkoutanon.aspx.1", SkinID, ThisCustomer.LocaleSetting);
            checkouttype = CommonLogic.QueryStringCanBeDangerousContent("checkouttype");

            // -----------------------------------------------------------------------------------------------
            // 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 (DisablePasswordAutocomplete)
            {
                AppLogic.DisableAutocomplete(Password);
                AppLogic.DisableAutocomplete(OldPassword);
                AppLogic.DisableAutocomplete(NewPassword);
                AppLogic.DisableAutocomplete(NewPassword2);
            }

            cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);

            cart.ValidProceedCheckout(); // will not come back from this if any issue. they are sent back to the cart page!

            if (AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") && !cart.HasRecurringComponents())
            {
                PasswordOptionalPanel.Visible = true;
            }

            ErrorMsgLabel.Text = "";
            if (!IsPostBack)
            {
                InitializePageContent();
            }
            if (AppLogic.AppConfigBool("SecurityCodeRequiredOnStoreLogin"))
            {
                // Create a random code and store it in the Session object.
                pnlSecurity.Visible             = true;
                SecurityImage.Visible           = true;
                SecurityCode2.Visible           = true;
                RequiredFieldValidator9.Enabled = true;
                ltSecurity.Visible = true;
                if (!IsPostBack)
                {
                    SecurityImage.ImageUrl = "Captcha.ashx?id=1";
                }
                else
                {
                    SecurityImage.ImageUrl = "Captcha.ashx?id=2";
                }
            }
        }
Exemple #14
0
        protected void AddToCart(CartTypeEnum cartType)
        {
            try
            {
                if (KitData.HasFileUploadGroup)
                {
                    KitData.MoveAllTempImagesToOrdered();
                }

                KitComposition composition = ComposeAddToCart();

                if (KitData.HasRequiredGroups)
                {
                    List <String> RequiredGroupNames = new List <String>();

                    foreach (KitGroupData requiredGroup in KitData.Groups)
                    {
                        if (requiredGroup.IsRequired)
                        {
                            int hasBeenSelected = composition.Compositions.Where(kci => kci.KitGroupID.Equals(requiredGroup.Id)).Count();
                            if (hasBeenSelected == 0)
                            {
                                RequiredGroupNames.Add(requiredGroup.Name);
                            }
                        }
                    }

                    if (RequiredGroupNames.Count > 0)
                    {
                        StringBuilder sb = new StringBuilder(1000);
                        sb.Append(AppLogic.GetString("product.kit2product.xml.config.16", ThisCustomer.LocaleSetting));
                        sb.Append("<ul  data-role=\"listview\">");
                        foreach (String requiredGroup in RequiredGroupNames)
                        {
                            sb.Append("<li>" + requiredGroup + "</li>");
                        }
                        sb.Append("</ul>");
                        ShowError(sb.ToString());
                        return;
                    }
                }

                String       tmp  = DB.GetNewGUID();
                ShoppingCart cart = new ShoppingCart(1, ThisCustomer, cartType, 0, false);

                int qty = GetQuantity();

                if (KitData.HasCartMapping)
                {
                    AppLogic.ClearKitItems(ThisCustomer, KitData.Id, KitData.VariantId, KitData.ShoppingCartRecordId);
                    CartItem lineItem = cart.CartItems.FirstOrDefault(item => item.ShoppingCartRecordID == KitData.ShoppingCartRecordId);
                    cart.SetItemQuantity(lineItem.ShoppingCartRecordID, qty);
                    cart.ProcessKitComposition(composition, KitData.Id, KitData.VariantId, KitData.ShoppingCartRecordId);
                }
                else
                {
                    //GFS - If customer a session has been cleared and no cookies are available, we must create a customer record to associate the new cart ID to.
                    //If this is not done, adding a kit product within the said environment will render an empty shopping cart.
                    ThisCustomer.RequireCustomerRecord();
                    int shipId   = ThisCustomer.PrimaryShippingAddressID;
                    int NewRecID = cart.AddItem(ThisCustomer,
                                                ThisCustomer.PrimaryShippingAddressID,
                                                KitData.Id, KitData.VariantId, qty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, cartType, false, false, 0, System.Decimal.Zero, composition);
                }
            }
            catch { }


            bool stayOnThisPage = AppLogic.AppConfig("AddToCartAction").Equals("STAY", StringComparison.InvariantCultureIgnoreCase);

            if (stayOnThisPage)
            {
                // some tokens like the shoppingcart qty may already be rendered
                // we therefore need to re-display the page to display the correct qty
                Response.Redirect(this.Request.Url.ToString());
            }
            else
            {
                string returnUrl = CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING");

                switch (cartType)
                {
                case CartTypeEnum.ShoppingCart:
                    Response.Redirect(ResolveClientUrl("~/ShoppingCart.aspx?add=true&ReturnUrl=" + Security.UrlEncode(returnUrl)));
                    break;

                case CartTypeEnum.GiftRegistryCart:
                    Response.Redirect(ResolveClientUrl("~/giftregistry.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                    break;

                case CartTypeEnum.WishCart:
                    Response.Redirect(ResolveClientUrl("~/wishlist.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                    break;
                }
            }
        }
        private void HandleAddToPack()
        {
            ThisCustomer.RequireCustomerRecord();

            int PackID     = CommonLogic.QueryStringUSInt("PackID");
            int ProductID  = CommonLogic.QueryStringUSInt("ProductID");
            int VariantID  = CommonLogic.QueryStringUSInt("VariantID");
            int CategoryID = CommonLogic.QueryStringUSInt("CategoryID");
            int SectionID  = CommonLogic.QueryStringUSInt("SectionID");
            int Quantity   = CommonLogic.QueryStringUSInt("Quantity");

            if (Quantity == 0)
            {
                Quantity = 1;
            }

            //If editing a pack is from the shopping cart
            bool FromCart  = (CommonLogic.QueryStringUSInt("CartRecID") > 0);
            int  CartRecID = CommonLogic.QueryStringUSInt("CartRecID");

            String ChosenColor            = String.Empty;
            String ChosenColorSKUModifier = String.Empty;
            String ChosenSize             = String.Empty;
            String ChosenSizeSKUModifier  = String.Empty;

            if (CommonLogic.QueryStringCanBeDangerousContent("Color").Length != 0)
            {
                String[] ColorSel = CommonLogic.QueryStringCanBeDangerousContent("Color").Split(',');
                try
                {
                    ChosenColor = ColorSel[0];
                }
                catch { }
                try
                {
                    ChosenColorSKUModifier = ColorSel[1];
                }
                catch { }
            }
            if (ChosenColor.Length != 0)
            {
                ThisCustomer.ThisCustomerSession["ChosenColor"] = ChosenColor;
            }


            if (CommonLogic.QueryStringCanBeDangerousContent("Size").Length != 0)
            {
                String[] SizeSel = CommonLogic.QueryStringCanBeDangerousContent("Size").Split(',');
                try
                {
                    ChosenSize = SizeSel[0];
                }
                catch { }
                try
                {
                    ChosenSizeSKUModifier = SizeSel[1];
                }
                catch { }
            }
            if (ChosenSize.Length != 0)
            {
                ThisCustomer.ThisCustomerSession["ChosenSize"] = ChosenSize;
            }

            if (Quantity > 0)
            {
                // add to custom cart:
                if (FromCart)
                {
                    CustomCart.AddItem(PackID, ProductID, VariantID, Quantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier, CartRecID, ThisCustomer, CartTypeEnum.ShoppingCart);
                }
                else
                {
                    CustomCart cart = new CustomCart(ThisCustomer, PackID, 1, CartTypeEnum.ShoppingCart);
                    cart.AddItem(ProductID, VariantID, Quantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier);
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("UpdateCartPack") == "")
            {
                String url = SE.MakeProductAndEntityLink(CommonLogic.QueryStringCanBeDangerousContent("entityname"), PackID, CommonLogic.QueryStringUSInt("entityid"), "");
                url = url + CommonLogic.IIF(FromCart, "?cartrecid=" + CartRecID.ToString(), "");

                RedirectMainContainer(url);
            }
            else
            {
                RedirectMainContainer("shoppingcart.aspx");
            }
        }
Exemple #16
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");
            _checkoutType = CommonLogic.QueryStringCanBeDangerousContent("checkoutType");

            RequireSecurePage();

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

            // -----------------------------------------------------------------------------------------------
            // 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();

            cart = new InterpriseShoppingCart(base.EntityHelpers, SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, String.Empty, false, true);

            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)));
            }

            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");
            }

            CheckoutMap.HotSpots[0].AlternateText = AppLogic.GetString("checkoutanon.aspx.2", SkinID, ThisCustomer.LocaleSetting, true);

            Teaser.SetContext = this;

            if (AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout"))
            {
                PasswordOptionalPanel.Visible = true;
            }

            ErrorMsgLabel.Text = "";
            if (!IsPostBack)
            {
                InitializePageContent();
            }

            if (AppLogic.AppConfigBool("SecurityCodeRequiredOnStoreLogin"))
            {
                // Create a random code and store it in the Session object.
                SecurityImage.Visible = true;
                SecurityCode.Visible  = true;

                trSecurityCodeText.Visible  = true;
                trSecurityCodeImage.Visible = true;

                Label4.Visible = true;
                if (!IsPostBack)
                {
                    SecurityImage.ImageUrl = "Captcha.ashx?id=1";
                }
                else
                {
                    SecurityImage.ImageUrl = "Captcha.ashx?id=2";
                }
            }
        }
Exemple #17
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            MobileHelper.RedirectPageWhenMobileIsDisabled("~/checkoutreview.aspx", ThisCustomer);

            if (cart.HasCoupon())
            {
                string CouponName = cart.Coupon.CouponCode;
                cart.ClearCoupon();
                cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
                cart.SetCoupon(CouponName, true);
            }

            Response.CacheControl = "private";
            Response.Expires      = -1;
            Response.AddHeader("pragma", "no-cache");

            ErrorMessage err;

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

            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();

            PaymentMethod = CommonLogic.QueryStringCanBeDangerousContent("PaymentMethod").Trim();
            PM            = AppLogic.CleanPaymentMethod(PaymentMethod);

            if (!ThisCustomer.IsRegistered)
            {
                bool boolAllowAnon = (AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") && !cart.HasRecurringComponents());

                if (!boolAllowAnon && (PM == AppLogic.ro_PMPayPalExpress || PM == AppLogic.ro_PMPayPalExpressMark))
                {
                    boolAllowAnon = AppLogic.AppConfigBool("PayPal.Express.AllowAnonCheckout");
                }

                if (!boolAllowAnon)
                {
                    Response.Redirect("createaccount.aspx?checkout=true");
                }
            }
            if (ThisCustomer.PrimaryBillingAddressID == 0 || (ThisCustomer.PrimaryShippingAddressID == 0 && !AppLogic.AppConfigBool("SkipShippingOnCheckout") && !cart.IsAllDownloadComponents() && !cart.IsAllSystemComponents()))
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutpayment.aspx.2", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + err.MessageId);
            }

            SectionTitle = AppLogic.GetString("checkoutreview.aspx.1", SkinID, ThisCustomer.LocaleSetting);
            //cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);


            // re-validate all shipping info, as ANYTHING could have changed since last page:
            if (!cart.ShippingIsAllValid())
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("shoppingcart.cs.95", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
                HttpContext.Current.Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + err.MessageId);
            }

            decimal CartTotal = cart.Total(true);
            decimal NetTotal  = CartTotal - CommonLogic.IIF(cart.Coupon.CouponType == CouponTypeEnum.GiftCard, CommonLogic.IIF(CartTotal < cart.Coupon.DiscountAmount, CartTotal, cart.Coupon.DiscountAmount), 0);

            if (NetTotal > System.Decimal.Zero || !AppLogic.AppConfigBool("SkipPaymentEntryOnZeroDollarCheckout"))
            {
                AppLogic.ValidatePM(PM); // this WILL throw a hard security exception on any problem!
            }

            String PayPalToken = ThisCustomer.ThisCustomerSession["PayPalExpressToken"];
            String PayerID     = ThisCustomer.ThisCustomerSession["PayPalExpressPayerID"];

            if ((PM == AppLogic.ro_PMPayPalExpress || PM == AppLogic.ro_PMPayPalExpressMark) &&
                (PayPalToken.Length == 0 || PayerID.Length == 0))
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutpayment.aspx.20", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("checkoutpayment.aspx?errormsg=" + err.MessageId);
            }

            if (!IsPostBack)
            {
                InitializePageContent();

                if ((PM == AppLogic.ro_PMPayPalExpress || PM == AppLogic.ro_PMPayPalExpressMark) &&
                    CommonLogic.QueryStringCanBeDangerousContent("useraction").Equals("COMMIT", StringComparison.InvariantCultureIgnoreCase))
                {
                    ContinueCheckout();
                }
            }
            if (cart.CartItems.Count == 0)
            {
                Response.Redirect("shoppingcart.aspx");
            }

            AppLogic.eventHandler("CheckoutReview").CallEvent("&CheckoutReview=true");

            #region vortx init xmlpackage
            CheckoutHeader.Text = Vortx.MobileFramework.MobileXSLTExtensionBase.GetCheckoutHeader("review");
            #endregion
        }
Exemple #18
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (ThisCustomer.IsAdminUser || AppLogic.AppConfigBool("UseStrongPwd"))
            {
                ctrlAccount.PasswordNote = AppLogic.GetString("account.strongPassword", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
            }
            RequireSecurePage();
            Checkout = CommonLogic.QueryStringBool("checkout");
            RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
            SectionTitle = AppLogic.GetString("account.aspx.56", SkinID, ThisCustomer.LocaleSetting);
            ctrlAccount.Attributes.Add("Disabled", "");
            if (Checkout)
            {
                GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
                if (checkoutByAmazon.IsCheckingOut)
                {
                    pnlCBAAddressWidget.Visible         = true;
                    litCBAAddressWidget.Text            = checkoutByAmazon.RenderAddressWidgetWithRedirect("CBAAddressWidgetContainer", Server.UrlEncode("account.aspx?checkout=true"), new Guid(ThisCustomer.CustomerGUID), 300, 200);
                    litCBAAddressWidgetInstruction.Text = "gw.checkoutbyamazon.display.4".StringResource();

                    pnlAddress.Visible = false;
                }

                ThisCustomer.RequireCustomerRecord();
                CheckoutSteps.Visible = true;
            }
            else
            {
                CheckoutSteps.Visible = false;
            }

            lblErrorMessage.Text  = String.Empty;
            pnlErrorMsg.Visible   = false;
            lblAcctUpdateMsg.Text = String.Empty;

            var status = new StringBuilder();

            bool newAccount = CommonLogic.QueryStringBool("newaccount");

            if (newAccount)
            {
                lblErrorMessage.Text = AppLogic.GetString("createaccount.aspx.86", SkinID, ThisCustomer.LocaleSetting);
                pnlErrorMsg.Visible  = true;
            }

            ThisCustomer.ValidatePrimaryAddresses();

            bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") && !AppLogic.AppConfigBool("SkipShippingOnCheckout");

            if (!AllowShipToDifferentThanBillTo)
            {
                pnlShipping.Visible = false;
            }

            //If there is a DeleteID remove it from the cart
            int DeleteID = CommonLogic.QueryStringUSInt("DeleteID");

            if (DeleteID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, DeleteID))
            {
                Order             originalOrder = new Order(DeleteID);
                RecurringOrderMgr rmgr          = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);

                ExpressAPIType expressApiType = PayPalController.GetAppropriateExpressType();

                if (originalOrder.PaymentMethod == AppLogic.ro_PMPayPalExpress && expressApiType == ExpressAPIType.PayPalExpress)
                {
                    status.Append(rmgr.CancelPPECRecurringOrder(DeleteID, false));
                }
                else
                {
                    status.Append(rmgr.CancelRecurringOrder(DeleteID));
                }
            }

            //If there is a FullRefundID refund it
            int FullRefundID = CommonLogic.QueryStringUSInt("FullRefundID");

            if (FullRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, FullRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                status.Append(rmgr.ProcessAutoBillFullRefund(FullRefundID));
            }

            //If there is a PartialRefundID refund it
            int PartialRefundID = CommonLogic.QueryStringUSInt("PartialRefundID");

            if (PartialRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, PartialRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                status.Append(rmgr.ProcessAutoBillPartialRefund(PartialRefundID));
            }

            //do not display an error message saying OK
            lblErrorMessage.Text = status.ToString() != AppLogic.ro_OK ? status.ToString() : String.Empty;
            pnlErrorMsg.Visible  = lblErrorMessage.Text.Length > 0;

            if (!this.IsPostBack)
            {
                RefreshPage();
                SetAccountFields();
                if (ThisCustomer.IsRegistered)
                {
                    this.hdnCustomerLevel1.Text = ThisCustomer.CustomerLevelID.ToString();
                }
                else
                {
                    hdnCustomerLevel1.Text = "-1";
                }
            }
        }
Exemple #19
0
        public void ProcessCart(bool DoingFullCheckout, bool ForceOnePageCheckout, bool InternationalCheckout)
        {
            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 ShoppingCart(1, ThisCustomer, cte, 0, false);

            if (cart.InventoryTrimmed || this.InventoryTrimmed)
            {
                HandleInventoryTrimmed();
                return; //Bail and warn the customer that their cart changed before putting them into checkout
            }

            if (cart.IsEmpty())
            {
                cart.ClearCoupon();
                // 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;
                }
            }

            // update cart quantities:
            UpdateCartQuantity();

            // save coupon code, no need to reload cart object
            // will update customer record also:
            if (cte == CartTypeEnum.ShoppingCart)
            {
                cart.SetCoupon(CouponCode.Text, true);

                // kind of backwards, but if DisallowOrderNotes is false, then
                // allow order notes
                if (!AppLogic.AppConfigBool("DisallowOrderNotes"))
                {
                    if (OrderNotes.Text.Trim().Length > 0)
                    {
                        SqlParameter sp = new SqlParameter("@OrderNotes", SqlDbType.NText);
                        sp.Value = OrderNotes.Text.Trim();
                        SqlParameter[] spa = { sp };
                        ThisCustomer.UpdateCustomer(spa);
                    }
                }

                // rebind the cart summary control to handle coupon
                ctrlCartSummary.DataSource = cart;

                // 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)
                        {
                            int VariantID = AppLogic.GetProductsDefaultVariantID(ProductID);
                            if (VariantID != 0)
                            {
                                int            NewRecID = cart.AddItem(ThisCustomer, ThisCustomer.PrimaryShippingAddressID, ProductID, VariantID, 1, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, CartTypeEnum.ShoppingCart, true, false, 0, System.Decimal.Zero);
                                Decimal        PR       = AppLogic.GetUpsellProductPrice(0, ProductID, ThisCustomer.CustomerLevelID);
                                SqlParameter[] spa      = { DB.CreateSQLParameter("@Price", SqlDbType.Decimal, 10, PR, ParameterDirection.Input), DB.CreateSQLParameter("@CartRecID", SqlDbType.Int, 4, NewRecID, ParameterDirection.Input) };
                                DB.ExecuteSQL("update shoppingcart set IsUpsell=1, ProductPrice=@Price where ShoppingCartRecID=@CartRecID", spa);
                            }
                        }
                    }
                }

                if (cart.CheckInventory(ThisCustomer.CustomerID))
                {
                    ErrorMsgLabel.Text += Server.HtmlEncode(AppLogic.GetString("shoppingcart_process.aspx.1", SkinID, ThisCustomer.LocaleSetting));
                    // inventory got adjusted, send them back to the cart page to confirm the new values!
                }
            }

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

            cart.ClearShippingOptions();
            if (DoingFullCheckout)
            {
                bool validated =
                    cart.MeetsMinimumOrderAmount(AppLogic.AppConfigUSDecimal("CartMinOrderAmount")) &&
                    cart.MeetsMinimumOrderQuantity(AppLogic.AppConfigUSInt("MinCartItemsBeforeCheckout")) &&
                    !cart.ExceedsMaximumOrderQuantity(AppLogic.AppConfigUSInt("MaxCartItemsBeforeCheckout")) &&
                    (!cart.HasCoupon() || cart.CouponIsValid);

                if (validated)
                {
                    AppLogic.eventHandler("BeginCheckout").CallEvent("&BeginCheckout=true");

                    if (InternationalCheckout)
                    {
                        Response.Redirect("internationalcheckout.aspx");
                    }

                    if ((ThisCustomer.IsRegistered || ThisCustomer.EMail.Length != 0) && (ThisCustomer.Password.Length == 0 || ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 || !ThisCustomer.HasAtLeastOneAddress()))
                    {
                        Response.Redirect("createaccount.aspx?checkout=true");
                    }

                    if (!ThisCustomer.IsRegistered || ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 || !ThisCustomer.HasAtLeastOneAddress())
                    {
                        Response.Redirect("createaccount.aspx?checkout=true");
                    }
                    else
                    {
                        if (AppLogic.AppConfigBool("SkipShippingOnCheckout") || cart.IsAllSystemComponents() || cart.IsAllDownloadComponents())
                        {
                            if (cart.ContainsGiftCard())
                            {
                                Response.Redirect("checkoutgiftcard.aspx");
                            }
                            else
                            {
                                Response.Redirect("checkoutpayment.aspx");
                            }
                        }

                        if ((cart.HasMultipleShippingAddresses() || cart.HasGiftRegistryComponents()) && cart.TotalQuantity() <= AppLogic.MultiShipMaxNumItemsAllowed() && cart.CartAllowsShippingMethodSelection)
                        {
                            Response.Redirect("checkoutshippingmult.aspx");
                        }
                        else
                        {
                            Response.Redirect("checkoutshipping.aspx");
                        }
                    }
                }
                InitializePageContent();
            }

            //Make sure promotions is updated when the cart changes
            BindPromotions();
        }
Exemple #20
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("UseStringPwd"))
            {
                ctrlAccount.PasswordNote = AppLogic.GetString("account.stringPassword", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);
            }
            RequireSecurePage();
            RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
            SectionTitle = AppLogic.GetString("account.aspx.56", SkinID, ThisCustomer.LocaleSetting);
            Checkout     = CommonLogic.QueryStringBool("checkout");
            if (Checkout)
            {
                GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
                if (checkoutByAmazon.IsCheckingOut)
                {
                    pnlCBAAddressWidget.Visible         = true;
                    litCBAAddressWidget.Text            = checkoutByAmazon.RenderAddressWidgetWithRedirect("CBAAddressWidgetContainer", Server.UrlEncode("account.aspx?checkout=true"), new Guid(ThisCustomer.CustomerGUID), 300, 200);
                    litCBAAddressWidgetInstruction.Text = "gw.checkoutbyamazon.display.4".StringResource();

                    tblAccount.Visible = false;
                }

                ThisCustomer.RequireCustomerRecord();
            }

            ErrorMsgLabel.Text    = "";
            lblAcctUpdateMsg.Text = "";

            bool newAccount = CommonLogic.QueryStringBool("newaccount");

            if (newAccount)
            {
                ErrorMsgLabel.Text = "<b><center>" + AppLogic.GetString("createaccount.aspx.86", SkinID, ThisCustomer.LocaleSetting) + "</center></b>";
            }

            ThisCustomer.ValidatePrimaryAddresses();

            bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") && !AppLogic.AppConfigBool("SkipShippingOnCheckout");

            if (!AllowShipToDifferentThanBillTo)
            {
                pnlShipping.Visible = pnlShipping2.Visible = false;
            }

            //If there is a DeleteID remove it from the cart
            int DeleteID = CommonLogic.QueryStringUSInt("DeleteID");

            if (DeleteID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, DeleteID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.CancelRecurringOrder(DeleteID);
            }

            //If there is a FullRefundID refund it
            int FullRefundID = CommonLogic.QueryStringUSInt("FullRefundID");

            if (FullRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, FullRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.ProcessAutoBillFullRefund(FullRefundID);
            }

            //If there is a PartialRefundID refund it
            int PartialRefundID = CommonLogic.QueryStringUSInt("PartialRefundID");

            if (PartialRefundID != 0 && Customer.OwnsThisOrder(ThisCustomer.CustomerID, PartialRefundID))
            {
                RecurringOrderMgr rmgr = new RecurringOrderMgr(base.EntityHelpers, base.GetParser);
                rmgr.ProcessAutoBillPartialRefund(PartialRefundID);
            }

            //SkinImagePath = "~/App_Themes/skin_" + SkinID.ToString() + "/images/";

            if (!this.IsPostBack)
            {
                ctrlAccount.FirstName         = ThisCustomer.FirstName;
                ctrlAccount.LastName          = ThisCustomer.LastName;
                ctrlAccount.Email             = ThisCustomer.EMail.ToLowerInvariant().Trim();
                ctrlAccount.Password          = String.Empty;
                ctrlAccount.PasswordConfirm   = String.Empty;
                ctrlAccount.Phone             = ThisCustomer.Phone;
                ctrlAccount.SaveCC            = ThisCustomer.MasterShouldWeStoreCreditCardInfo || ThisCustomer.SecureNetVaultMasterShouldWeStoreCreditCardInfo;
                ctrlAccount.Over13            = ThisCustomer.IsOver13;
                ctrlAccount.VATRegistrationID = ThisCustomer.VATRegistrationID;
                if (ThisCustomer.OKToEMail)
                {
                    ctrlAccount.OKToEmailYes = true;
                }
                else
                {
                    ctrlAccount.OKToEmailNo = true;
                }

                RefreshPage();
            }
        }
Exemple #21
0
        private void MoveGiftRegistryItemToCart(string PassedGiftRegistryGUID, int MoveID)
        {
            // move is a misnomer, we're really "copying" the gift registry item, we don't remove it from the gift registry until THIS
            // customer actually purchases it and the payment has cleared and only then if AppConfig:DecrementGiftRegistryOnOrder=true
            if (PassedGiftRegistryGUID.Length != 0 && MoveID != 0)
            {
                ThisCustomer.RequireCustomerRecord();
                String NewGUID = DB.GetNewGUID();
                int    RegistryOwnerCustomerID   = AppLogic.GiftRegistryOwnerID(PassedGiftRegistryGUID);
                int    ExistingShoppingCartRecID = 0;
                if (RegistryOwnerCustomerID != 0)
                {
                    // increment their cart if they already have this item in there for this gift recipient:
                    bool   TheyHaveInCartAlready = false;
                    int    ProductID             = 0;
                    int    VariantID             = 0;
                    string ChosenColor           = string.Empty;
                    string ChosenSize            = string.Empty;
                    string TextOption            = string.Empty;
                    string sqlx = string.Empty;

                    using (SqlConnection conn = DB.dbConn())
                    {
                        conn.Open();
                        using (IDataReader rs = DB.GetRS("select * from ShoppingCart where CartType in (" + ((int)CartTypeEnum.ShoppingCart).ToString() + ") and ShoppingCartRecID=" + MoveID.ToString(), conn))
                        {
                            if (rs.Read())
                            {
                                ProductID   = DB.RSFieldInt(rs, "ProductID");
                                VariantID   = DB.RSFieldInt(rs, "VariantID");
                                ChosenColor = DB.RSField(rs, "ChosenColor");
                                ChosenSize  = DB.RSField(rs, "ChosenSize");
                                TextOption  = DB.RSField(rs, "TextOption");
                            }
                        }
                    }

                    sqlx = String.Format("select ShoppingCartRecID from shoppingcart where CartType in (" + ((int)CartTypeEnum.ShoppingCart).ToString() + ") and ProductID={0} and VariantID={1} and ChosenColor like {2} and ChosenSize like {3} and TextOption like {4} and GiftRegistryForCustomerID={5} and CustomerID={6}", ProductID.ToString(), VariantID.ToString(), DB.SQuote("%" + ChosenColor + "%"), DB.SQuote("%" + ChosenSize + "%"), DB.SQuote("%" + TextOption + "%"), RegistryOwnerCustomerID.ToString(), ThisCustomer.CustomerID.ToString());
                    using (SqlConnection conn2 = DB.dbConn())
                    {
                        conn2.Open();
                        using (IDataReader rsx = DB.GetRS(sqlx, conn2))
                        {
                            if (rsx.Read())
                            {
                                ExistingShoppingCartRecID = DB.RSFieldInt(rsx, "ShoppingCartRecID");
                            }
                        }
                    }
                    TheyHaveInCartAlready = (ExistingShoppingCartRecID != 0);

                    if (TheyHaveInCartAlready)
                    {
                        DB.ExecuteSQL("update ShoppingCart set Quantity=Quantity+1 where ShoppingCartRecID=" + ExistingShoppingCartRecID.ToString());
                    }
                    else
                    {
                        int    GiftShippingAddressID = Customer.GetCustomerPrimaryShippingAddressID(RegistryOwnerCustomerID);
                        String sql = "insert into shoppingcart(ShoppingCartRecGUID,CustomerID,ProductSKU,ProductPrice,ProductWeight,ProductID,VariantID,Quantity,ChosenColor,ChosenColorSKUModifier,ChosenSize,ChosenSizeSKUModifier,IsTaxable,IsShipSeparately,IsDownload,DownloadLocation,ProductDimensions,CartType,TextOption,NextRecurringShipDate,RecurringIndex,OriginalRecurringOrderNumber,BillingAddressID,ShippingAddressID,DistributorID,SubscriptionInterval,SubscriptionIntervalType,Notes,IsUpsell,GiftRegistryForCustomerID,RecurringInterval,RecurringIntervalType,ExtensionData, IsAKit, IsAPack, StoreID) ";
                        sql += " select " + DB.SQuote(NewGUID) + "," + ThisCustomer.CustomerID.ToString() + ",ProductSKU,ProductPrice,ProductWeight,ProductID,VariantID,Quantity,ChosenColor,ChosenColorSKUModifier,ChosenSize,ChosenSizeSKUModifier,IsTaxable,IsShipSeparately,IsDownload,DownloadLocation,ProductDimensions," + ((int)CartTypeEnum.ShoppingCart).ToString() + ",TextOption,NextRecurringShipDate,RecurringIndex,OriginalRecurringOrderNumber,BillingAddressID," + GiftShippingAddressID.ToString() + ",DistributorID,SubscriptionInterval,SubscriptionIntervalType,Notes,IsUpsell," + RegistryOwnerCustomerID.ToString() + ",RecurringInterval,RecurringIntervalType,ExtensionData, IsAKit, IsAPack, StoreID";
                        sql += " from ShoppingCart where ShoppingCartRecID=" + MoveID.ToString();
                        DB.ExecuteSQL(sql);

                        // get new ShoppingCartRecID:
                        int NewShoppingCartRecID = 0;
                        using (SqlConnection conn3 = DB.dbConn())
                        {
                            conn3.Open();
                            using (IDataReader rs = DB.GetRS("Select ShoppingCartRecID from ShoppingCart  with (NOLOCK)  where ShoppingCartRecGUID=" + DB.SQuote(NewGUID), conn3))
                            {
                                if (rs.Read())
                                {
                                    NewShoppingCartRecID = DB.RSFieldInt(rs, "ShoppingCartRecID");
                                }
                            }
                        }

                        //JH -- KitCart doesn't have a StoreID Column

                        String sql2 = "insert into kitcart(CustomerID,ShoppingCartRecID,ProductID,VariantID,KitGroupID,KitItemID,Quantity,CartType,OriginalRecurringOrderNumber,ExtensionData, KitGroupTypeID) ";
                        sql2 += " select " + ThisCustomer.CustomerID.ToString() + "," + NewShoppingCartRecID.ToString() + ",ProductID,VariantID,KitGroupID,KitItemID,Quantity," + ((int)CartTypeEnum.ShoppingCart).ToString() + ",OriginalRecurringOrderNumber,ExtensionData, KitGroupTypeID";
                        sql2 += " from kitcart where ShoppingCartRecID=" + MoveID.ToString();
                        DB.ExecuteSQL(sql2);
                    }
                    Response.Redirect("shoppingcart.aspx");
                }
            }
        }
Exemple #22
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();
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            MobileHelper.RedirectPageWhenMobileIsDisabled("~/createaccount.aspx", ThisCustomer);

            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            RequireSecurePage();
            ThisCustomer.RequireCustomerRecord();

            SectionTitle     = AppLogic.GetString("createaccount.aspx.1", SkinID, ThisCustomer.LocaleSetting);
            Checkout         = CommonLogic.QueryStringBool("checkout");
            SkipRegistration = CommonLogic.QueryStringBool("skipreg");
            checkouttype     = CommonLogic.QueryStringCanBeDangerousContent("checkouttype");

            if (!Checkout)
            {
                RequireSecurityCode = AppLogic.AppConfigBool("SecurityCodeRequiredOnCreateAccount");
            }
            else
            {
                RequireSecurityCode = AppLogic.AppConfigBool("SecurityCodeRequiredOnCreateAccountDuringCheckout");
            }

            if (RequireSecurityCode)
            {
                if (!IsPostBack)
                {
                    // Create a random code and store it in the Session object.
                    ctrlAccount.SecurityImage = "~/Captcha.ashx?id=1";
                }
                else
                {
                    String code = Session["SecurityCode"].ToString();

                    ctrlAccount.SecurityImage = "~/Captcha.ashx?id=2";
                }
            }
            else
            {
                ctrlAccount.ShowSecurityCode                = false;
                ctrlAccount.txtSecurityCode.Visible         = false;
                ctrlAccount.imgAccountSecurityImage.Visible = false;
                ctrlAccount.lblSecurityCode.Visible         = false;
            }

            if (Checkout)
            {
                SectionTitle = AppLogic.GetString("createaccount.aspx.2", SkinID, ThisCustomer.LocaleSetting) + SectionTitle;

                // -----------------------------------------------------------------------------------------------
                // 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...
                // -----------------------------------------------------------------------------------------------
                ShoppingCart cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
                cart.ValidProceedCheckout(); // will not come back from this if any issue. they are sent back to the cart page!
            }

            AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") &&
                                             !AppLogic.AppConfigBool("SkipShippingOnCheckout");
            ReturnURL = CommonLogic.QueryStringCanBeDangerousContent("ReturnURL");
            AppLogic.CheckForScriptTag(ReturnURL);
            ErrorMsgLabel.Text = "";

            if (!IsPostBack)
            {
                BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);
                ShippingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryShippingAddressID, AddressTypes.Shipping);
                InitializeValidationErrorMessages();
                InitializePageContent();
            }

            #region vortx init xmlpackage
            //CheckoutHeader.SetContext = this;
            CheckoutHeader.Text = Vortx.MobileFramework.MobileXSLTExtensionBase.GetCheckoutHeader("address");
            #endregion
        }
Exemple #24
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();
            }
        }
Exemple #25
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.Expires = -1;
            Response.AddHeader("pragma", "no-cache");
            Response.AddHeader("Last-Modified", DateTime.Now.AddMinutes(-10).ToUniversalTime() + " GMT");
            Response.AddHeader("Cache-Control", "no-store, no-cache, must-revalidate"); // HTTP/1.1
            Response.AddHeader("Cache-Control", "post-check=0, pre-check=0");
            Response.AddHeader("Pragma", "no-cache");                                   // HTTP/1.0
            ErrorMessage err;

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

            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.IsRegistered)
            {
                bool boolAllowAnon = (AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") && !cart.HasRecurringComponents());
                if (!boolAllowAnon && ThisCustomer.PrimaryBillingAddressID > 0)
                {
                    Address BillingAddress = new Address();
                    BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);
                    if (BillingAddress.PaymentMethodLastUsed == AppLogic.ro_PMPayPalExpress || BillingAddress.PaymentMethodLastUsed == AppLogic.ro_PMPayPalExpressMark)
                    {
                        boolAllowAnon = AppLogic.AppConfigBool("PayPal.Express.AllowAnonCheckout");
                    }
                }

                if (!boolAllowAnon)
                {
                    Response.Redirect("createaccount.aspx?checkout=true");
                }
            }
            if (ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0)
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutpayment.aspx.2", SkinID, ThisCustomer.LocaleSetting))); //checkout not allowed without primary shipping/billing addy
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + err.MessageId);
            }

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

            cart.ValidProceedCheckout();                                                                          // will not come back from this if any issue. they are sent back to the cart page!

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();
            if (cart.IsAllDownloadComponents() || !Shipping.MultiShipEnabled() || cart.TotalQuantity() > AppLogic.MultiShipMaxNumItemsAllowed() || !cart.CartAllowsShippingMethodSelection || checkoutByAmazon.IsCheckingOut)
            {
                // not allowed then:
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutshippingmult.aspx.12", SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + err.MessageId);
            }

            CartItem FirstCartItem            = (CartItem)cart.CartItems[0];
            Address  FirstItemShippingAddress = new Address();

            FirstItemShippingAddress.LoadByCustomer(ThisCustomer.CustomerID, FirstCartItem.ShippingAddressID, AddressTypes.Shipping);
            if (FirstItemShippingAddress.AddressID == 0)
            {
                // not allowed here anymore!
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutshippingmult.aspx.10", SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("shoppingcart.aspx?errormsg=" + err.MessageId);
            }

            if (!IsPostBack && CommonLogic.FormCanBeDangerousContent("update") == "" && CommonLogic.FormCanBeDangerousContent("continue") == "" && CommonLogic.QueryStringCanBeDangerousContent("setallprimary") == "")
            {
                UpdatepageContent();
            }

            if (CommonLogic.FormCanBeDangerousContent("update") != "" || CommonLogic.FormCanBeDangerousContent("continue") != "" || CommonLogic.QueryStringCanBeDangerousContent("setallprimary") != "")
            {
                ProcessCart();
            }
            JSPopupRoutines.Text = AppLogic.GetJSPopupRoutines();

            AppLogic.eventHandler("CheckoutShipping").CallEvent("&CheckoutShipping=true");
        }
Exemple #26
0
        private void ProcessForm(bool UseValidationService, int AddressID)
        {
            ThisCustomer.RequireCustomerRecord();
            string ResidenceType = ddlResidenceType.SelectedValue;
            bool   valid         = true;
            string errormsg      = string.Empty;

            // Payment method validations
            if (AddressType == AddressTypes.Billing)
            {
                string paymentMethodLastUsed = AppLogic.CleanPaymentMethod(CommonLogic.FormCanBeDangerousContent("PaymentMethod"));
                if (paymentMethodLastUsed == AppLogic.ro_PMECheck && ShowEcheck)
                {
                    if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("ECheckBankABACode")))
                    {
                        valid     = false;
                        errormsg += "&bull;Bank ABA Code is required";
                    }
                    if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("ECheckBankAccountNumber")))
                    {
                        valid     = false;
                        errormsg += "&bull;Bank Account Number is required";
                    }
                    if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("ECheckBankName")))
                    {
                        valid     = false;
                        errormsg += "&bull;Bank Account Name is required";
                    }
                    if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("ECheckBankAccountName")))
                    {
                        valid     = false;
                        errormsg += "&bull;Bank Account Name is required";
                    }
                }
                if (paymentMethodLastUsed == AppLogic.ro_PMCreditCard)
                {
                    if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardName")))
                    {
                        valid     = false;
                        errormsg += "&bull;Card Name is required";
                    }
                    if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardType")))
                    {
                        valid     = false;
                        errormsg += "&bull;Card Type is required";
                    }
                    if (string.IsNullOrEmpty(CommonLogic.FormCanBeDangerousContent("CardNumber")))
                    {
                        valid     = false;
                        errormsg += "&bull;Card Number is required";
                    }

                    int    iexpMonth = 0;
                    int    iexpYear  = 0;
                    string expMonth  = CommonLogic.FormCanBeDangerousContent("CardExpirationMonth");
                    string expYear   = CommonLogic.FormCanBeDangerousContent("CardExpirationYear");

                    if (string.IsNullOrEmpty(expMonth) ||
                        !int.TryParse(expMonth, out iexpMonth) ||
                        !(iexpMonth > 0))
                    {
                        valid     = false;
                        errormsg += "&bull;Please select the Card Expiration Month";
                    }
                    if (string.IsNullOrEmpty(expYear) ||
                        !int.TryParse(expYear, out iexpYear) ||
                        !(iexpYear > 0))
                    {
                        valid     = false;
                        errormsg += "&bull;Please select the Card Expiration Year";
                    }
                }
            }

            if (!Page.IsValid || !valid)
            {
                ErrorMsgLabel.Text = "" + AppLogic.GetString("editaddress.aspx.15", SkinID, ThisCustomer.LocaleSetting) + "";
                foreach (IValidator aValidator in this.Validators)
                {
                    if (!aValidator.IsValid)
                    {
                        ErrorMsgLabel.Text += "&bull; " + aValidator.ErrorMessage + "";
                    }
                }
                ErrorMsgLabel.Text += "";
                ErrorMsgLabel.Text += errormsg;
                InitializePageContent();
                return;
            }

            theAddress.AddressType = AddressType;
            theAddress.NickName    = txtAddressNickName.Text;
            theAddress.FirstName   = txtFirstName.Text;
            theAddress.LastName    = txtLastName.Text;
            theAddress.Company     = txtCompany.Text;
            theAddress.Address1    = txtAddress1.Text;
            theAddress.Address2    = txtAddress2.Text;
            theAddress.Suite       = txtSuite.Text;
            theAddress.City        = txtCity.Text;
            theAddress.State       = ddlState.SelectedValue;
            theAddress.Zip         = txtZip.Text;
            theAddress.Country     = ddlCountry.SelectedValue;
            theAddress.Phone       = txtPhone.Text;
            if (ResidenceType == "2")
            {
                theAddress.ResidenceType = ResidenceTypes.Commercial;
            }
            else if (ResidenceType == "1")
            {
                theAddress.ResidenceType = ResidenceTypes.Residential;
            }
            else
            {
                theAddress.ResidenceType = ResidenceTypes.Unknown;
            }
            if (theAddress.AddressType == AddressTypes.Billing)
            {
                theAddress.PaymentMethodLastUsed = AppLogic.CleanPaymentMethod(CommonLogic.FormCanBeDangerousContent("PaymentMethod"));
                if (theAddress.PaymentMethodLastUsed == AppLogic.ro_PMECheck && ShowEcheck)
                {
                    string eCheckABACode = CommonLogic.FormCanBeDangerousContent("ECheckBankABACode");
                    if (!eCheckABACode.StartsWith("*"))
                    {
                        theAddress.ECheckBankABACode = CommonLogic.FormCanBeDangerousContent("ECheckBankABACode");
                    }

                    string eCheckBankAccountNumber = CommonLogic.FormCanBeDangerousContent("ECheckBankAccountNumber");
                    if (!eCheckBankAccountNumber.StartsWith("*"))
                    {
                        theAddress.ECheckBankAccountNumber = CommonLogic.FormCanBeDangerousContent("ECheckBankAccountNumber");
                    }

                    theAddress.ECheckBankName        = CommonLogic.FormCanBeDangerousContent("ECheckBankName");
                    theAddress.ECheckBankAccountName = CommonLogic.FormCanBeDangerousContent("ECheckBankAccountName");
                    theAddress.ECheckBankAccountType = CommonLogic.FormCanBeDangerousContent("ECheckBankAccountType");
                }
                if (theAddress.PaymentMethodLastUsed == AppLogic.ro_PMCreditCard)
                {
                    theAddress.CardName = CommonLogic.FormCanBeDangerousContent("CardName");
                    theAddress.CardType = CommonLogic.FormCanBeDangerousContent("CardType");

                    string tmpS = CommonLogic.FormCanBeDangerousContent("CardNumber");
                    if (!tmpS.StartsWith("*"))
                    {
                        theAddress.CardNumber = tmpS;
                    }
                    theAddress.CardExpirationMonth = CommonLogic.FormCanBeDangerousContent("CardExpirationMonth");
                    theAddress.CardExpirationYear  = CommonLogic.FormCanBeDangerousContent("CardExpirationYear");
                }
            }
            theAddress.UpdateDB();

            string RETURNURL = "";

            if (ViewState["RETURNURL"] != null)
            {
                RETURNURL = "&ReturnUrl=" + ViewState["RETURNURL"].ToString();
            }
            if (UseValidationService)
            {
                Address StandardizedAddress = new Address();
                String  validateResult      = AddressValidation.RunValidate(theAddress, out StandardizedAddress);
                theAddress = StandardizedAddress;
                theAddress.UpdateDB();

                if (validateResult != AppLogic.ro_OK)
                {
                    validateResult = "address.validation.errormsg".StringResource() + validateResult;
                    Session["ErrorMsgLabelText"] = System.Web.HttpUtility.HtmlEncode(validateResult);
                    Response.Redirect("editaddress.aspx?Checkout=" + Checkout.ToString() + "&AddressType=" + AddressType.ToString() + "&AddressID=" + AddressID.ToString() + RETURNURL);
                }
            }

            Response.Redirect(String.Format("selectaddress.aspx?Checkout={0}&AddressType={1}" + RETURNURL, Checkout.ToString(), AddressType));
        }
Exemple #27
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            MobileHelper.RedirectPageWhenMobileIsDisabled("~/checkoutshipping.aspx", ThisCustomer);

            Response.CacheControl = "private";
            Response.Expires      = -1;
            Response.AddHeader("pragma", "no-cache");

            ErrorMessage err;

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

            bool phoneCustomer = ((HttpContext.Current.Items["IsBeingImpersonated"] != null) &&
                                  ((string)HttpContext.Current.Items["IsBeingImpersonated"] == "true"));

            bool paypalExpressCheckout = (ThisCustomer.ThisCustomerSession["paypalexpresspayerid"].ToString().Length == 0 &&
                                          ThisCustomer.ThisCustomerSession["paypalexpresstoken"].ToString().Length == 0);

            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.IsRegistered)
            {
                bool boolAllowAnon = (AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") && !cart.HasRecurringComponents());
                if (!boolAllowAnon && ThisCustomer.PrimaryBillingAddressID > 0)
                {
                    Address BillingAddress = new Address();
                    BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing);
                    if (BillingAddress.PaymentMethodLastUsed == AppLogic.ro_PMPayPalExpress || BillingAddress.PaymentMethodLastUsed == AppLogic.ro_PMPayPalExpressMark)
                    {
                        boolAllowAnon = AppLogic.AppConfigBool("PayPal.Express.AllowAnonCheckout");
                    }
                }

                if (!boolAllowAnon)
                {
                    Response.Redirect("createaccount.aspx?checkout=true");
                }
            }
            if (ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0)
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutpayment.aspx.2", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("shoppingcart.aspx?resetlinkback=1&errormsg=" + err.MessageId);
            }

            SectionTitle = AppLogic.GetString("checkoutshipping.aspx.1", SkinID, ThisCustomer.LocaleSetting);
            cart         = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);

            cart.ValidProceedCheckout(); // will not come back from this if any issue. they are sent back to the cart page!

            if (!cart.IsAllDownloadComponents() && !cart.IsAllFreeShippingComponents() && !cart.IsAllSystemComponents() && (cart.HasMultipleShippingAddresses() || cart.HasGiftRegistryComponents()) && cart.TotalQuantity() <= AppLogic.MultiShipMaxNumItemsAllowed() && cart.CartAllowsShippingMethodSelection && cart.TotalQuantity() > 1)
            {
                Response.Redirect("checkoutshippingmult.aspx");
            }

            //MOD GS - If entire cart is email gift cards...redirect to checkoutgiftcard.aspx
            //if (cart.IsAllEmailGiftCards())
            //{
            //    Response.Redirect("checkoutgiftcard.aspx");
            //}

            if (AppLogic.AppConfigBool("SkipShippingOnCheckout") ||
                cart.IsAllSystemComponents() ||
                cart.IsAllDownloadComponents() ||
                cart.NoShippingRequiredComponents())
            {
                if (cart.ContainsGiftCard())
                {
                    Response.Redirect("checkoutgiftcard.aspx");
                }
                else
                {
                    if (ThisCustomer.ThisCustomerSession["PayPalExpressToken"] == "")
                    {
                        Response.Redirect("checkoutpayment.aspx");
                    }
                    else
                    {
                        Response.Redirect("checkoutreview.aspx?PaymentMethod=PAYPALEXPRESS");
                    }
                }
            }

            pnlSelectAddress.Visible = Vortx.Data.Config.MobilePlatform.AllowAddressChangeOnCheckoutShipping && AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo");

            ctrlShippingMethods.ErrorMessage = string.Empty;
            pnlErrorMsg.Visible = false;

            CartItem FirstCartItem            = (CartItem)cart.CartItems[0];
            Address  FirstItemShippingAddress = new Address();

            FirstItemShippingAddress.LoadByCustomer(ThisCustomer.CustomerID, FirstCartItem.ShippingAddressID, AddressTypes.Shipping);
            if (FirstItemShippingAddress.AddressID == 0)
            {
                err = new ErrorMessage(Server.HtmlEncode(AppLogic.GetString("checkoutshipping.aspx.10", ThisCustomer.SkinID, ThisCustomer.LocaleSetting)));
                Response.Redirect("shoppingcart.aspx?errormsg=" + err.MessageId);
            }

            if (!this.IsPostBack)
            {
                if (!AppLogic.AppConfigBool("AllowMultipleShippingAddressPerOrder") && CommonLogic.QueryStringCanBeDangerousContent("dontupdateid").Length == 0)
                {
                    // force primary shipping address id to be active on all cart items (safety check):
                    DB.ExecuteSQL("update ShoppingCart set ShippingAddressID=(select ShippingAddressID from customer where CustomerID=" + ThisCustomer.CustomerID.ToString() + ") where CustomerID=" + ThisCustomer.CustomerID.ToString() + " and CartType=" + ((int)CartTypeEnum.ShoppingCart).ToString());
                    Response.Redirect("checkoutshipping.aspx?dontupdateid=true");
                }
                InitializePageContent();
            }
            else
            {
                pnlErrorMsg.Visible = false;
                if (CommonLogic.FormCanBeDangerousContent("btnContinueCheckout") != "")
                {
                    ProcessCheckOut();
                }
            }

            AppLogic.eventHandler("CheckoutShipping").CallEvent("&CheckoutShipping=true");

            #region vortx init xmlpackage
            CheckoutHeader.Text = Vortx.MobileFramework.MobileXSLTExtensionBase.GetCheckoutHeader("shipping");
            #endregion
        }
        private void CreateAccount()
        {
            ThisCustomer.RequireCustomerRecord();
            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut && checkoutByAmazon.GetDefaultShippingAddress() == null)
            {
                lblErrorMessage.Text = "gw.checkoutbyamazon.display.3".StringResource();
                pnlErrorMsg.Visible  = true;
                return;
            }

            if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut && ThisCustomer.IsRegistered)
            {
                checkoutByAmazon.BeginCheckout(new Guid(ThisCustomer.CustomerGUID), false, false);
                Response.Redirect("checkoutshipping.aspx");
            }
            else if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut)
            {
                checkoutByAmazon.BeginCheckout(new Guid(ThisCustomer.CustomerGUID), false, false);
            }

            SetPasswordFields();

            string AccountName = (ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim()).Trim();

            if (SkipRegistration)
            {
                AccountName = String.Format("{0} {1}", ctrlBillingAddress.FirstName.Trim(), ctrlBillingAddress.LastName.Trim()).Trim();

                if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut)
                {
                    AccountName = "Anonymous Amazon Customer";
                }
            }

            if (SkipRegistration)
            {
                Page.Validate("skipreg");
            }
            else
            {
                if (ctrlAccount.Password.Contains('\xFF') || ctrlAccount.Password.Length == 0)
                {
                    ctrlAccount.PasswordValidate = ViewState["custpwd"].ToString();
                }
                else
                {
                    ctrlAccount.PasswordValidate = ctrlAccount.Password;
                }

                if (ctrlAccount.PasswordConfirm.Contains('\xFF') || ctrlAccount.PasswordConfirm.Length == 0)
                {
                    ctrlAccount.PasswordConfirmValidate = ViewState["custpwd2"].ToString();
                }
                else
                {
                    ctrlAccount.PasswordConfirmValidate = ctrlAccount.PasswordConfirm;
                }

                ctrlAccount.Over13 = ctrlAccount.Over13;
                if ((!ThisCustomer.IsRegistered) && !checkoutByAmazon.IsCheckingOut && (ctrlAccount.Password.Length == 0 || ctrlAccount.PasswordConfirm.Length == 0))
                {
                    lblErrorMessage.Text = "createaccount.aspx.6".StringResource();
                    ResetScrollPosition();
                    pnlErrorMsg.Visible = true;
                    return;
                }

                ctrlBillingAddress.CountryIDToValidateZipCode  = AppLogic.GetCountryID(ctrlBillingAddress.Country);
                ctrlShippingAddress.CountryIDToValidateZipCode = AppLogic.GetCountryID(ctrlShippingAddress.Country);

                Page.Validate("registration");

                if (RequireSecurityCode)
                {
                    if (Session["SecurityCode"] != null)
                    {
                        String  sCode     = Session["SecurityCode"].ToString();
                        String  fCode     = ctrlAccount.txtSecurityCode.Text;
                        Boolean codeMatch = false;

                        if (AppLogic.AppConfigBool("Captcha.CaseSensitive"))
                        {
                            if (fCode.Equals(sCode))
                            {
                                codeMatch = true;
                            }
                        }
                        else
                        {
                            if (fCode.Equals(sCode, StringComparison.InvariantCultureIgnoreCase))
                            {
                                codeMatch = true;
                            }
                        }

                        if (!codeMatch)
                        {
                            lblErrorMessage.Text                         = string.Format(AppLogic.GetString("lat_signin_process.aspx.5", SkinID, ThisCustomer.LocaleSetting), sCode, fCode);
                            ctrlAccount.txtSecurityCode.Text             = String.Empty;
                            ctrlAccount.imgAccountSecurityImage.ImageUrl = "~/Captcha.ashx?id=1";
                            ResetScrollPosition();
                            pnlErrorMsg.Visible = true;
                            return;
                        }
                    }
                    else
                    {
                        lblErrorMessage.Text                         = string.Format(AppLogic.GetString("lat_signin_process.aspx.5", SkinID, ThisCustomer.LocaleSetting), "", ctrlAccount.txtSecurityCode.Text);
                        ctrlAccount.txtSecurityCode.Text             = String.Empty;
                        ctrlAccount.imgAccountSecurityImage.ImageUrl = "~/Captcha.ashx?id=1";
                        ResetScrollPosition();
                        pnlErrorMsg.Visible = true;
                        return;
                    }
                }

                if (!Page.IsValid && RequireSecurityCode)
                {
                    Session["SecurityCode"] = CommonLogic.GenerateRandomCode(6);
                }
            }



            Page.Validate("createacccount");


            if (Page.IsValid && AccountName.Length > 0)
            {
                String EMailField = CommonLogic.IIF(SkipRegistration, txtSkipRegEmail.Text.ToLowerInvariant().Trim(), ctrlAccount.Email.ToLowerInvariant().Trim());

                bool NewEmailAllowed = Customer.NewEmailPassesDuplicationRules(EMailField, ThisCustomer.CustomerID, SkipRegistration);

                String   PWD    = ViewState["custpwd"].ToString();
                Password p      = new Password(PWD);
                String   newpwd = p.SaltedPassword;
                System.Nullable <int> newsaltkey = p.Salt;

                Password blankpwd = new Password("", ThisCustomer.SaltKey);
                if (!(ThisCustomer.Password == "" || ThisCustomer.Password == blankpwd.SaltedPassword))
                {
                    // do NOT allow passwords to be changed on this page. this is only for creating an account.
                    // if they want to change their password, they must use their account page
                    newpwd     = null;
                    newsaltkey = null;
                }
                if (NewEmailAllowed)
                {
                    AppLogic.eventHandler("CreateAccount").CallEvent("&CreateAccount=true");

                    string strDOB = null;
                    if (AppLogic.AppConfigBool("Account.ShowBirthDateField"))
                    {
                        strDOB = ctrlAccount.DOBMonth + "/" + ctrlAccount.DOBDay + "/" + ctrlAccount.DOBYear;
                        //DOB defaults to 0/0/0 when doing anonymous checkout and blows up dbo.aspdnsf_updCustomer, preventing checkout
                        strDOB = (strDOB.Equals("0/0/0", StringComparison.Ordinal)) ? null : strDOB;
                    }

                    var defaultCustomerLevel_Public = (int)UserType.PUBLIC;

                    ThisCustomer.UpdateCustomer(
                        /*CustomerLevelID*/ defaultCustomerLevel_Public,
                        /*EMail*/ EMailField,
                        /*SaltedAndHashedPassword*/ newpwd,
                        /*SaltKey*/ newsaltkey,
                        /*DateOfBirth*/ strDOB,
                        /*Gender*/ null,
                        /*FirstName*/ ctrlAccount.FirstName,
                        /*LastName*/ ctrlAccount.LastName,
                        /*Notes*/ null,
                        /*SkinID*/ null,
                        /*Phone*/ ctrlAccount.Phone,
                        /*AffiliateID*/ null,
                        /*Referrer*/ null,
                        /*CouponCode*/ null,
                        /*OkToEmail*/ CommonLogic.IIF(ctrlAccount.OKToEmailYes, 1, 0),
                        /*IsAdmin*/ null,
                        /*BillingEqualsShipping*/ CommonLogic.IIF(AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo"), 0, 1),
                        /*LastIPAddress*/ null,
                        /*OrderNotes*/ null,
                        /*SubscriptionExpiresOn*/ null,
                        /*RTShipRequest*/ null,
                        /*RTShipResponse*/ null,
                        /*OrderOptions*/ null,
                        /*LocaleSetting*/ null,
                        /*MicroPayBalance*/ null,
                        /*RecurringShippingMethodID*/ null,
                        /*RecurringShippingMethod*/ null,
                        /*BillingAddressID*/ null,
                        /*ShippingAddressID*/ null,
                        /*GiftRegistryGUID*/ null,
                        /*GiftRegistryIsAnonymous*/ null,
                        /*GiftRegistryAllowSearchByOthers*/ null,
                        /*GiftRegistryNickName*/ null,
                        /*GiftRegistryHideShippingAddresses*/ null,
                        /*CODCompanyCheckAllowed*/ null,
                        /*CODNet30Allowed*/ null,
                        /*ExtensionData*/ null,
                        /*FinalizationData*/ null,
                        /*Deleted*/ null,
                        /*Over13Checked*/ 1, //CommonLogic.IIF(ctrlAccount.Over13 || SkipRegOver13.Checked, 1, 0),
                        /*CurrencySetting*/ null,
                        /*VATSetting*/ null,
                        /*VATRegistrationID*/ null,
                        /*StoreCCInDB*/ CommonLogic.IIF(ctrlAccount.ShowSaveCC, ctrlAccount.SaveCC, true),
                        /*IsRegistered*/ CommonLogic.IIF(SkipRegistration, 0, 1),
                        /*LockedUntil*/ null,
                        /*AdminCanViewCC*/ null,
                        /*BadLogin*/ null,
                        /*Active*/ null,
                        /*PwdChangeRequired*/ null,
                        /*RegisterDate*/ null,
                        /*StoreId*/ AppLogic.StoreID()
                        );
                    if (ctrlAccount.OKToEmailYes)
                    {
                        AddToNewsletterList(ctrlAccount.FirstName, ctrlAccount.LastName, EMailField);
                    }
                    BillingAddress = ThisCustomer.PrimaryBillingAddress;
                    if (BillingAddress.AddressID == 0 && !checkoutByAmazon.IsCheckingOut)
                    {
                        if (pnlBillingInfo.Visible)
                        {
                            BillingAddress.NickName      = ctrlBillingAddress.NickName;
                            BillingAddress.LastName      = ctrlBillingAddress.LastName;
                            BillingAddress.FirstName     = ctrlBillingAddress.FirstName;
                            BillingAddress.Phone         = ctrlBillingAddress.PhoneNumber;
                            BillingAddress.Company       = ctrlBillingAddress.Company;
                            BillingAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlBillingAddress.ResidenceType);
                            BillingAddress.Address1      = ctrlBillingAddress.Address1;
                            BillingAddress.Address2      = ctrlBillingAddress.Address2;
                            BillingAddress.Suite         = ctrlBillingAddress.Suite;
                            BillingAddress.City          = ctrlBillingAddress.City;
                            BillingAddress.State         = ctrlBillingAddress.State;
                            BillingAddress.Zip           = ctrlBillingAddress.ZipCode;
                            BillingAddress.Country       = ctrlBillingAddress.Country;

                            BillingAddress.InsertDB(ThisCustomer.CustomerID);
                            BillingAddress.MakeCustomersPrimaryAddress(AddressTypes.Billing);
                        }
                    }
                    else
                    {
                        BillingAddress.NickName  = String.Format("{0} {1}", ctrlAccount.FirstName, ctrlAccount.LastName);
                        BillingAddress.LastName  = ctrlAccount.FirstName;
                        BillingAddress.FirstName = ctrlAccount.LastName;
                        BillingAddress.Phone     = ctrlAccount.Phone;
                    }

                    ShippingAddress = ThisCustomer.PrimaryShippingAddress;
                    if (ShippingAddress.AddressID == 0 && !checkoutByAmazon.IsCheckingOut)
                    {
                        if (AllowShipToDifferentThanBillTo)
                        {
                            if (ctrlShippingAddress.Visible)
                            {
                                ShippingAddress.NickName      = ctrlBillingAddress.NickName;
                                ShippingAddress.LastName      = ctrlShippingAddress.LastName;
                                ShippingAddress.FirstName     = ctrlShippingAddress.FirstName;
                                ShippingAddress.Phone         = ctrlShippingAddress.PhoneNumber;
                                ShippingAddress.Company       = ctrlShippingAddress.Company;
                                ShippingAddress.ResidenceType = (ResidenceTypes)Enum.Parse(typeof(ResidenceTypes), ctrlShippingAddress.ResidenceType);
                                ShippingAddress.Address1      = ctrlShippingAddress.Address1;
                                ShippingAddress.Address2      = ctrlShippingAddress.Address2;
                                ShippingAddress.Suite         = ctrlShippingAddress.Suite;
                                ShippingAddress.City          = ctrlShippingAddress.City;
                                ShippingAddress.State         = ctrlShippingAddress.State;
                                ShippingAddress.Zip           = ctrlShippingAddress.ZipCode;
                                ShippingAddress.Country       = ctrlShippingAddress.Country;

                                ShippingAddress.InsertDB(ThisCustomer.CustomerID);
                                if (!String.IsNullOrEmpty(VerifyAddressesProvider))
                                {
                                    VerifyResult        = AddressValidation.RunValidate(ShippingAddress, out StandardizedAddress);
                                    VerifyAddressPrompt = (VerifyResult != AppLogic.ro_OK);
                                    if (VerifyAddressPrompt)
                                    {
                                        ShippingAddress = StandardizedAddress;
                                        ShippingAddress.UpdateDB();
                                    }
                                }
                                ShippingAddress.MakeCustomersPrimaryAddress(AddressTypes.Shipping);
                            }
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(VerifyAddressesProvider))
                            {
                                VerifyResult        = AddressValidation.RunValidate(BillingAddress, out StandardizedAddress);
                                VerifyAddressPrompt = (VerifyResult != AppLogic.ro_OK);
                                if (VerifyAddressPrompt)
                                {
                                    BillingAddress = StandardizedAddress;
                                    BillingAddress.UpdateDB();
                                }
                            }
                            BillingAddress.MakeCustomersPrimaryAddress(AddressTypes.Shipping);
                        }
                    }
                    else
                    {
                        ShippingAddress.NickName  = String.Format("{0} {1}", ctrlAccount.FirstName, ctrlAccount.LastName);
                        ShippingAddress.LastName  = ctrlAccount.FirstName;
                        ShippingAddress.FirstName = ctrlAccount.LastName;
                        ShippingAddress.Phone     = ctrlAccount.Phone;
                    }

                    if (AppLogic.AppConfigBool("Vat.Enabled") && ctrlAccount.VATRegistrationID.Length > 0)
                    {
                        String vtr = ctrlAccount.VATRegistrationID.Trim();

                        Exception vatServiceException = null;
                        if (AppLogic.VATRegistrationIDIsValid(ctrlBillingAddress.Country, vtr, out vatServiceException))
                        {
                            ThisCustomer.SetVATRegistrationID(vtr);
                        }
                        else
                        {
                            vtr = String.Empty;

                            if (vatServiceException != null && !String.IsNullOrEmpty(vatServiceException.Message))
                            {
                                if (vatServiceException.Message.Length > 255)
                                {
                                    lblErrorMessage.Text = Server.HtmlEncode(vatServiceException.Message.Substring(0, 255));
                                }
                                else
                                {
                                    lblErrorMessage.Text = Server.HtmlEncode(vatServiceException.Message);
                                }
                            }
                            else
                            {
                                lblErrorMessage.Text = "account.aspx.91".StringResource();
                            }
                            pnlErrorMsg.Visible = true;
                            return;
                        }
                    }
                    if (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") ||
                        AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled"))
                    {
                        ThisCustomer.ReplaceProductViewFromAnonymous();
                    }
                }
                if (Checkout)
                {
                    if (!NewEmailAllowed)
                    {
                        lblErrorMessage.Text = AppLogic.GetString("createaccount_process.aspx.1", 1, Localization.GetDefaultLocale());
                        InitializePageContent();
                    }
                    else
                    {
                        if (AppLogic.AppConfigBool("SendWelcomeEmail") && EMailField.IndexOf("@") != -1 && ThisCustomer.IsRegistered == true)
                        {
                            // don't let a simple welcome stop checkout!
                            try
                            {
                                string body = AppLogic.RunXmlPackage(AppLogic.AppConfig("XmlPackage.WelcomeEmail"),
                                                                     null,
                                                                     ThisCustomer,
                                                                     this.SkinID,
                                                                     "",
                                                                     "fullname=" + ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(),
                                                                     false,
                                                                     false,
                                                                     this.EntityHelpers);

                                AppLogic.SendMail(AppLogic.GetString("createaccount.aspx.79", ThisCustomer.SkinID, ThisCustomer.LocaleSetting),
                                                  body,
                                                  true,
                                                  AppLogic.AppConfig("MailMe_FromAddress"),
                                                  AppLogic.AppConfig("MailMe_FromName"),
                                                  EMailField,
                                                  ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(),
                                                  "",
                                                  AppLogic.MailServer());
                            }
                            catch { }
                        }
                        if (VerifyAddressPrompt)
                        {
                            if (AllowShipToDifferentThanBillTo)
                            {
                                Response.Redirect("address.aspx?Checkout=True&AddressType=Shipping&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration + "&returnURL=checkoutshipping.aspx?checkout=true");
                            }
                            else
                            {
                                Response.Redirect("address.aspx?Checkout=True&AddressType=Billing&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration + "&returnURL=checkoutshipping.aspx?checkout=true");
                            }
                        }
                        else
                        {
                            if (checkouttype == "ppec" || checkouttype == "ppbml" || checkouttype == "gc")
                            {
                                Response.Redirect("shoppingcart.aspx");
                            }
                            else
                            {
                                Response.Redirect("account.aspx?checkout=true");//checkoutshipping
                            }
                        }
                    }
                }
                else
                {
                    if (!NewEmailAllowed)
                    {
                        DB.ExecuteSQL("update customer set EMail='', IsRegistered = 0 where CustomerID=" + ThisCustomer.CustomerID);
                        lblErrorMessage.Text = AppLogic.GetString("createaccount_process.aspx.1", 1, Localization.GetDefaultLocale());
                        InitializePageContent();
                    }
                    else
                    {
                        if (AppLogic.AppConfigBool("SendWelcomeEmail") && EMailField.IndexOf("@") != -1 && ThisCustomer.IsRegistered == true)
                        {
                            // don't let a simple welcome stop checkout!
                            try
                            {
                                string body = AppLogic.RunXmlPackage(AppLogic.AppConfig("XmlPackage.WelcomeEmail"),
                                                                     null,
                                                                     ThisCustomer,
                                                                     this.SkinID,
                                                                     "",
                                                                     "",
                                                                     false,
                                                                     false,
                                                                     this.EntityHelpers);

                                AppLogic.SendMail(AppLogic.GetString("createaccount.aspx.79", ThisCustomer.SkinID, ThisCustomer.LocaleSetting),
                                                  body,
                                                  true,
                                                  AppLogic.AppConfig("MailMe_FromAddress"),
                                                  AppLogic.AppConfig("MailMe_FromName"),
                                                  EMailField,
                                                  ctrlAccount.FirstName.Trim() + " " + ctrlAccount.LastName.Trim(), "",
                                                  AppLogic.MailServer());
                            }
                            catch { }
                        }
                        if (VerifyAddressPrompt)
                        {
                            if (AllowShipToDifferentThanBillTo)
                            {
                                Response.Redirect("address.aspx?Checkout=False&AddressType=Shipping&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration);
                            }
                            else
                            {
                                Response.Redirect("address.aspx?Checkout=False&AddressType=Billing&AddressID=" + Customer.GetCustomerPrimaryShippingAddressID(ThisCustomer.CustomerID).ToString() + "&NewAccount=true&prompt=" + VerifyResult + "&skipreg=" + SkipRegistration);
                            }
                        }
                        else
                        {
                            Response.Redirect("JWMyAccount.aspx");
                        }
                    }
                }
            }
            else
            {
                foreach (IValidator aValidator in this.Validators)
                {
                    if (!aValidator.IsValid)
                    {
                        lblErrorMessage.Text = aValidator.ErrorMessage;
                        break;
                    }
                }
                ResetScrollPosition();
            }

            pnlErrorMsg.Visible = lblErrorMessage.Text.Length > 0;
        }
Exemple #29
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            RequireSecurePage();

            ReturnURL = CommonLogic.QueryStringCanBeDangerousContent("ReturnURL");
            AppLogic.CheckForScriptTag(ReturnURL);
            AddressTypeString = CommonLogic.QueryStringCanBeDangerousContent("AddressType");
            AppLogic.CheckForScriptTag(AddressTypeString);
            ThisCustomer.RequireCustomerRecord();
            if (!Shipping.MultiShipEnabled())
            {
                RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING"));
            }
            SectionTitle = String.Format(AppLogic.GetString("selectaddress.aspx.1", SkinID, ThisCustomer.LocaleSetting), AddressTypeString);
            Checkout     = CommonLogic.QueryStringBool("checkout");


            if (DB.GetSqlN("select count(*) as N from Address  with (NOLOCK)  where CustomerID=" + ThisCustomer.CustomerID.ToString()) == 0)
            {
                pnlAddressListBottom.Visible = false;
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("add").Equals("TRUE", StringComparison.InvariantCultureIgnoreCase))
            {
                liAdd.Visible = false;
            }

            if (AddressTypeString.Length != 0)
            {
                AddressType = (AddressTypes)Enum.Parse(typeof(AddressTypes), AddressTypeString, true);
            }
            if (AddressType == AddressTypes.Unknown)
            {
                AddressType       = AddressTypes.Shipping;
                AddressTypeString = "Shipping";
            }

            if (AddressType == AddressTypes.Billing)
            {
                SectionTitle += " - " + AppLogic.GetString("order.cs.58", SkinID, ThisCustomer.LocaleSetting);
            }
            else
            {
                SectionTitle += " - " + AppLogic.GetString("order.cs.57", SkinID, ThisCustomer.LocaleSetting);
            }

            custAddresses = new Addresses();
            custAddresses.LoadCustomer(ThisCustomer.CustomerID);


            if (AddressType == AddressTypes.Shipping)
            {
                ButtonImage = AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/usethisshippingaddress.gif", ThisCustomer.LocaleSetting);
            }
            else
            {
                ButtonImage = AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/usethisbillingaddress.gif", ThisCustomer.LocaleSetting);
            }
            PaymentMethodPrompt = "<b>" + AppLogic.GetString("selectaddress.aspx.8", SkinID, ThisCustomer.LocaleSetting) + "</b>";

            if (!IsPostBack)
            {
                InitializePageContent();
            }
        }
Exemple #30
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                SkinBase.GoNonSecureAgain();
            }

            ProductID      = CommonLogic.QueryStringUSInt("ProductID");
            CategoryID     = CommonLogic.QueryStringUSInt("CategoryID");
            SectionID      = CommonLogic.QueryStringUSInt("SectionID");
            ManufacturerID = CommonLogic.QueryStringUSInt("ManufacturerID");
            DistributorID  = CommonLogic.QueryStringUSInt("DistributorID");
            GenreID        = CommonLogic.QueryStringUSInt("GenreID");
            VectorID       = CommonLogic.QueryStringUSInt("VectorID");

            if (ProductID == 0)
            {
                if (IsAddToCartPostBack)
                {
                    int    PackID                 = 0;
                    int    packProductID          = 0;
                    int    packVariantID          = 0;
                    int    packQuantity           = 0;
                    int    packProductTypeID      = 0;
                    bool   FromCart               = false;
                    int    packCartRecID          = 0;
                    String ChosenColor            = String.Empty;
                    String ChosenColorSKUModifier = String.Empty;
                    String ChosenSize             = String.Empty;
                    String ChosenSizeSKUModifier  = String.Empty;
                    String color      = string.Empty;
                    String size       = string.Empty;
                    String TextOption = CommonLogic.FormCanBeDangerousContent("TextOption");


                    for (int i = 0; i <= HttpContext.Current.Request.Form.Count - 1; i++)
                    {
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("ProductID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            packProductID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent("__EVENTARGUMENT").Split('_')[1]);
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("VariantID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            packVariantID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent("__EVENTARGUMENT").Split('_')[2]);
                        }

                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("PackID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            PackID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                            if (CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).Contains(",") && PackID == 0)
                            {
                                PackID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).Split(',')[0]);
                            }
                        }

                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("Quantity", StringComparison.InvariantCultureIgnoreCase) && !HttpContext.Current.Request.Form.Keys[i].StartsWith("Quantity_vldt", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                packQuantity = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                            }
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("CartRecID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            packCartRecID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("Color", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                color = CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).ToString();
                            }
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("Size", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                size = CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]).ToString();
                            }
                        }
                        if (HttpContext.Current.Request.Form.Keys[i].StartsWith("ProductTypeID", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (Localization.ParseUSInt(HttpContext.Current.Request.Form.Keys[i].Split('_')[2]) == packVariantID)
                            {
                                packProductTypeID = Localization.ParseUSInt(CommonLogic.FormCanBeDangerousContent(HttpContext.Current.Request.Form.Keys[i]));
                            }
                        }
                    }


                    ThisCustomer.RequireCustomerRecord();
                    if (packQuantity == 0)
                    {
                        packQuantity = 1;
                    }
                    FromCart = (packCartRecID > 0);

                    if (color.Length != 0)
                    {
                        String[] ColorSel = color.Split(',');
                        try
                        {
                            ChosenColor = ColorSel[0];
                        }
                        catch { }
                        try
                        {
                            ChosenColorSKUModifier = ColorSel[1];
                        }
                        catch { }
                    }
                    if (ChosenColor.Length != 0)
                    {
                        ThisCustomer.ThisCustomerSession["ChosenColor"] = ChosenColor;
                    }


                    if (size.Length != 0)
                    {
                        String[] SizeSel = size.Split(',');
                        try
                        {
                            ChosenSize = SizeSel[0];
                        }
                        catch { }
                        try
                        {
                            ChosenSizeSKUModifier = SizeSel[1];
                        }
                        catch { }
                    }
                    if (ChosenSize.Length != 0)
                    {
                        ThisCustomer.ThisCustomerSession["ChosenSize"] = ChosenSize;
                    }

                    if (packQuantity > 0)
                    {
                        // add to custom cart:
                        if (FromCart)
                        {
                            CustomCart.AddItem(PackID, packProductID, packVariantID, packQuantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier, packCartRecID, ThisCustomer, CartTypeEnum.ShoppingCart);
                        }
                        else
                        {
                            CustomCart cart = new CustomCart(ThisCustomer, PackID, 1, CartTypeEnum.ShoppingCart);
                            cart.AddItem(packProductID, packVariantID, packQuantity, ChosenColor, ChosenColorSKUModifier, ChosenSize, ChosenSizeSKUModifier);
                        }
                    }

                    if (CommonLogic.QueryStringCanBeDangerousContent("UpdateCartPack") == "")
                    {
                        String url = "pb.aspx?type=" + packProductTypeID.ToString() + "&PackID=" + PackID.ToString() + "&ProductID=" + packProductID.ToString() + "&cartrecid=" + packCartRecID;

                        Response.Redirect(url + CommonLogic.IIF(FromCart, "?cartrecid=" + packCartRecID.ToString(), ""));
                        Response.Redirect(url);
                    }
                    else
                    {
                        Response.Redirect(ResolveClientUrl("~/shoppingcart.aspx"));
                    }
                }
            }
            String ActualSEName = string.Empty;

            using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
            {
                dbconn.Open();
                using (IDataReader rs = DB.GetRS(string.Format("select * from Product a with (NOLOCK) inner join (select a.ProductID, b.StoreID from Product a with (nolock) left join ProductStore b " +
                                                               "with (NOLOCK) on a.ProductID = b.ProductID) b on a.ProductID = b.ProductID where Deleted=0 and a.ProductID={0} and ({1}=0 or StoreID={2})", +
                                                               ProductID, CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowProductFiltering") == true, 1, 0), AppLogic.StoreID()), dbconn))
                {
                    if (!rs.Read())
                    {
                        Response.Redirect(SE.MakeDriverLink("ProductNotFound"));
                    }
                    else
                    {
                        bool a = DB.RSFieldBool(rs, "Published");
                        if (!a)
                        {
                            Response.Redirect(SE.MakeDriverLink("ProductNotFound"));
                        }
                    }

                    String SENameINURL = CommonLogic.QueryStringCanBeDangerousContent("SEName");
                    ActualSEName = SE.MungeName(DB.RSField(rs, "SEName"));
                    if (ActualSEName != SENameINURL)
                    {
                        String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);

                        string QStr  = "?";
                        bool   first = true;
                        for (int i = 0; i < Request.QueryString.Count; i++)
                        {
                            string key = Request.QueryString.GetKey(i);
                            if ((key.Equals("productid", StringComparison.InvariantCultureIgnoreCase)) == false && (key.Equals("sename", StringComparison.InvariantCultureIgnoreCase)) == false)
                            {
                                if (!first)
                                {
                                    QStr += "&";
                                }
                                QStr += key + "=" + Request.QueryString[i];
                                first = false;
                            }
                        }
                        if (QStr.Length > 1)
                        {
                            NewURL += QStr;
                        }

                        HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                        Response.Status = "301 Moved Permanently";
                        Response.AddHeader("Location", NewURL);
                        HttpContext.Current.Response.End();
                    }


                    #region Vortx Mobile Xml Package Modification
                    m_XmlPackage = Vortx.MobileFramework.MobileXmlPackageController.XmlPackageHook(DB.RSField(rs, "XmlPackage").ToLowerInvariant(), ThisCustomer);
                    #endregion
                    IsAKit  = DB.RSFieldBool(rs, "IsAKit");
                    IsAPack = DB.RSFieldBool(rs, "IsAPack");
                    if (m_XmlPackage.Length == 0)
                    {
                        if (IsAKit)
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductKitXmlPackage; // provide a default
                        }
                        else if (IsAPack)
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductPackXmlPackage; // provide a default
                        }
                        else
                        {
                            m_XmlPackage = AppLogic.ro_DefaultProductXmlPackage; // provide a default
                        }
                    }
                    RequiresReg = DB.RSFieldBool(rs, "RequiresRegistration");
                    ProductName = DB.RSFieldByLocale(rs, "Name", ThisCustomer.LocaleSetting);

                    CategoryHelper     = AppLogic.LookupHelper("Category", 0);
                    SectionHelper      = AppLogic.LookupHelper("Section", 0);
                    ManufacturerHelper = AppLogic.LookupHelper("Manufacturer", 0);
                    DistributorHelper  = AppLogic.LookupHelper("Distributor", 0);
                    GenreHelper        = AppLogic.LookupHelper("Genre", 0);
                    VectorHelper       = AppLogic.LookupHelper("Vector", 0);

                    String SEName = String.Empty;
                    if (DB.RSFieldByLocale(rs, "SETitle", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SETitle = Security.HtmlEncode(AppLogic.AppConfig("StoreName") + " - " + ProductName);
                    }
                    else
                    {
                        SETitle = DB.RSFieldByLocale(rs, "SETitle", ThisCustomer.LocaleSetting);
                    }
                    if (DB.RSFieldByLocale(rs, "SEDescription", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SEDescription = Security.HtmlEncode(ProductName);
                    }
                    else
                    {
                        SEDescription = DB.RSFieldByLocale(rs, "SEDescription", ThisCustomer.LocaleSetting);
                    }
                    if (DB.RSFieldByLocale(rs, "SEKeywords", ThisCustomer.LocaleSetting).Length == 0)
                    {
                        SEKeywords = Security.HtmlEncode(ProductName);
                    }
                    else
                    {
                        SEKeywords = DB.RSFieldByLocale(rs, "SEKeywords", ThisCustomer.LocaleSetting);
                    }
                    SENoScript = DB.RSFieldByLocale(rs, "SENoScript", ThisCustomer.LocaleSetting);
                }
            }

            //Log all views of unknown and registered customer
            if (!AppLogic.ProductIsMLExpress() && (AppLogic.AppConfigBool("DynamicRelatedProducts.Enabled") || AppLogic.AppConfigBool("RecentlyViewedProducts.Enabled")))
            {
                ThisCustomer.LogProductView(ProductID);
            }

            if (IsAKit && !Vortx.MobileFramework.MobileHelper.isMobile())
            {
                Server.Transfer(ResolveClientUrl("~/kitproduct.aspx"), true);
                return;
            }
            else if (IsAKit && Vortx.MobileFramework.MobileHelper.isMobile())
            {
                Server.Transfer(ResolveClientUrl("~/mobilekitproduct.aspx"), true);
                return;
            }

            CategoryName     = CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);
            SectionName      = SectionHelper.GetEntityName(SectionID, ThisCustomer.LocaleSetting);
            ManufacturerName = ManufacturerHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);
            DistributorName  = DistributorHelper.GetEntityName(DistributorID, ThisCustomer.LocaleSetting);
            GenreName        = GenreHelper.GetEntityName(GenreID, ThisCustomer.LocaleSetting);
            VectorName       = VectorHelper.GetEntityName(VectorID, ThisCustomer.LocaleSetting);

            String SourceEntityInstanceName = String.Empty;

            if (ManufacturerID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = ManufacturerID.ToString();
                Profile.LastViewedEntityInstanceName = ManufacturerName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (DistributorID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_DistributorEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = DistributorID.ToString();
                Profile.LastViewedEntityInstanceName = DistributorName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (GenreID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_GenreEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = GenreID.ToString();
                Profile.LastViewedEntityInstanceName = GenreName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (VectorID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_VectorEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = VectorID.ToString();
                Profile.LastViewedEntityInstanceName = VectorName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (CategoryID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = CategoryID.ToString();
                Profile.LastViewedEntityInstanceName = CategoryName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (SectionID != 0)
            {
                Profile.LastViewedEntityName         = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                Profile.LastViewedEntityInstanceID   = SectionID.ToString();
                Profile.LastViewedEntityInstanceName = SectionName;

                String NewURL = AppLogic.GetStoreHTTPLocation(false, false) + SE.MakeProductLink(ProductID, ActualSEName);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }

            SourceEntity             = Profile.LastViewedEntityName;
            SourceEntityInstanceName = Profile.LastViewedEntityInstanceName;
            SourceEntityID           = int.Parse(CommonLogic.IIF(CommonLogic.IsInteger(Profile.LastViewedEntityInstanceID), Profile.LastViewedEntityInstanceID, "0"));

            // validate that source entity id is actually valid for this product:
            if (SourceEntityID != 0)
            {
                String sqlx = string.Format("select count(*) as N from productentity a with (nolock) inner join (select distinct a.entityid, a.EntityType from productentity a with (nolock) left join EntityStore b with (nolock) " +
                                            "on a.EntityID = b.EntityID where ({0} = 0 or StoreID = {1})) b on a.EntityID = b.EntityID and a.EntityType=b.EntityType where ProductID = {2} and a.EntityID = {3} and a.EntityType = {4}"
                                            , CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowEntityFiltering") == true, 1, 0), AppLogic.StoreID(), ProductID, SourceEntityID, DB.SQuote(SourceEntity));
                if (DB.GetSqlN(sqlx) == 0)
                {
                    SourceEntityID = 0;
                }
            }

            // we had no entity context coming in, try to find a category context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    CategoryID   = SourceEntityID;
                    CategoryName = CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = CategoryID.ToString();
                    Profile.LastViewedEntityInstanceName = CategoryName;

                    SourceEntity             = EntityDefinitions.readonly_CategoryEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = CategoryName;
                }
            }

            // we had no entity context coming in, try to find a section context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    SectionID   = SourceEntityID;
                    SectionName = CategoryHelper.GetEntityName(SectionID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = SectionID.ToString();
                    Profile.LastViewedEntityInstanceName = SectionName;

                    SourceEntity             = EntityDefinitions.readonly_SectionEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = SectionName;
                }
            }

            // we had no entity context coming in, try to find a Manufacturer context for this product, so they have some context if possible:
            if (SourceEntityID == 0)
            {
                SourceEntityID = EntityHelper.GetProductsFirstEntity(ProductID, EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName);
                if (SourceEntityID > 0)
                {
                    ManufacturerID   = SourceEntityID;
                    ManufacturerName = CategoryHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);

                    Profile.LastViewedEntityName         = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                    Profile.LastViewedEntityInstanceID   = ManufacturerID.ToString();
                    Profile.LastViewedEntityInstanceName = ManufacturerName;

                    SourceEntity             = EntityDefinitions.readonly_ManufacturerEntitySpecs.m_EntityName;
                    SourceEntityInstanceName = ManufacturerName;
                }
            }

            // build up breadcrumb if we need:
            SectionTitle = Breadcrumb.GetProductBreadcrumb(ProductID, ProductName, SourceEntity, SourceEntityID, ThisCustomer);
            //Reset LastViewedEntityInstanceID to zero if no entities are mapped to the product so the left nav will render properly.
            if (SourceEntityID <= 0)
            {
                HttpContext.Current.Profile.SetPropertyValue("LastViewedEntityInstanceID", "0");
            }

            if (RequiresReg && !ThisCustomer.IsRegistered)
            {
                m_PageOutput += "<br/><br/><br/><br/><b>" + AppLogic.GetString("showproduct.aspx.1", SkinID, ThisCustomer.LocaleSetting) + "</b><br/><br/><br/><a href=\"signin.aspx?returnurl=" + CommonLogic.GetThisPageName(false) + "?ProductID=" + ProductID.ToString() + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").Trim().Length > 0, "&" + Security.HtmlEncode(Security.UrlEncode(CommonLogic.ServerVariables("QUERY_STRING"))), String.Empty) + "\">" + AppLogic.GetString("showproduct.aspx.2", SkinID, ThisCustomer.LocaleSetting) + "</a> " + AppLogic.GetString("showproduct.aspx.3", SkinID, ThisCustomer.LocaleSetting);
            }
            else
            {
                AppLogic.eventHandler("ViewProductPage").CallEvent("&ViewProductPage=true");

                // check if the postback was caused by an addtocart button
                if (this.IsPostBack && this.IsAddToCartPostBack)
                {
                    HandleAddToCart();
                    return;
                }

                DB.ExecuteSQL("update product set Looks=Looks+1 where ProductID=" + ProductID.ToString());

                m_PageOutput = "<!-- XmlPackage: " + m_XmlPackage + " -->\n";
                if (m_XmlPackage.Length == 0)
                {
                    m_PageOutput += "<p><b><font color=red>XmlPackage format was chosen, but no XmlPackage was specified!</font></b></p>";
                }
                else
                {
                    using (XmlPackage2 p = new XmlPackage2(m_XmlPackage, ThisCustomer, SkinID, "", "EntityName=" + SourceEntity + "&EntityID=" + SourceEntityID.ToString() + CommonLogic.IIF(CommonLogic.ServerVariables("QUERY_STRING").IndexOf("cartrecid") != -1, "&cartrecid=" + CommonLogic.QueryStringUSInt("cartrecid").ToString(), "&showproduct=1"), String.Empty, true))
                    {
                        m_PageOutput += AppLogic.RunXmlPackage(p, base.GetParser, ThisCustomer, SkinID, true, true);
                        if (p.SectionTitle != "")
                        {
                            SectionTitle = p.SectionTitle;
                        }
                        if (p.SETitle != "")
                        {
                            SETitle = p.SETitle;
                        }
                        if (p.SEDescription != "")
                        {
                            SEDescription = p.SEDescription;
                        }
                        if (p.SEKeywords != "")
                        {
                            SEKeywords = p.SEKeywords;
                        }
                        if (p.SENoScript != "")
                        {
                            SENoScript = p.SENoScript;
                        }
                    }
                }
            }
            litOutput.Text = m_PageOutput;
        }