Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = CommonHelper.GetLoginPageURL(true);
                Response.Redirect(loginURL);
            }

            if (!Page.IsPostBack)
            {
                OrderCollection orderCollection = NopContext.Current.User.Orders;
                if (orderCollection.Count == 0)
                {
                    Response.Redirect("~/Default.aspx");
                }

                Order lastOrder = orderCollection[0];
                lblOrderNumber.Text        = lastOrder.OrderID.ToString();
                hlOrderDetails.NavigateUrl = string.Format("{0}OrderDetails.aspx?OrderID={1}", CommonHelper.GetStoreLocation(), lastOrder.OrderID);

                var shoppingCart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
                foreach (ShoppingCartItem sc in shoppingCart)
                {
                    ShoppingCartManager.DeleteShoppingCartItem(sc.ShoppingCartItemID, false);
                }

                var indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders();
                foreach (BusinessLogic.Orders.IndividualOrder indOrder in indOrders)
                {
                    IndividualOrderManager.DeleteIndividualOrder(indOrder.IndividualOrderID);
                }
            }
        }
Exemplo n.º 2
0
        protected int GetCount()
        {
            int cartCount = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart).Count;
            int indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders().Count;

            return(cartCount + indOrders);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = CommonHelper.GetLoginPageURL(true);
                Response.Redirect(loginURL);
            }

            Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
            IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders();

            if (Cart.Count == 0 && indOrders.Count == 0)
            {
                Response.Redirect("~/ShoppingCart.aspx");
            }

            bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart);

            if (!shoppingCartRequiresShipping)
            {
                NopContext.Current.User.LastShippingOption = null;
                Response.Redirect("~/CheckoutPaymentMethod.aspx");
            }

            if (!Page.IsPostBack)
            {
                if (shoppingCartRequiresShipping)
                {
                    //ShipmentPackage shipmentPackage = ShippingManager.CreateShipmentPackage(Cart, NopContext.Current.User.ShippingAddress);
                    string error = string.Empty;
                    ShippingOptionCollection shippingOptions = ShippingManager.GetShippingOptions(Cart, NopContext.Current.User, NopContext.Current.User.ShippingAddress, ref error);
                    if (!String.IsNullOrEmpty(error))
                    {
                        LogManager.InsertLog(LogTypeEnum.ShippingErrror, error, error);
                        lError.Text = Server.HtmlEncode(error);
                    }
                    else
                    {
                        if (shippingOptions.Count > 0)
                        {
                            dlShippingOptions.DataSource = shippingOptions;
                            dlShippingOptions.DataBind();
                        }
                        else
                        {
                            phSelectShippingMethod.Visible = false;
                            phShippingIsNotAllowed.Visible = true;
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CommonHelper.EnsureSSL();
            }

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

            ShoppingCart cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
            IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders();

            if (cart.Count == 0 && indOrders.Count == 0)
            {
                Response.Redirect("~/ShoppingCart.aspx");
            }

            if (NopContext.Current.User == null && CustomerManager.AnonymousCheckoutAllowed)
            {
                //create anonymous record
                string email    = "*****@*****.**";
                string password = string.Empty;
                MembershipCreateStatus status = MembershipCreateStatus.UserRejected;
                Customer guestCustomer        = CustomerManager.AddCustomer(email, email, password, false, true, true, out status);
                if (guestCustomer != null && status == MembershipCreateStatus.Success)
                {
                    NopContext.Current.User = guestCustomer;

                    if (NopContext.Current.Session == null)
                    {
                        NopContext.Current.Session = NopContext.Current.GetSession(true);
                    }

                    NopContext.Current.Session = CustomerManager.SaveCustomerSession(NopContext.Current.Session.CustomerSessionGUID,
                                                                                     guestCustomer.CustomerID, DateTime.Now, NopContext.Current.Session.IsExpired);
                }
            }

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

            string title = GetLocaleResourceString("PageTitle.Checkout");

            SEOHelper.RenderTitle(this, title, true);

            Response.Redirect("~/CheckoutBillingAddress.aspx");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = CommonHelper.GetLoginPageURL(true);
                Response.Redirect(loginURL);
            }

            Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
            IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders();

            if (Cart.Count == 0 && indOrders.Count == 0)
            {
                Response.Redirect("~/ShoppingCart.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = CommonHelper.GetLoginPageURL(true);
                Response.Redirect(loginURL);
            }

            Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
            IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders();

            if (Cart.Count == 0 && indOrders.Count == 0)
            {
                Response.Redirect("~/ShoppingCart.aspx");
            }

            btnNextStep.Attributes.Add("onclick", "this.disabled = true;" + Page.ClientScript.GetPostBackEventReference(this.btnNextStep, ""));
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = CommonHelper.GetLoginPageURL(true);
                Response.Redirect(loginURL);
            }

            Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
            IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders();

            if (Cart.Count == 0 && indOrders.Count == 0)
            {
                Response.Redirect("~/ShoppingCart.aspx");
            }

            if (!Page.IsPostBack)
            {
                CustomerManager.ResetCheckoutData(NopContext.Current.User.CustomerID, false);
            }
            bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart);

            if (!shoppingCartRequiresShipping)
            {
                SelectAddress(null);
                Response.Redirect("~/CheckoutBillingAddress.aspx");
            }

            if (!Page.IsPostBack)
            {
                AddressCollection addresses = getAllowedShippingAddresses(NopContext.Current.User);
                if (addresses.Count > 0)
                {
                    dlAddress.DataSource = addresses;
                    dlAddress.DataBind();
                    lEnterShippingAddress.Text = GetLocaleResourceString("Checkout.OrEnterNewAddress");
                }
                else
                {
                    pnlSelectShippingAddress.Visible = false;
                    lEnterShippingAddress.Text       = GetLocaleResourceString("Checkout.EnterShippingAddress");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = CommonHelper.GetLoginPageURL(true);
                Response.Redirect(loginURL);
            }

            Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
            IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders();

            if (Cart.Count == 0 && indOrders.Count == 0)
            {
                Response.Redirect("~/ShoppingCart.aspx");
            }

            if (!Page.IsPostBack)
            {
                Address shippingAddress = NopContext.Current.User.ShippingAddress;
                pnlTheSameAsShippingAddress.Visible = CustomerManager.CanUseAddressAsBillingAddress(shippingAddress);

                AddressCollection addresses = getAllowedBillingAddresses(NopContext.Current.User);

                if (addresses.Count > 0)
                {
                    //bind data
                    //if (addresses.Count > 1)
                    //    addresses.RemoveRange(1, addresses.Count - 1);
                    dlAddress.DataSource = addresses;
                    dlAddress.DataBind();
                    lEnterBillingAddress.Text = GetLocaleResourceString("Checkout.OrEnterNewAddress");
                }
                else
                {
                    pnlSelectBillingAddress.Visible = false;
                    lEnterBillingAddress.Text       = GetLocaleResourceString("Checkout.EnterBillingAddress");
                }
            }
        }
Exemplo n.º 9
0
        public void BindData()
        {
            ShoppingCart Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
            IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders();

            if (Cart.Count == 0 && indOrders.Count == 0)
            {
                pnlEmptyCart.Visible = true;
                pnlCart.Visible      = false;
            }
            else
            {
                pnlEmptyCart.Visible = false;
                pnlCart.Visible      = true;
                phCoupon.Visible     = DiscountManager.HasDiscountsWithCouponCode();

                rptShoppingCart.DataSource = Cart;
                rptShoppingCart.DataBind();
                ValidateCart();
            }

            this.ctrlOrderTotals.BindData();
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed))
            {
                string loginURL = CommonHelper.GetLoginPageURL(true);
                Response.Redirect(loginURL);
            }

            Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart);
            IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders();

            if (Cart.Count == 0 && indOrders.Count == 0)
            {
                Response.Redirect("~/ShoppingCart.aspx");
            }

            if (!Page.IsPostBack)
            {
                PaymentMethodCollection paymentMethods             = PaymentMethodManager.GetAllPaymentMethods();
                PaymentMethod           paypalExpressPaymentMethod = null;
                foreach (PaymentMethod pm in paymentMethods)
                {
                    if (pm.SystemKeyword == "PayPalExpress")
                    {
                        paypalExpressPaymentMethod = pm;
                    }
                }
                PaymentMethod googleCheckoutPaymentMethod = null;
                foreach (PaymentMethod pm in paymentMethods)
                {
                    if (pm.SystemKeyword == "GoogleCheckout")
                    {
                        googleCheckoutPaymentMethod = pm;
                    }
                }

                bool hasButtonMethods = false;
                if (paypalExpressPaymentMethod != null && paypalExpressPaymentMethod.IsActive)
                {
                    hasButtonMethods = true;
                }

                PaymentMethodCollection boundPaymentMethods = new PaymentMethodCollection();
                foreach (PaymentMethod pm in paymentMethods)
                {
                    if (pm != paypalExpressPaymentMethod && pm != googleCheckoutPaymentMethod)
                    {
                        boundPaymentMethods.Add(pm);
                    }
                }

                if (boundPaymentMethods.Count == 0)
                {
                    if (hasButtonMethods)
                    {
                        phSelectPaymentMethod.Visible = false;
                        phNoPaymentMethods.Visible    = false;
                    }
                    else
                    {
                        phSelectPaymentMethod.Visible = false;
                        phNoPaymentMethods.Visible    = true;
                    }
                }
                else if (boundPaymentMethods.Count == 1)
                {
                    if (hasButtonMethods)
                    {
                        phSelectPaymentMethod.Visible = true;
                        phNoPaymentMethods.Visible    = false;
                        dlPaymentMethod.DataSource    = boundPaymentMethods;
                        dlPaymentMethod.DataBind();
                    }
                    else
                    {
                        phSelectPaymentMethod.Visible = false;
                        phNoPaymentMethods.Visible    = false;
                        NopContext.Current.User       = CustomerManager.SetLastPaymentMethodID(NopContext.Current.User.CustomerID, paymentMethods[0].PaymentMethodID);
                        Response.Redirect("~/CheckoutConfirm.aspx");
                    }
                }
                else
                {
                    phSelectPaymentMethod.Visible = true;
                    phNoPaymentMethods.Visible    = false;
                    dlPaymentMethod.DataSource    = boundPaymentMethods;
                    dlPaymentMethod.DataBind();
                }
            }

            divAdditionalPaymentInfo.Visible = Request["OrderId"] != null;
        }