Exemple #1
0
 protected void CartSummary_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "ShowGiftOptions")
     {
         int        itemId     = AlwaysConvert.ToInt(e.CommandArgument);
         BasketItem basketItem = BasketItemDataSource.Load(itemId);
         ShowGiftOptionsDialog(basketItem);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            BasketItem item      = BasketItemDataSource.Load(BasketItemId);
            WrapGroup  wrapGroup = item.Product.WrapGroup;

            if (wrapGroup != null)
            {
                _wrapStyles = wrapGroup.WrapStyles;
            }

            BuildWrapStyleList();

            if (!Page.IsPostBack)
            {
                // load initial values from calling parent control
                this.InnerGiftMessage.Text = _GiftMessage;
            }
        }
        private void InitializeGiftWrapChoices()
        {
            BasketItem item      = BasketItemDataSource.Load(_BasketItemId);
            WrapGroup  wrapGroup = item.Product.WrapGroup;

            if (wrapGroup != null)
            {
                _wrapStyles = wrapGroup.WrapStyles;
            }

            BuildWrapStyleList();

            if (string.IsNullOrEmpty(InnerGiftMessage.Text))
            {
                // load initial values from calling parent control
                this.InnerGiftMessage.Text = _GiftMessage;
            }
        }
Exemple #4
0
        protected void ContinueButton_Click(object sender, EventArgs e)
        {
            BasketItem basketItem = BasketItemDataSource.Load(AlwaysConvert.ToInt(GiftOptionsBasketItemId.Value));
            // LOOP EACH ITEM ROW TO DETERMINE GIFT OPTIONS
            List <BasketItemGiftOption> giftOptions = new List <BasketItemGiftOption>();

            foreach (GridViewRow row in GiftItemsGrid.Rows)
            {
                GiftWrapChoices wrapOptions = (GiftWrapChoices)row.FindControl("GiftWrapChoices");
                wrapOptions.BasketItemId = basketItem.Id;
                int    wrapStyleId = wrapOptions.WrapStyleId;
                string giftMessage = wrapOptions.GiftMessage;
                BasketItemGiftOption optionItem = new BasketItemGiftOption(basketItem, wrapStyleId, giftMessage);
                int existingIndex = giftOptions.IndexOf(optionItem);
                if (existingIndex > -1)
                {
                    giftOptions[existingIndex].Quantity++;
                }
                else
                {
                    giftOptions.Add(optionItem);
                }
            }

            // LOOP THROUGH GIFT OPTIONS AND UPDATE BASKET ITEMS
            Basket basket = AbleContext.Current.User.Basket;

            for (int i = 0; i < giftOptions.Count; i++)
            {
                BasketItemGiftOption giftOptionItem = giftOptions[i];
                if (i == 0)
                {
                    // FOR FIRST GIFT OPTION, UPDATE THE ORIGINAL BASKET ITEM
                    basketItem.Quantity    = giftOptionItem.Quantity;
                    basketItem.WrapStyleId = giftOptionItem.WrapStyleId;
                    basketItem.GiftMessage = giftOptionItem.GiftMessage;
                }
                else
                {
                    // FOR ADDTIONAL GIFT OPTIONS, CREATE COPIES OF THE ORIGINAL BASKET ITEM
                    BasketItem newItem = basketItem.Copy();
                    newItem.Quantity    = giftOptionItem.Quantity;
                    newItem.GiftMessage = giftOptionItem.GiftMessage;
                    newItem.WrapStyleId = giftOptionItem.WrapStyleId;
                    basket.Items.Add(newItem);
                }
            }

            // SAVE, COMBINE
            basket.Save();
            IBasketService basketService = AbleContext.Resolve <IBasketService>();

            basketService.Combine(basket);

            CartSummary.DataSource = GetBasketItems();
            CartSummary.DataBind();

            // NOW HIDE THE POPUP
            phGiftOptions.Visible = false;
            GiftOptionsPopup.Hide();
        }
