Example #1
0
        protected void WishlistGrid_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.CommandArgument.ToString()))
            {
                int      rowIndex       = AlwaysConvert.ToInt(e.CommandArgument);
                int      wishlistItemId = (int)WishlistGrid.DataKeys[rowIndex].Value;
                Wishlist wishlist       = AbleContext.Current.User.PrimaryWishlist;
                int      index          = wishlist.WishlistItems.IndexOf(wishlistItemId);
                switch (e.CommandName)
                {
                case "Basket":
                    if (index > -1)
                    {
                        wishlist.WishlistItems.MoveToBasket(index, AbleContext.Current.User.Basket);
                        Response.Redirect(NavigationHelper.GetBasketUrl());
                    }
                    WishlistGrid.DataBind();
                    break;

                case "DeleteItem":
                    if (index > -1)
                    {
                        wishlist.WishlistItems.DeleteAt(index);
                    }
                    WishlistGrid.DataBind();
                    break;
                }
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // verify the provider is configured
            _AmazonProvider = GetAmazonProvider();
            if (_AmazonProvider == null)
            {
                Response.Redirect(NavigationHelper.GetBasketUrl());
            }

            // package the basket on first visit
            Basket basket = AbleContext.Current.User.Basket;

            if (!Page.IsPostBack)
            {
                IBasketService basketService = AbleContext.Resolve <IBasketService>();
                basketService.Package(basket, true);
                basketService.Combine(basket);
                foreach (var shipment in basket.Shipments)
                {
                    shipment.ShipMethod = null;
                }
                basket.Save();
                basketService.Recalculate(basket);
            }

            // bind the amazon widgets
            MethodInfo buttonMethod = _AmazonProvider.GetType().GetMethod("GetAddressWidget");
            string     eventHandler = "document.getElementById('" + RecalculateShippingButton.ClientID + "').click();";

            object[]    parameters    = new object[] { basket, eventHandler, false };
            PlaceHolder addressWidget = (PlaceHolder)buttonMethod.Invoke(_AmazonProvider, parameters);

            this.ShippingAddress.Controls.Add(addressWidget);
            BindBasketGrid();
        }
Example #3
0
        protected void BillingAddress_AddressCancel(object sender, EventArgs e)
        {
            Address billingAddress = AbleContext.Current.User.PrimaryAddress;

            if (billingAddress == null || !billingAddress.IsValid)
            {
                Response.Redirect(NavigationHelper.GetBasketUrl());
            }
            else
            {
                BillingAddressTextPanel.Visible = true;
                FormattedBillingAddress.Text    = GetFormattedAddressString(billingAddress);
                BillingAddress.Visible          = false;
            }
        }
Example #4
0
        protected void Page_Init(object sender, EventArgs e)
        {
            AbleCommerce.Code.PageHelper.DisableValidationScrolling(this.Page);
            User user = AbleContext.Current.User;

            _Basket = AbleContext.Current.User.Basket;
            if (_Basket.Items.Count == 0)
            {
                Response.Redirect(NavigationHelper.GetBasketUrl());
            }

            //MAKE SURE THERE ARE ITEMS IN THE BASKET
            bool hasItems = false;

            foreach (BasketItem item in user.Basket.Items)
            {
                if (item.OrderItemType == OrderItemType.Product)
                {
                    hasItems = true;
                    break;
                }
            }
            if (!hasItems)
            {
                //THERE ARE NO PRODUCTS, SEND THEN TO SEE EMPTY BASKET
                Response.Redirect(AbleCommerce.Code.NavigationHelper.GetBasketUrl());
            }

            //VERIFY A VALID BILLING ADDRESS IS AVAILABLE
            if (!user.PrimaryAddress.IsValid)
            {
                Response.Redirect("EditBillAddress.aspx");
            }

            // VERIFY ANY SHIPPABLE ITEMS ARE IN PROPERLY CONFIGURED SHIPMENTS
            int unpackagedItems = _Basket.Items.Count(i => i.Shippable != CommerceBuilder.Shipping.Shippable.No && i.Shipment == null);

            if (unpackagedItems > 0)
            {
                Response.Redirect("ShipAddress.aspx");
            }
            int missingShippingAddress = _Basket.Shipments.Count(s => !s.Address.IsValid);

            if (missingShippingAddress > 0)
            {
                Response.Redirect("ShipAddress.aspx");
            }
            int missingShippingMethod = _Basket.Shipments.Count(s => s.ShipMethod == null);

            if (missingShippingMethod > 0)
            {
                Response.Redirect("ShipMethod.aspx");
            }

            if (!Page.IsPostBack)
            {
                IBasketService preCheckoutService = AbleContext.Resolve <IBasketService>();
                preCheckoutService.Recalculate(user.Basket);
                decimal orderTotal            = GetBasketTotal();
                StoreSettingsManager settings = AbleContext.Current.Store.Settings;
                decimal minOrderAmount        = settings.OrderMinimumAmount;
                decimal maxOrderAmount        = settings.OrderMaximumAmount;

                // IF THE ORDER AMOUNT DOES NOT FALL IN VALID RANGE SPECIFIED BY THE MERCHENT
                if ((minOrderAmount > orderTotal) || (maxOrderAmount > 0 && maxOrderAmount < orderTotal))
                {
                    // REDIRECT TO BASKET PAGE
                    Response.Redirect("~/Basket.aspx");
                }
                else if (!string.IsNullOrEmpty(settings.CheckoutTermsAndConditions))
                {
                    //SHOW TERMS AND CONDITIONS IF PRESENT
                    TermsAndConditionsSection.Visible = true;
                }
            }

            // SEE IF VALID SHIPPING ADDRESSES AND SHIP METHODS ARE SELECTED
            if (this.HasShippableProducts)
            {
                foreach (BasketShipment shipment in user.Basket.Shipments)
                {
                    if (!shipment.Address.IsValid)
                    {
                        Response.Redirect("ShipAddress.aspx");
                    }
                    if (shipment.ShipMethod == null)
                    {
                        Response.Redirect("ShipMethod.aspx");
                    }
                }
            }

            //SEE WHETHER WE HAVE MULTIPLE SHIPMENTS
            if (HasMultipleDestinations())
            {
                _EditShipToLink = "~/Checkout/ShipAddresses.aspx";
            }
            else
            {
                _EditShipToLink = NavigationHelper.GetMobileStoreUrl("~/Checkout/ShipAddress.aspx");
            }

            // INITIALIZE THE PAYMENT CONTROL
            Basket basket = AbleContext.Current.User.Basket;

            PaymentWidget.Basket = basket;
        }