コード例 #1
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            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 link = string.Format("<a target=\"_blank\" href=\"{0}\">{1}</a>", Page.ResolveUrl("~/Admin/Products/EditProduct.aspx?ProductId=" + product.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);
                    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 && sp != null && sp.IsRecurring);
                    if (SubscriptionPanel.Visible)
                    {
                        InitialPayment.Visible = (sp.RecurringChargeSpecified);
                        if (InitialPayment.Visible)
                        {
                            InitialPayment.Text = string.Format(InitialPayment.Text, _BasketItem.Price.LSCurrencyFormat("lc"));
                        }
                        string period;
                        if (sp.PaymentFrequency > 1)
                        {
                            period = sp.PaymentFrequency + " " + sp.PaymentFrequencyUnit.ToString().ToLowerInvariant() + "s";
                        }
                        else
                        {
                            period = sp.PaymentFrequencyUnit.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("lc"), period);
                        }
                        else
                        {
                            RecurringPayment.Text = string.Format(RecurringPayment.Text, numPayments, sp.CalculateRecurringCharge(_BasketItem.Price).LSCurrencyFormat("lc"), 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();
            }
        }
コード例 #2
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();
            }
        }