Exemple #5
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            BasketItem basketItem = BasketItemDataSource.Load(this.BasketItemId);

            if (basketItem != null)
            {
                Product product = basketItem.Product;
                if (product != null)
                {
                    //OUTPUT THE PRODUCT NAME
                    string productName = basketItem.Name;
                    if (basketItem.ProductVariant != null)
                    {
                        string variantName = string.Format(" ({0})", basketItem.ProductVariant.VariantName);
                        if (!productName.EndsWith(variantName))
                        {
                            productName += variantName;
                        }
                    }
                    if (this.LinkProducts && product.Visibility != CatalogVisibility.Private)
                    {
                        //OUTPUT NAME AS LINK
                        string url = UrlGenerator.GetBrowseUrl(product.Id, CatalogNodeType.Product, product.Name);
                        if (!string.IsNullOrEmpty(basketItem.KitList) && !string.IsNullOrEmpty(basketItem.OptionList))
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}&Kits={2}&Options={3}\">{4}</a>", Page.ResolveUrl(url), basketItem.Id, basketItem.KitList, basketItem.OptionList.Replace(",0", string.Empty), productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                        else if (!string.IsNullOrEmpty(basketItem.KitList) && string.IsNullOrEmpty(basketItem.OptionList))
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}&Kits={2}\">{3}</a>", Page.ResolveUrl(url), basketItem.Id, basketItem.KitList, productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                        else if (string.IsNullOrEmpty(basketItem.KitList) && !string.IsNullOrEmpty(basketItem.OptionList))
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}&Options={2}\">{3}</a>", Page.ResolveUrl(url), basketItem.Id, basketItem.OptionList.Replace(",0", string.Empty), productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                        else
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}\">{2}</a>", Page.ResolveUrl(url), basketItem.Id, productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                    }
                    else
                    {
                        //OUTPUT NAME
                        phProductName.Controls.Add(new LiteralControl(productName));
                    }

                    if (EnableFriendlyFormat)
                    {
                        phProductName.Controls.AddAt(0, new LiteralControl(string.Format("{0} of ", basketItem.Quantity)));
                        phProductName.Controls.Add(new LiteralControl(string.Format("<span class='price'>({0})</span>", basketItem.Price.LSCurrencyFormat("ulc"))));
                    }

                    //SHOW INPUTS
                    IList <BasketItemInput> inputs = GetCustomerInputs(basketItem);
                    if (inputs.Count > 0)
                    {
                        InputList.DataSource = inputs;
                        InputList.DataBind();
                    }
                    else
                    {
                        InputList.Visible = false;
                    }
                    //SHOW KIT PRODUCTS IF AVAILABLE, AND THE PRODUCT DOES NOT USE ITEMIZED DISPLAY OR FORCE KIT DISPLAY IS ON
                    if (!string.IsNullOrEmpty(basketItem.KitList) && basketItem.Product != null &&
                        basketItem.Product.Kit != null && (!basketItem.Product.Kit.ItemizeDisplay || this.ForceKitDisplay))
                    {
                        IList <BasketItem> kitProductList = GetKitProducts(basketItem, this.IgnoreKitShipment);
                        if (kitProductList.Count > 0)
                        {
                            KitProductPanel.Visible       = true;
                            KitProductRepeater.DataSource = kitProductList;
                            KitProductRepeater.DataBind();
                        }
                    }
                    //SET THE KIT MEMBER LABEL
                    if (basketItem.OrderItemType == OrderItemType.Product && basketItem.IsChildItem)
                    {
                        BasketItem parentItem = basketItem.GetParentItem(true);
                        if (parentItem != null)
                        {
                            if ((parentItem.Product != null && basketItem.Product.Kit != null && parentItem.Product.Kit.ItemizeDisplay) ||
                                basketItem.ShipmentId != parentItem.ShipmentId)
                            {
                                //SET THE WISHLIST NAME
                                KitMemberLabel.Visible = true;
                                KitMemberLabel.Text    = string.Format(KitMemberLabel.Text, parentItem.Name);
                            }
                        }
                    }
                    //SET THE WISHLIST LABEL
                    WishlistLabel.Visible = (basketItem.WishlistItem != null);
                    if (WishlistLabel.Visible)
                    {
                        //SET THE WISHLIST NAME
                        WishlistLabel.Text = string.Format(WishlistLabel.Text, GetWishlistName(basketItem.WishlistItem.Wishlist));
                    }
                    //SET THE SHIPS TO PANEL
                    Basket         basket   = basketItem.Basket;
                    BasketShipment shipment = basketItem.Shipment;
                    Address        address  = (shipment == null) ? null : shipment.Address;
                    ShipsToPanel.Visible = (this.ShowShipTo && (address != null) && (!string.IsNullOrEmpty(address.FullName)));
                    if (ShipsToPanel.Visible)
                    {
                        ShipsTo.Text = address.FullName;
                    }
                    //SHOW GIFT WRAP
                    GiftWrapPanel.Visible = (basketItem.WrapStyle != null);
                    if (GiftWrapPanel.Visible)
                    {
                        GiftWrap.Text         = basketItem.WrapStyle.Name;
                        GiftWrapPrice.Visible = (basketItem.WrapStyle.Price != 0);
                        GiftWrapPrice.Text    = string.Format("&nbsp;({0})", basketItem.WrapStyle.Price.LSCurrencyFormat("ulc"));
                    }
                    //SHOW GIFT MESSAGE
                    GiftMessagePanel.Visible = (!string.IsNullOrEmpty(basketItem.GiftMessage));
                    if (GiftMessagePanel.Visible)
                    {
                        GiftMessage.Text = basketItem.GiftMessage;
                    }
                    //SHOW ASSETS
                    List <AbleCommerce.Code.ProductAssetWrapper> assets = AbleCommerce.Code.ProductHelper.GetAssets(this.Page, basketItem.Product, basketItem.OptionList, basketItem.KitList, "javascript:window.close()");
                    AssetsPanel.Visible = (this.ShowAssets && assets.Count > 0);
                    if (AssetsPanel.Visible)
                    {
                        AssetLinkList.DataSource = assets;
                        AssetLinkList.DataBind();
                    }
                    //SHOW SUBSCRIPTIONS
                    if (this.ShowSubscription)
                    {
                        SubscriptionPlan sp = basketItem.Product.SubscriptionPlan;
                        if (sp != null && basketItem.IsSubscription && basketItem.Frequency > 0)
                        {
                            // GET THE RECURRING PAYMENT MESSAGE FOR THIS PRODUCT
                            RecurringPaymentMessage.Text = AbleCommerce.Code.ProductHelper.GetRecurringPaymentMessage(basketItem);
                            SubscriptionPanel.Visible    = true;
                        }
                    }
                }
                else
                {
                    //OUTPUT NAME
                    phProductName.Controls.Add(new LiteralControl(basketItem.Name));
                    InputList.Visible         = false;
                    KitProductPanel.Visible   = false;
                    WishlistLabel.Visible     = false;
                    ShipsToPanel.Visible      = false;
                    GiftWrapPanel.Visible     = false;
                    GiftMessagePanel.Visible  = false;
                    AssetsPanel.Visible       = false;
                    SubscriptionPanel.Visible = false;
                }
            }
            else
            {
                //NO ITEM TO DISPLAY
                this.Controls.Clear();
            }
        }
