protected void btnAddToCart_Click(object sender, EventArgs e)
        {
            foreach (RepeaterItem item in rptShoppingCart.Items)
            {
                var lblShoppingCartItemId = item.FindControl("lblShoppingCartItemId") as Label;
                var cbAddToCart           = item.FindControl("cbAddToCart") as CheckBox;

                int shoppingCartItemId = 0;
                if (lblShoppingCartItemId != null && cbAddToCart != null)
                {
                    int.TryParse(lblShoppingCartItemId.Text, out shoppingCartItemId);
                    if (cbAddToCart.Checked)
                    {
                        var sci = this.ShoppingCartService.GetShoppingCartItemById(shoppingCartItemId);
                        if (sci != null)
                        {
                            this.ShoppingCartService.AddToCart(
                                ShoppingCartTypeEnum.ShoppingCart,
                                sci.ProductVariantId,
                                sci.AttributesXml,
                                sci.CustomerEnteredPrice,
                                sci.Quantity);
                        }
                    }
                }
            }

            Response.Redirect(SEOHelper.GetShoppingCartUrl());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CommonHelper.SetResponseNoCache(Response);

            if (this.Cart.Count == 0)
            {
                Response.Redirect(SEOHelper.GetShoppingCartUrl());
            }

            //user validation
            if (NopContext.Current.User == null && this.CustomerService.AnonymousCheckoutAllowed)
            {
                //create anonymous record
                this.CustomerService.CreateAnonymousUser();
            }

            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !this.CustomerService.AnonymousCheckoutAllowed))
            {
                string loginURL = SEOHelper.GetLoginPageUrl(true);
                Response.Redirect(loginURL);
            }

            //reset checkout data
            this.CustomerService.ResetCheckoutData(NopContext.Current.User.CustomerId, false);


            //validation
            var scWarnings = this.ShoppingCartService.GetShoppingCartWarnings(Cart, NopContext.Current.User.CheckoutAttributes, true);

            if (scWarnings.Count > 0)
            {
                Response.Redirect(SEOHelper.GetShoppingCartUrl());
            }
            else
            {
                foreach (ShoppingCartItem sci in this.Cart)
                {
                    var sciWarnings = this.ShoppingCartService.GetShoppingCartItemWarnings(
                        sci.ShoppingCartType,
                        sci.ProductVariantId,
                        sci.AttributesXml,
                        sci.CustomerEnteredPrice,
                        sci.Quantity);
                    if (sciWarnings.Count > 0)
                    {
                        Response.Redirect(SEOHelper.GetShoppingCartUrl());
                    }
                }
            }

            if (this.SettingManager.GetSettingValueBoolean("Checkout.UseOnePageCheckout"))
            {
                Response.Redirect("~/checkoutonepage.aspx");
            }
            else
            {
                Response.Redirect("~/checkoutshippingaddress.aspx");
            }
        }
Beispiel #3
0
 protected void BtnReOrder_OnClick(object sender, EventArgs e)
 {
     try
     {
         OrderManager.ReOrder(this.OrderId);
         Response.Redirect(SEOHelper.GetShoppingCartUrl());
     }
     catch (Exception)
     {
     }
 }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !this.CustomerService.AnonymousCheckoutAllowed))
            {
                string loginURL = SEOHelper.GetLoginPageUrl(true);
                Response.Redirect(loginURL);
            }

            if (this.Cart.Count == 0)
            {
                Response.Redirect(SEOHelper.GetShoppingCartUrl());
            }
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !this.CustomerService.AnonymousCheckoutAllowed))
            {
                string loginURL = SEOHelper.GetLoginPageUrl(true);
                Response.Redirect(loginURL);
            }

            if (Cart.Count == 0)
            {
                Response.Redirect(SEOHelper.GetShoppingCartUrl());
            }

            //validation
            var scWarnings = this.ShoppingCartService.GetShoppingCartWarnings(Cart, NopContext.Current.User.CheckoutAttributes, true);

            if (scWarnings.Count > 0)
            {
                Response.Redirect(SEOHelper.GetShoppingCartUrl());
            }
            else
            {
                foreach (ShoppingCartItem sci in this.Cart)
                {
                    List <String> sciWarnings = this.ShoppingCartService.GetShoppingCartItemWarnings(
                        sci.ShoppingCartType,
                        sci.ProductVariantId,
                        sci.AttributesXml,
                        sci.CustomerEnteredPrice,
                        sci.Quantity);
                    if (sciWarnings.Count > 0)
                    {
                        Response.Redirect(SEOHelper.GetShoppingCartUrl());
                    }
                }
            }

            if (!Page.IsPostBack)
            {
                if (!this.ShippingService.ShoppingCartRequiresShipping(Cart))
                {
                    pnlShippingAddress.Visible = false;
                    pnlShippingMethods.Visible = false;
                }

                SelectPane(CheckoutStepEnum.ShippingAddress);
            }
        }
