Example #1
0
        private void HandleAddToCart()
        {
            // extract the input parameters from the form post
            AddToCartInfo formInput = AddToCartInfo.FromForm(ThisCustomer);

            if (formInput != AddToCartInfo.INVALID_FORM_COMPOSITION)
            {
                string returnUrl = SE.MakeObjectLink("Product", formInput.ProductId, String.Empty);

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

                    ErrorMessage er;

                    if (formInput.CartType == CartTypeEnum.WishCart)
                    {
                        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 (formInput.CartType == CartTypeEnum.GiftRegistryCart)
                    {
                        ErrMsg = AppLogic.GetString("signin.aspx.28", 1, ThisCustomer.LocaleSetting);
                        er     = new ErrorMessage(ErrMsg);
                        Response.Redirect("signin.aspx?ErrorMsg=" + er.MessageId + "&ReturnUrl=" + Security.UrlEncode(returnUrl));
                    }
                }


                bool success = ShoppingCart.AddToCart(ThisCustomer, formInput);
                AppLogic.eventHandler("AddToCart").CallEvent("&AddToCart=true&VariantID=" + formInput.VariantId.ToString() + "&ProductID=" + formInput.ProductId.ToString() + "&ChosenColor=" + formInput.ChosenColor.ToString() + "&ChosenSize=" + formInput.ChosenSize.ToString());
                if (success)
                {
                    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
                    {
                        if (formInput.CartType == CartTypeEnum.WishCart)
                        {
                            Response.Redirect(ResolveClientUrl("~/wishlist.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                        }
                        if (formInput.CartType == CartTypeEnum.GiftRegistryCart)
                        {
                            Response.Redirect(ResolveClientUrl("~/giftregistry.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                        }
                        // default
                        Response.Redirect(ResolveClientUrl("~/ShoppingCart.aspx?add=true&ReturnUrl=" + Security.UrlEncode(returnUrl)));
                    }
                }
            }

            return;
        }
Example #2
0
    public bool AddToCart(string sProductId,
                          string sVariantId,
                          string sCartType,
                          string sQuantity,
                          string sShippingAddressId,
                          string sVariantStyle,
                          string textOption,
                          string sCustomerEnteredPrice,
                          string colorOptions,
                          string sizeOptions,
                          string upsellProductIds,
                          string sShoppingCartRecordId,
                          string sIsEditKit,
                          string kitItemValues)
    {
        bool success = false;

        Customer ThisCustomer = Customer.Current;

        if (ThisCustomer != null)
        {
            int productId = Localization.ParseNativeInt(sProductId);

            AddToCartInfo formInput = AddToCartInfo.NewAddToCartInfo(ThisCustomer, productId);
            if (formInput == AddToCartInfo.INVALID_FORM_COMPOSITION)
            {
                success = false;
            }
            else
            {
                formInput.CartType  = (CartTypeEnum)Localization.ParseNativeInt(sCartType);
                formInput.VariantId = Localization.ParseNativeInt(sVariantId);
                formInput.Quantity  = Localization.ParseNativeInt(sQuantity);

                formInput.ParseValidShippingAddressId(sShippingAddressId);
                formInput.ParseValidCustomerEnteredPrice(sCustomerEnteredPrice);

                formInput.ParseColorOptions(colorOptions);
                formInput.ParseSizeOptions(sizeOptions);

                formInput.TextOption   = textOption;
                formInput.VariantStyle = (VariantStyleEnum)Localization.ParseNativeInt(sVariantStyle);

                // kit specific
                formInput.IsEditKit            = IsFormBool(sIsEditKit);
                formInput.ShoppingCartRecordId = Localization.ParseNativeInt(sShoppingCartRecordId);
                formInput.IsKit2 = !CommonLogic.IsStringNullOrEmpty(kitItemValues);

                formInput.ParseUpsellProductIds(upsellProductIds);

                success = ShoppingCart.AddToCart(ThisCustomer, formInput);
            }
        }

        return(success);
    }
Example #3
0
        private void HandleAddToCart()
        {
            // extract the input parameters from the form post
            AddToCartInfo formInput = AddToCartInfo.FromForm(ThisCustomer);

            if (formInput != AddToCartInfo.INVALID_FORM_COMPOSITION)
            {
                bool success = ShoppingCart.AddToCart(ThisCustomer, formInput);
                AppLogic.eventHandler("AddToCart").CallEvent("&AddToCart=true&VariantID=" + formInput.VariantId.ToString() + "&ProductID=" + formInput.ProductId.ToString() + "&ChosenColor=" + formInput.ChosenColor.ToString() + "&ChosenSize=" + formInput.ChosenSize.ToString());
                if (success)
                {
                    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");

                        if (formInput.CartType == CartTypeEnum.WishCart)
                        {
                            Response.Redirect(ResolveClientUrl("~/wishlist.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                        }
                        if (formInput.CartType == CartTypeEnum.GiftRegistryCart)
                        {
                            Response.Redirect(ResolveClientUrl("~/giftregistry.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                        }
                        // default
                        Response.Redirect(ResolveClientUrl("~/ShoppingCart.aspx?add=true&ReturnUrl=" + Security.UrlEncode(returnUrl)));
                    }
                }
            }

            return;
        }
Example #4
0
        private void HandleAddToCart()
        {
            if (String.IsNullOrEmpty(txtBluBuksUsed.Text) || String.IsNullOrWhiteSpace(txtBluBuksUsed.Text) || txtBluBuksUsed.Text == ".")
            {
                txtBluBuksUsed.Text = "0";
            }

            if (String.IsNullOrEmpty(txtproductcategoryfundusedforsalesrep.Text) || String.IsNullOrWhiteSpace(txtproductcategoryfundusedforsalesrep.Text) || (txtproductcategoryfundusedforsalesrep.Text == "."))
            {
                txtproductcategoryfundusedforsalesrep.Text = "0";
            }
            // extract the input parameters from the form post
            AddToCartInfo formInput = AddToCartInfo.FromForm(ThisCustomer);

            formInput.BluBucksUsed = Convert.ToDecimal(txtBluBuksUsed.Text);
            formInput.FundID       = Convert.ToInt32(hdnProductFundID.Text);
            //GLcode holds decision parameter value
            formInput.GLcode = SOFCodeChoice;
            if (ThisCustomer.CustomerLevelID == 3 || ThisCustomer.CustomerLevelID == 7)
            {
                if (Convert.ToInt16(formInput.GLcode) == (int)SOFUsedType.NF)
                {
                    formInput.CategoryFundUsed = Convert.ToDecimal("0.00");
                }
                else
                {
                    formInput.CategoryFundUsed = Convert.ToDecimal(txtproductcategoryfundusedforsalesrep.Text);
                }

                formInput.FundID = (int)FundType.SOFFunds;
            }
            else
            {
                formInput.CategoryFundUsed = Convert.ToDecimal(hdnProductFundAmountUsed.Text);
            }


            formInput.BluBucksPercentageUsed = Convert.ToDecimal(hdnBudgetPercentValue.Text);
            formInput.ProductCategoryID      = Convert.ToInt32(hdnProductCategoryID.Text);

            if (Convert.ToInt16(formInput.GLcode) == (int)SOFUsedType.SOFF)
            {
                formInput.SOFCode = txtSOFCode.Text;
            }
            else if (Convert.ToInt16(formInput.GLcode) == (int)SOFUsedType.CAPEX)
            {
                formInput.SOFCode = txtCAPEX.Text;
            }
            else
            {
                formInput.SOFCode = "0";
            }
            if (formInput != AddToCartInfo.INVALID_FORM_COMPOSITION)
            {
                string returnUrl = SE.MakeObjectLink("Product", formInput.ProductId, String.Empty);

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

                    ErrorMessage er;

                    if (formInput.CartType == CartTypeEnum.WishCart)
                    {
                        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 (formInput.CartType == CartTypeEnum.GiftRegistryCart)
                    {
                        ErrMsg = AppLogic.GetString("signin.aspx.28", 1, ThisCustomer.LocaleSetting);
                        er     = new ErrorMessage(ErrMsg);
                        Response.Redirect("signin.aspx?ErrorMsg=" + er.MessageId + "&ReturnUrl=" + Security.UrlEncode(returnUrl));
                    }
                }


                bool success = ShoppingCart.AddToCart(ThisCustomer, formInput);
                AppLogic.eventHandler("AddToCart").CallEvent("&AddToCart=true&VariantID=" + formInput.VariantId.ToString() + "&ProductID=" + formInput.ProductId.ToString() + "&ChosenColor=" + formInput.ChosenColor.ToString() + "&ChosenSize=" + formInput.ChosenSize.ToString());
                if (success)
                {
                    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
                    {
                        if (formInput.CartType == CartTypeEnum.WishCart)
                        {
                            Response.Redirect(ResolveClientUrl("~/wishlist.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                        }
                        if (formInput.CartType == CartTypeEnum.GiftRegistryCart)
                        {
                            Response.Redirect(ResolveClientUrl("~/giftregistry.aspx?ReturnUrl=" + Security.UrlEncode(returnUrl)));
                        }
                        // default
                        Response.Redirect(ResolveClientUrl("~/ShoppingCart.aspx?add=true&ReturnUrl=" + Security.UrlEncode(returnUrl)));
                    }
                }
            }


            return;
        }