Exemple #6
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            _BasketItem = BasketItemDataSource.Load(BasketItemId);
            if (_BasketItem != null)
            {
                Product product = _BasketItem.Product;
                if (product != null)
                {
                    //OUTPUT THE PRODUCT NAME
                    string productName = product.Name;
                    if (_BasketItem.ProductVariant != null)
                    {
                        productName += string.Format(" ({0})", _BasketItem.ProductVariant.VariantName);
                    }
                    if (this.LinkProducts)
                    {
                        //OUTPUT NAME AS LINK
                        string url = UrlGenerator.GetBrowseUrl(product.Id, CatalogNodeType.Product, product.Name);
                        if (!string.IsNullOrEmpty(_BasketItem.KitList) && !string.IsNullOrEmpty(_BasketItem.OptionList))
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}&Kits={2}&Options={3} \">{4}</a>", Page.ResolveUrl(url), _BasketItem.Id, _BasketItem.KitList, _BasketItem.OptionList.Replace(",0", string.Empty), productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                        else if (!string.IsNullOrEmpty(_BasketItem.KitList) && string.IsNullOrEmpty(_BasketItem.OptionList))
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}&Kits={2}\">{3}</a>", Page.ResolveUrl(url), _BasketItem.Id, _BasketItem.KitList, productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                        else if (string.IsNullOrEmpty(_BasketItem.KitList) && !string.IsNullOrEmpty(_BasketItem.OptionList))
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}&Options={2}\">{3}</a>", Page.ResolveUrl(url), _BasketItem.Id, _BasketItem.OptionList.Replace(",0", string.Empty), productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                        else
                        {
                            string link = string.Format("<a href=\"{0}?ItemId={1}\">{2}</a>", Page.ResolveUrl(url), _BasketItem.Id, productName);
                            phProductName.Controls.Add(new LiteralControl(link));
                        }
                    }
                    else
                    {
                        //OUTPUT NAME
                        phProductName.Controls.Add(new LiteralControl(productName));
                    }
                    //SHOW INPUTS
                    IList <BasketItemInput> inputs = GetCustomerInputs();
                    if (inputs.Count > 0)
                    {
                        InputList.DataSource = inputs;
                        InputList.DataBind();
                    }
                    else
                    {
                        InputList.Visible = false;
                    }
                    //SHOW KIT PRODUCTS
                    IList <BasketItem> kitProductList = GetKitProducts(_BasketItem);
                    KitProductPanel.Visible = (kitProductList.Count > 0 && _BasketItem.Product.Kit != null && !_BasketItem.Product.Kit.ItemizeDisplay);
                    if (KitProductPanel.Visible)
                    {
                        KitProductRepeater.DataSource = kitProductList;
                        KitProductRepeater.DataBind();
                    }
                    //SET THE WISHLIST LABEL
                    WishlistLabel.Visible = (_BasketItem.WishlistItem != null);
                    if (WishlistLabel.Visible)
                    {
                        //SET THE WISHLIST NAME
                        WishlistLabel.Text = string.Format(WishlistLabel.Text, GetWishlistName(_BasketItem.WishlistItem.Wishlist));
                    }
                    //SET THE SHIPS TO PANEL
                    Basket basket = _BasketItem.Basket;

                    //SHOW ASSETS
                    List <AbleCommerce.Code.ProductAssetWrapper> assets = AbleCommerce.Code.ProductHelper.GetAssets(this.Page, _BasketItem.Product, _BasketItem.OptionList, _BasketItem.KitList, "javascript:window.close()");
                    AssetsPanel.Visible = (this.ShowAssets && assets.Count > 0);
                    if (AssetsPanel.Visible)
                    {
                        AssetLinkList.DataSource = assets;
                        AssetLinkList.DataBind();
                    }
                    //SHOW SUBSCRIPTIONS
                    SubscriptionPlan sp = _BasketItem.Product.SubscriptionPlan;
                    SubscriptionPanel.Visible = (this.ShowSubscription && _BasketItem.IsSubscription);
                    if (SubscriptionPanel.Visible)
                    {
                        InitialPayment.Visible = (sp.RecurringChargeSpecified);
                        if (InitialPayment.Visible)
                        {
                            InitialPayment.Text = string.Format(InitialPayment.Text, _BasketItem.Price.LSCurrencyFormat("ulc"));
                        }
                        string period;
                        if (_BasketItem.Frequency > 1)
                        {
                            period = _BasketItem.Frequency + " " + _BasketItem.FrequencyUnit.ToString().ToLowerInvariant() + "s";
                        }
                        else
                        {
                            period = _BasketItem.FrequencyUnit.ToString().ToLowerInvariant();
                        }
                        int numPayments = (sp.RecurringChargeSpecified ? sp.NumberOfPayments - 1 : sp.NumberOfPayments);
                        if (sp.NumberOfPayments == 0)
                        {
                            RecurringPayment.Text = string.Format("Recurring Payment: {0}, every {1} until canceled", sp.CalculateRecurringCharge(_BasketItem.Price).LSCurrencyFormat("ulc"), period);
                        }
                        else
                        {
                            RecurringPayment.Text = string.Format(RecurringPayment.Text, numPayments, sp.CalculateRecurringCharge(_BasketItem.Price).LSCurrencyFormat("ulc"), period);
                        }
                    }
                }
                else
                {
                    //OUTPUT NAME
                    phProductName.Controls.Add(new LiteralControl(_BasketItem.Name));
                    InputList.Visible         = false;
                    KitProductPanel.Visible   = false;
                    WishlistLabel.Visible     = false;
                    AssetsPanel.Visible       = false;
                    SubscriptionPanel.Visible = false;
                }
            }
            else
            {
                //NO ITEM TO DISPLAY
                this.Controls.Clear();
            }
        }