Beispiel #6
0
        protected void btnAddToCart_Click(object sender, CommandEventArgs e)
        {
            int productId        = Convert.ToInt32(e.CommandArgument);
            int productVariantId = 0;

            if (ProductManager.DirectAddToCartAllowed(productId, out productVariantId))
            {
                var addToCartWarnings = ShoppingCartManager.AddToCart(ShoppingCartTypeEnum.ShoppingCart,
                                                                      productVariantId, string.Empty, decimal.Zero, 1);
                if (addToCartWarnings.Count == 0)
                {
                    bool displayCart = true;
                    if (this.RedirectCartAfterAddingProduct.HasValue)
                    {
                        displayCart = this.RedirectCartAfterAddingProduct.Value;
                    }
                    else
                    {
                        displayCart = SettingManager.GetSettingValueBoolean("Display.Products.DisplayCartAfterAddingProduct");
                    }

                    if (displayCart)
                    {
                        //redirect to shopping cart page
                        Response.Redirect(SEOHelper.GetShoppingCartUrl());
                    }
                    else
                    {
                        //display notification message
                        this.DisplayAlertMessage(GetLocaleResourceString("Products.ProductHasBeenAddedToTheCart"));
                    }
                }
                else
                {
                    string productURL = SEOHelper.GetProductUrl(productId);
                    Response.Redirect(productURL);
                }
            }
            else
            {
                string productURL = SEOHelper.GetProductUrl(productId);
                Response.Redirect(productURL);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CommonHelper.SetResponseNoCache(Response);

            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = SEOHelper.GetLoginPageUrl(true);
                Response.Redirect(loginURL);
            }

            ShoppingCart cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);

            if (cart.Count == 0)
            {
                Response.Redirect(SEOHelper.GetShoppingCartUrl());
            }

            this.btnNextStep.Attributes.Add("onclick", "this.disabled = true;" + Page.ClientScript.GetPostBackEventReference(this.btnNextStep, ""));
        }
Beispiel #8
0
        protected void UpdateShoppingCart()
        {
            if (!IsShoppingCart)
            {
                return;
            }

            ApplyCheckoutAttributes();
            bool hasErrors = ValidateCartItems();

            if (!hasErrors)
            {
                foreach (RepeaterItem item in rptShoppingCart.Items)
                {
                    var txtQuantity           = item.FindControl("txtQuantity") as TextBox;
                    var lblShoppingCartItemId = item.FindControl("lblShoppingCartItemId") as Label;
                    var cbRemoveFromCart      = item.FindControl("cbRemoveFromCart") as CheckBox;
                    int shoppingCartItemId    = 0;
                    int quantity = 0;
                    if (txtQuantity != null && lblShoppingCartItemId != null && cbRemoveFromCart != null)
                    {
                        int.TryParse(lblShoppingCartItemId.Text, out shoppingCartItemId);
                        if (cbRemoveFromCart.Checked)
                        {
                            ShoppingCartManager.DeleteShoppingCartItem(shoppingCartItemId, true);
                        }
                        else
                        {
                            int.TryParse(txtQuantity.Text, out quantity);
                            List <string> addToCartWarning = ShoppingCartManager.UpdateCart(shoppingCartItemId, quantity, true);
                        }
                    }
                }

                Response.Redirect(SEOHelper.GetShoppingCartUrl());
            }
        }
Beispiel #9
0
        private void SetLinks()
        {
            switch (this.OrderProgressStep.ToLowerInvariant())
            {
            case "cart":
            {
                hlCart.NavigateUrl     = SEOHelper.GetShoppingCartUrl();
                hlAddress.NavigateUrl  = string.Empty;
                hlShipping.NavigateUrl = string.Empty;
                hlPayment.NavigateUrl  = string.Empty;
                hlConfirm.NavigateUrl  = string.Empty;
                hlComplete.NavigateUrl = string.Empty;
            }
            break;

            case "address":
            {
                hlCart.NavigateUrl     = SEOHelper.GetShoppingCartUrl();
                hlAddress.NavigateUrl  = CommonHelper.GetStoreLocation() + "checkoutshippingaddress.aspx";
                hlShipping.NavigateUrl = string.Empty;
                hlPayment.NavigateUrl  = string.Empty;
                hlConfirm.NavigateUrl  = string.Empty;
                hlComplete.NavigateUrl = string.Empty;
            }
            break;

            case "shipping":
            {
                hlCart.NavigateUrl     = SEOHelper.GetShoppingCartUrl();
                hlAddress.NavigateUrl  = CommonHelper.GetStoreLocation() + "checkoutshippingaddress.aspx";
                hlShipping.NavigateUrl = CommonHelper.GetStoreLocation() + "checkoutshippingmethod.aspx";
                hlPayment.NavigateUrl  = string.Empty;
                hlConfirm.NavigateUrl  = string.Empty;
                hlComplete.NavigateUrl = string.Empty;
            }
            break;

            case "payment":
            {
                hlCart.NavigateUrl     = SEOHelper.GetShoppingCartUrl();
                hlAddress.NavigateUrl  = CommonHelper.GetStoreLocation() + "checkoutshippingaddress.aspx";
                hlShipping.NavigateUrl = CommonHelper.GetStoreLocation() + "checkoutshippingmethod.aspx";
                hlPayment.NavigateUrl  = CommonHelper.GetStoreLocation() + "checkoutpaymentmethod.aspx";
                hlConfirm.NavigateUrl  = string.Empty;
                hlComplete.NavigateUrl = string.Empty;
            }
            break;

            case "confirm":
            {
                hlCart.NavigateUrl     = SEOHelper.GetShoppingCartUrl();
                hlAddress.NavigateUrl  = CommonHelper.GetStoreLocation() + "checkoutshippingaddress.aspx";
                hlShipping.NavigateUrl = CommonHelper.GetStoreLocation() + "checkoutshippingmethod.aspx";
                hlPayment.NavigateUrl  = CommonHelper.GetStoreLocation() + "checkoutpaymentmethod.aspx";
                hlConfirm.NavigateUrl  = CommonHelper.GetStoreLocation() + "checkoutconfirm.aspx";
                hlComplete.NavigateUrl = string.Empty;
            }
            break;

            case "complete":
            {
                hlCart.NavigateUrl     = string.Empty;
                hlAddress.NavigateUrl  = string.Empty;
                hlShipping.NavigateUrl = string.Empty;
                hlPayment.NavigateUrl  = string.Empty;
                hlConfirm.NavigateUrl  = string.Empty;
                hlComplete.NavigateUrl = string.Empty;
            }
            break;

            default:
            {
                hlCart.NavigateUrl     = string.Empty;
                hlAddress.NavigateUrl  = string.Empty;
                hlShipping.NavigateUrl = string.Empty;
                hlPayment.NavigateUrl  = string.Empty;
                hlConfirm.NavigateUrl  = string.Empty;
                hlComplete.NavigateUrl = string.Empty;
            }
            break;
            }
        }
        protected void rptVariants_OnItemCommand(Object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "AddToCart" || e.CommandName == "AddToWishlist")
            {
                var txtQuantity             = e.Item.FindControl("txtQuantity") as NumericTextBox;
                var txtCustomerEnteredPrice = e.Item.FindControl("txtCustomerEnteredPrice") as DecimalTextBox;
                var productVariantId        = e.Item.FindControl("ProductVariantId") as Label;
                var ctrlProductAttributes   = e.Item.FindControl("ctrlProductAttributes") as ProductAttributesControl;
                var ctrlGiftCardAttributes  = e.Item.FindControl("ctrlGiftCardAttributes") as GiftCardAttributesControl;
                var lblError = e.Item.FindControl("lblError") as Label;

                var pv = ProductManager.GetProductVariantById(Convert.ToInt32(productVariantId.Text));
                if (pv == null)
                {
                    return;
                }

                string  attributes                    = ctrlProductAttributes.SelectedAttributes;
                decimal customerEnteredPrice          = txtCustomerEnteredPrice.Value;
                decimal customerEnteredPriceConverted = CurrencyManager.ConvertCurrency(customerEnteredPrice, NopContext.Current.WorkingCurrency, CurrencyManager.PrimaryStoreCurrency);
                int     quantity = txtQuantity.Value;

                //gift cards
                if (pv.IsGiftCard)
                {
                    string recipientName   = ctrlGiftCardAttributes.RecipientName;
                    string recipientEmail  = ctrlGiftCardAttributes.RecipientEmail;
                    string senderName      = ctrlGiftCardAttributes.SenderName;
                    string senderEmail     = ctrlGiftCardAttributes.SenderEmail;
                    string giftCardMessage = ctrlGiftCardAttributes.GiftCardMessage;

                    attributes = ProductAttributeHelper.AddGiftCardAttribute(attributes,
                                                                             recipientName, recipientEmail, senderName, senderEmail, giftCardMessage);
                }

                try
                {
                    if (e.CommandName == "AddToCart")
                    {
                        string        sep = "<br />";
                        List <string> addToCartWarnings = ShoppingCartManager.AddToCart(
                            ShoppingCartTypeEnum.ShoppingCart,
                            pv.ProductVariantId,
                            attributes,
                            customerEnteredPriceConverted,
                            quantity);
                        if (addToCartWarnings.Count == 0)
                        {
                            if (SettingManager.GetSettingValueBoolean("Display.Products.DisplayCartAfterAddingProduct"))
                            {
                                //redirect to shopping cart page
                                Response.Redirect(SEOHelper.GetShoppingCartUrl());
                            }
                            else
                            {
                                //display notification message
                                this.DisplayAlertMessage(GetLocaleResourceString("Products.ProductHasBeenAddedToTheCart"));
                            }
                        }
                        else
                        {
                            StringBuilder addToCartWarningsSb = new StringBuilder();
                            for (int i = 0; i < addToCartWarnings.Count; i++)
                            {
                                addToCartWarningsSb.Append(Server.HtmlEncode(addToCartWarnings[i]));
                                if (i != addToCartWarnings.Count - 1)
                                {
                                    addToCartWarningsSb.Append(sep);
                                }
                            }
                            string errorFull = addToCartWarningsSb.ToString();
                            lblError.Text = errorFull;
                            if (SettingManager.GetSettingValueBoolean("Common.ShowAlertForProductAttributes"))
                            {
                                this.DisplayAlertMessage(errorFull.Replace(sep, "\\n"));
                            }
                        }
                    }

                    if (e.CommandName == "AddToWishlist")
                    {
                        string sep = "<br />";
                        var    addToCartWarnings = ShoppingCartManager.AddToCart(
                            ShoppingCartTypeEnum.Wishlist,
                            pv.ProductVariantId,
                            attributes,
                            customerEnteredPriceConverted,
                            quantity);
                        if (addToCartWarnings.Count == 0)
                        {
                            Response.Redirect(SEOHelper.GetWishlistUrl());
                        }
                        else
                        {
                            var addToCartWarningsSb = new StringBuilder();
                            for (int i = 0; i < addToCartWarnings.Count; i++)
                            {
                                addToCartWarningsSb.Append(Server.HtmlEncode(addToCartWarnings[i]));
                                if (i != addToCartWarnings.Count - 1)
                                {
                                    addToCartWarningsSb.Append(sep);
                                }
                            }
                            string errorFull = addToCartWarningsSb.ToString();
                            lblError.Text = errorFull;
                            if (SettingManager.GetSettingValueBoolean("Common.ShowAlertForProductAttributes"))
                            {
                                this.DisplayAlertMessage(errorFull.Replace(sep, "\\n"));
                            }
                        }
                    }
                }
                catch (Exception exc)
                {
                    LogManager.InsertLog(LogTypeEnum.CustomerError, exc.Message, exc);
                    lblError.Text = Server.HtmlEncode(exc.Message);
                }
            }
        }
Beispiel #11
0
 protected void BtnCheckout_OnClick(object sender, EventArgs e)
 {
     Response.Redirect(SEOHelper.GetShoppingCartUrl());
 }
Beispiel #12
0
        protected override void OnPreRender(EventArgs e)
        {
            if (SettingManager.GetSettingValueBoolean("Common.ShowMiniShoppingCart"))
            {
                var shoppingCart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
                if (shoppingCart.Count == 0)
                {
                    phCheckoutInfo.Visible = false;
                    lShoppingCart.Text     = GetLocaleResourceString("MiniShoppingCartBox.NoItems");

                    lvCart.Visible = false;
                }
                else
                {
                    phCheckoutInfo.Visible = true;
                    if (shoppingCart.Count == 1)
                    {
                        lShoppingCart.Text = string.Format(GetLocaleResourceString("MiniShoppingCartBox.OneItemText"), string.Format("<a href=\"{0}\" class=\"items\">{1}</a>", SEOHelper.GetShoppingCartUrl(), GetLocaleResourceString("MiniShoppingCartBox.OneItem")));
                    }
                    else
                    {
                        lShoppingCart.Text = string.Format(GetLocaleResourceString("MiniShoppingCartBox.SeveralItemsText"), string.Format("<a href=\"{0}\" class=\"items\">{1}</a>", SEOHelper.GetShoppingCartUrl(), string.Format(GetLocaleResourceString("MiniShoppingCartBox.SeveralItems"), shoppingCart.Count)));
                    }

                    lblOrderSubtotal.Text = GetLocaleResourceString("MiniShoppingCartBox.OrderSubtotal", GetOrderSubtotal(shoppingCart));

                    if (SettingManager.GetSettingValueBoolean("Display.ItemsInMiniShoppingCart", false))
                    {
                        lvCart.Visible    = true;
                        lvCart.DataSource = shoppingCart;
                        lvCart.DataBind();
                    }
                    else
                    {
                        lvCart.Visible = false;
                    }
                }
            }
            else
            {
                this.Visible = false;
            }
            base.OnPreRender(e);
        }