示例#1
0
        protected void ddlVariantPrice_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var productVariant  = e.Item.DataItem as ProductVariant;
                var lblPriceDisplay = e.Item.FindControl("lblPriceDisplay") as Label;
                var lblPrice        = e.Item.FindControl("lblPrice") as Label;
                var imgBuyNow       = e.Item.FindControl("imgBuyNow") as ImageButton;

                if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                    (NopContext.Current.User != null &&
                     !NopContext.Current.User.IsGuest))
                {
                    if (productVariant.CustomerEntersPrice)
                    {
                        int minimumCustomerEnteredPrice = Convert.ToInt32(Math.Ceiling(CurrencyManager.ConvertCurrency(productVariant.MinimumCustomerEnteredPrice, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency)));
                        lblPrice.Text        = minimumCustomerEnteredPrice.ToString();
                        lblPriceDisplay.Text = PriceHelper.FormatPrice(minimumCustomerEnteredPrice);
                    }
                    else
                    {
                        decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                        decimal fromPrice     = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                        lblPrice.Text        = fromPrice.ToString();
                        lblPriceDisplay.Text = PriceHelper.FormatPrice(fromPrice);
                    }
                }
                else
                {
                    lblPriceDisplay.Visible = false;
                    btnAddToCart.Visible    = false;
                }
            }
        }
示例#2
0
        private void BindData()
        {
            var productVariant = ProductManager.GetProductVariantById(this.ProductVariantId);

            if (productVariant != null)
            {
                if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                    (NopContext.Current.User != null &&
                     !NopContext.Current.User.IsGuest))
                {
                    if (productVariant.CustomerEntersPrice)
                    {
                        phOldPrice.Visible    = false;
                        lblPrice.Visible      = false;
                        lblPriceValue.Visible = false;
                        phDiscount.Visible    = false;

                        lblCustomerEnterPrice.Visible = true;
                        lblCustomerEnterPrice.Text    = GetLocaleResourceString("Products.EnterProductPrice");
                    }
                    else
                    {
                        if (productVariant.CallForPrice)
                        {
                            lblPriceValue.Text = GetLocaleResourceString("Products.CallForPrice");
                            phOldPrice.Visible = false;
                            phDiscount.Visible = false;
                        }
                        else
                        {
                            decimal taxRate      = decimal.Zero;
                            decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice, out taxRate);
                            decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false), out taxRate);
                            decimal finalPriceWithDiscountBase    = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, true), out taxRate);

                            decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                            decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                            decimal finalPriceWithDiscount    = CurrencyManager.ConvertCurrency(finalPriceWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                            if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase > decimal.Zero)
                            {
                                lblOldPrice.Text   = PriceHelper.FormatPrice(oldPrice);
                                lblPriceValue.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                                phOldPrice.Visible = true;
                            }
                            else
                            {
                                lblPriceValue.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                                phOldPrice.Visible = false;
                            }

                            if (finalPriceWithoutDiscountBase != finalPriceWithDiscountBase)
                            {
                                lblFinalPriceWithDiscount.Text = PriceHelper.FormatPrice(finalPriceWithDiscount);
                                phDiscount.Visible             = true;
                            }
                            else
                            {
                                phDiscount.Visible = false;
                            }

                            if (phDiscount.Visible)
                            {
                                lblPriceValue.CssClass = string.Empty;
                            }
                            else
                            {
                                lblPriceValue.CssClass = "productPrice";
                            }

                            if (phDiscount.Visible || phOldPrice.Visible)
                            {
                                lblPrice.Text = GetLocaleResourceString("Products.FinalPriceWithoutDiscount");
                            }
                            if (SettingManager.GetSettingValueBoolean("ProductAttribute.EnableDynamicPriceUpdate"))
                            {
                                string pattern     = SettingManager.GetSettingValue("ProductAttribute.PricePattern", "(?<val>(\\d+[\\s\\,\\.]?)+)");
                                string replacement = String.Format("<span class=\"price-val-for-dyn-upd-{0}\">${{val}}</span> ", productVariant.ProductVariantId);

                                if (finalPriceWithoutDiscountBase != finalPriceWithDiscountBase)
                                {
                                    lblFinalPriceWithDiscount.Text = Regex.Replace(lblFinalPriceWithDiscount.Text, pattern, replacement);
                                }
                                else
                                {
                                    lblPriceValue.Text = Regex.Replace(lblPriceValue.Text, pattern, replacement);
                                }
                            }
                        }
                    }
                }
                else
                {
                    this.Visible = false;
                }
            }
            else
            {
                this.Visible = false;
            }
        }
示例#3
0
        protected override void OnPreRender(EventArgs e)
        {
            if (SettingManager.GetSettingValueBoolean("ProductAttribute.EnableDynamicPriceUpdate"))
            {
                var productVariant = ProductManager.GetProductVariantById(this.ProductVariantId);
                if (productVariant != null && !productVariant.CallForPrice)
                {
                    decimal taxRate = decimal.Zero;
                    decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false), out taxRate);
                    decimal finalPriceWithoutDiscount     = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                    decimal finalPriceWithDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, true), out taxRate);
                    decimal finalPriceWithDiscount     = CurrencyManager.ConvertCurrency(finalPriceWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                    float  val    = (float)(finalPriceWithoutDiscountBase != finalPriceWithDiscountBase ? finalPriceWithDiscount : finalPriceWithoutDiscount);
                    string key    = String.Format("PriceValForDynUpd_{0}", productVariant.ProductVariantId);
                    string script = String.Format(CultureInfo.InvariantCulture, "var priceValForDynUpd_{0} = {1};", productVariant.ProductVariantId, val);

                    Page.ClientScript.RegisterClientScriptBlock(GetType(), key, script, true);
                }
            }
            base.OnPreRender(e);
        }
示例#4
0
        protected void dlRelatedProducts_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                RelatedProduct relatedProduct = e.Item.DataItem as RelatedProduct;
                Product        product        = relatedProduct.Product2;

                if (relatedProduct != null && product != null)
                {
                    string productURL = SEOHelper.GetProductURL(product);

                    Label lblPrice = e.Item.FindControl("lblPrice") as Label;

                    if (product.ProductVariants.Count > 0)
                    {
                        if (!product.HasMultipleVariants)
                        {
                            ProductVariant productVariant = product.ProductVariants[0];

                            decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice);
                            decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));

                            decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                            decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                            lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscountBase);
                        }
                        else
                        {
                            ProductVariant productVariant = product.MinimalPriceProductVariant;
                            if (productVariant != null)
                            {
                                decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                                decimal fromPrice     = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                                lblPrice.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                            }
                        }
                    }
                    Image hlImageLink = e.Item.FindControl("hlImageLink") as Image;
                    if (hlImageLink != null)
                    {
                        ProductPictureCollection productPictures = product.ProductPictures;
                        if (productPictures.Count > 0)
                        {
                            hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].Picture, SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 84), true);
                        }
                        else
                        {
                            hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 84));
                        }
                        //hlImageLink.NavigateUrl = productURL;
                        //hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                        //hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                    }

                    HyperLink hlProduct = e.Item.FindControl("hlProduct") as HyperLink;
                    if (hlProduct != null)
                    {
                        hlProduct.NavigateUrl = productURL;
                        //hlProduct.Text = product.Name;
                    }
                }
            }
        }
        private void BindData()
        {
            var product = this.ProductService.GetProductById(this.ProductId);

            if (product != null)
            {
                var productVariantCollection = product.ProductVariants;
                if (productVariantCollection.Count > 0)
                {
                    if (!product.HasMultipleVariants)
                    {
                        var productVariant = productVariantCollection[0];
                        if (!this.SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                            (NopContext.Current.User != null &&
                             !NopContext.Current.User.IsGuest))
                        {
                            if (productVariant.CustomerEntersPrice)
                            {
                                lblOldPrice.Visible = false;
                                lblPrice.Visible    = false;
                            }
                            else
                            {
                                if (productVariant.CallForPrice)
                                {
                                    lblOldPrice.Visible = false;
                                    lblPrice.Text       = GetLocaleResourceString("Products.CallForPrice");
                                }
                                else
                                {
                                    decimal taxRate        = decimal.Zero;
                                    decimal oldPriceBase   = this.TaxService.GetPrice(productVariant, productVariant.OldPrice, out taxRate);
                                    decimal finalPriceBase = this.TaxService.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, true), out taxRate);

                                    decimal oldPrice   = this.CurrencyService.ConvertCurrency(oldPriceBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                                    decimal finalPrice = this.CurrencyService.ConvertCurrency(finalPriceBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                                    if (finalPriceBase != oldPriceBase && oldPriceBase != decimal.Zero)
                                    {
                                        lblOldPrice.Text = PriceHelper.FormatPrice(oldPrice);
                                        lblPrice.Text    = PriceHelper.FormatPrice(finalPrice);
                                    }
                                    else
                                    {
                                        lblOldPrice.Visible = false;
                                        lblPrice.Text       = PriceHelper.FormatPrice(finalPrice);
                                    }
                                }
                            }
                        }
                        else
                        {
                            lblOldPrice.Visible = false;
                            lblPrice.Visible    = false;
                        }
                    }
                    else
                    {
                        var productVariant = product.MinimalPriceProductVariant;
                        if (productVariant != null)
                        {
                            if (!this.SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                                (NopContext.Current.User != null &&
                                 !NopContext.Current.User.IsGuest))
                            {
                                if (productVariant.CustomerEntersPrice)
                                {
                                    lblOldPrice.Visible = false;
                                    lblPrice.Visible    = false;
                                }
                                else
                                {
                                    if (productVariant.CallForPrice)
                                    {
                                        lblOldPrice.Visible = false;
                                        lblPrice.Text       = GetLocaleResourceString("Products.CallForPrice");
                                    }
                                    else
                                    {
                                        decimal taxRate       = decimal.Zero;
                                        decimal fromPriceBase = this.TaxService.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false), out taxRate);
                                        decimal fromPrice     = this.CurrencyService.ConvertCurrency(fromPriceBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                                        lblOldPrice.Visible = false;
                                        lblPrice.Text       = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                                    }
                                }
                            }
                            else
                            {
                                lblOldPrice.Visible = false;
                                lblPrice.Visible    = false;
                            }
                        }
                    }
                }
                else
                {
                    lblOldPrice.Visible = false;
                    lblPrice.Visible    = false;
                }
            }
        }
示例#6
0
        private void BindData()
        {
            if (product != null)
            {
                string productURL = SEOHelper.GetProductURL(product);

                hlProduct.Text = Server.HtmlEncode(product.Name);

                ProductPictureCollection productPictures = product.ProductPictures;
                if (productPictures.Count > 0)
                {
                    hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].Picture, ProductImageSize, true);
                    hlImageLink.ToolTip  = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                    hlImageLink.Text     = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                }
                else
                {
                    hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(this.ProductImageSize);
                    hlImageLink.ToolTip  = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                    hlImageLink.Text     = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                }
                hlImageLink.NavigateUrl = productURL;

                lShortDescription.Text = product.ShortDescription;

                ProductVariantCollection productVariantCollection = product.ProductVariants;

                if (productVariantCollection.Count > 0)
                {
                    if (!product.HasMultipleVariants)
                    {
                        ProductVariant productVariant = productVariantCollection[0];

                        decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));

                        lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscountBase);
                        if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD")
                        {
                            lblPrice.Text += "$";
                        }
                    }
                    else
                    {
                        ProductVariant productVariant = product.MinimalPriceProductVariant;
                        if (productVariant != null)
                        {
                            decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                            decimal fromPrice     = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                            lblPrice.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                        }
                    }
                }
                else
                {
                    lblPrice.Visible = false;
                }

                #region scjaarge's change
                if (!lblPrice.Visible || lblPrice.Text.Trim() == string.Empty)
                {
                    litOrderOrNa.Text = "Нет в наличии";
                }
                #endregion scjaarge's change
            }
        }
示例#7
0
        private void BindData()
        {
            ProductVariant productVariant = ProductManager.GetProductVariantByID(this.ProductVariantID);

            if (productVariant != null)
            {
                decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice);
                decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                decimal finalPriceWithDiscountBase    = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, true));

                decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                decimal finalPriceWithDiscount    = CurrencyManager.ConvertCurrency(finalPriceWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase > decimal.Zero)
                {
                    lblOldPrice.Text   = PriceHelper.FormatPrice(oldPrice);
                    lblPriceValue.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                    phOldPrice.Visible = true;
                }
                else
                {
                    lblPriceValue.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                    phOldPrice.Visible = false;
                }

                if (finalPriceWithoutDiscountBase != finalPriceWithDiscountBase)
                {
                    lblFinalPriceWithDiscount.Text = PriceHelper.FormatPrice(finalPriceWithDiscount);
                    phDiscount.Visible             = true;
                }
                else
                {
                    phDiscount.Visible = false;
                }

                if (phDiscount.Visible)
                {
                    lblPriceValue.CssClass = string.Empty;
                }
                else
                {
                    lblPriceValue.CssClass = "productPrice";
                }

                if (phDiscount.Visible || phOldPrice.Visible)
                {
                    lblPrice.Text = GetLocaleResourceString("Products.FinalPriceWithoutDiscount");
                }
            }
            else
            {
                this.Visible = false;
            }
        }
示例#8
0
        private void BindData()
        {
            if (product != null)
            {
                string productURL = SEOHelper.GetProductUrl(product);

                hlProduct.NavigateUrl = productURL;
                hlProduct.Text        = Server.HtmlEncode(product.Name);

                ProductPicture productPicture = product.DefaultProductPicture;
                if (productPicture != null)
                {
                    hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPicture.Picture, this.ProductImageSize, true);
                    hlImageLink.ToolTip  = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                    hlImageLink.Text     = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                }
                else
                {
                    hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(this.ProductImageSize);
                    hlImageLink.ToolTip  = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                    hlImageLink.Text     = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                }
                hlImageLink.NavigateUrl = productURL;

                lShortDescription.Text = product.ShortDescription;

                var productVariantCollection = product.ProductVariants;
                if (productVariantCollection.Count > 0)
                {
                    if (!product.HasMultipleVariants)
                    {
                        var productVariant = productVariantCollection[0];
                        btnAddToCart.Visible = (!productVariant.DisableBuyButton);

                        if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                            (NopContext.Current.User != null &&
                             !NopContext.Current.User.IsGuest))
                        {
                            if (productVariant.CustomerEntersPrice)
                            {
                                lblOldPrice.Visible = false;
                                lblPrice.Visible    = false;
                            }
                            else
                            {
                                decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice);
                                decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));

                                decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                                decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                                if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase != decimal.Zero)
                                {
                                    lblOldPrice.Text = PriceHelper.FormatPrice(oldPrice);
                                    lblPrice.Text    = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                                }
                                else
                                {
                                    lblOldPrice.Visible = false;
                                    lblPrice.Text       = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                                }
                            }
                        }
                        else
                        {
                            lblOldPrice.Visible  = false;
                            lblPrice.Visible     = false;
                            btnAddToCart.Visible = false;
                        }
                    }
                    else
                    {
                        var productVariant = product.MinimalPriceProductVariant;
                        if (productVariant != null)
                        {
                            if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                                (NopContext.Current.User != null &&
                                 !NopContext.Current.User.IsGuest))
                            {
                                if (productVariant.CustomerEntersPrice)
                                {
                                    lblOldPrice.Visible = false;
                                    lblPrice.Visible    = false;
                                }
                                else
                                {
                                    decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                                    decimal fromPrice     = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                                    lblOldPrice.Visible = false;
                                    lblPrice.Text       = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                                }
                            }
                            else
                            {
                                lblOldPrice.Visible  = false;
                                lblPrice.Visible     = false;
                                btnAddToCart.Visible = false;
                            }
                        }

                        btnAddToCart.Visible = false;
                    }
                }
                else
                {
                    lblOldPrice.Visible  = false;
                    lblPrice.Visible     = false;
                    btnAddToCart.Visible = false;
                }
            }
        }
示例#9
0
        public void CreateCompareTable()
        {
            this.tblCompareProducts.Rows.Clear();
            this.tblCompareProducts.Width = "100%";
            ProductCollection compareProducts = ProductManager.GetCompareProducts();

            if (compareProducts.Count > 0)
            {
                HtmlTableRow headerRow = new HtmlTableRow();
                this.AddCell(headerRow, "&nbsp;");
                HtmlTableRow productNameRow = new HtmlTableRow();
                this.AddCell(productNameRow, "&nbsp;");
                HtmlTableRow  priceRow = new HtmlTableRow();
                HtmlTableCell cell     = new HtmlTableCell();
                cell.InnerText = GetLocaleResourceString("Products.CompareProductsPrice");
                cell.Align     = "center";
                priceRow.Cells.Add(cell);

                List <int> allAttributeIDs = new List <int>();
                foreach (Product product in compareProducts)
                {
                    ProductSpecificationAttributeCollection productSpecificationAttributes = SpecificationAttributeManager.GetProductSpecificationAttributesByProductID(product.ProductID, null, true);
                    foreach (ProductSpecificationAttribute attribute in productSpecificationAttributes)
                    {
                        if (!allAttributeIDs.Contains(attribute.SpecificationAttributeOptionID))
                        {
                            allAttributeIDs.Add(attribute.SpecificationAttributeOptionID);
                        }
                    }
                }

                foreach (Product product in compareProducts)
                {
                    HtmlTableCell      headerCell        = new HtmlTableCell();
                    HtmlGenericControl headerCellDiv     = new HtmlGenericControl("div");
                    Button             btnRemoveFromList = new Button();
                    btnRemoveFromList.ToolTip          = GetLocaleResourceString("Products.CompareProductsRemoveFromList");
                    btnRemoveFromList.Text             = GetLocaleResourceString("Products.CompareProductsRemoveFromList");
                    btnRemoveFromList.CommandName      = "Remove";
                    btnRemoveFromList.Command         += new CommandEventHandler(this.btnRemoveFromList_Command);
                    btnRemoveFromList.CommandArgument  = product.ProductID.ToString();
                    btnRemoveFromList.CausesValidation = false;
                    btnRemoveFromList.CssClass         = "removeButton";
                    btnRemoveFromList.ID = "btnRemoveFromList" + product.ProductID.ToString();
                    headerCellDiv.Controls.Add(btnRemoveFromList);

                    HtmlGenericControl productImagePanel = new HtmlGenericControl("p");
                    productImagePanel.Attributes.Add("align", "center");

                    HtmlImage productImage = new HtmlImage();
                    productImage.Border = 0;
                    //productImage.Align = "center";
                    productImage.Alt = "Product image";
                    ProductPictureCollection productPictures = product.ProductPictures;
                    if (productPictures.Count > 0)
                    {
                        productImage.Src = PictureManager.GetPictureUrl(productPictures[0].Picture, SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125), true);
                    }
                    else
                    {
                        productImage.Src = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125));
                    }
                    productImagePanel.Controls.Add(productImage);

                    headerCellDiv.Controls.Add(productImagePanel);



                    headerCell.Controls.Add(headerCellDiv);
                    headerRow.Cells.Add(headerCell);
                    HtmlTableCell productNameCell = new HtmlTableCell();
                    HyperLink     productLink     = new HyperLink();
                    productLink.Text        = Server.HtmlEncode(product.Name);
                    productLink.NavigateUrl = SEOHelper.GetProductURL(product);
                    productLink.Attributes.Add("class", "link");
                    productNameCell.Align = "center";
                    productNameCell.Controls.Add(productLink);
                    productNameRow.Cells.Add(productNameCell);
                    HtmlTableCell priceCell = new HtmlTableCell();
                    priceCell.Align = "center";
                    ProductVariantCollection productVariantCollection = product.ProductVariants;
                    if (productVariantCollection.Count > 0)
                    {
                        ProductVariant productVariant = productVariantCollection[0];

                        //decimal oldPrice = productVariant.OldPrice;
                        //decimal oldPriceConverted = CurrencyManager.ConvertCurrency(oldPrice, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                        decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                        decimal finalPriceWithoutDiscount     = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                        priceCell.InnerText = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                    }
                    priceRow.Cells.Add(priceCell);
                }
                productNameRow.Attributes.Add("class", "productName");
                priceRow.Attributes.Add("class", "productPrice");
                this.tblCompareProducts.Rows.Add(headerRow);
                this.tblCompareProducts.Rows.Add(productNameRow);
                this.tblCompareProducts.Rows.Add(priceRow);

                if (allAttributeIDs.Count > 0)
                {
                    foreach (int specificationAttributeID in allAttributeIDs)
                    {
                        //SpecificationAttribute attribute = SpecificationAttributeManager.GetSpecificationAttributeByID(specificationAttributeID);
                        SpecificationAttributeOption attributeOption = SpecificationAttributeManager.GetSpecificationAttributeOptionByID(specificationAttributeID);
                        HtmlTableRow productRow = new HtmlTableRow();
                        this.AddCell(productRow, Server.HtmlEncode(attributeOption.SpecificationAttribute.Name)).Align = "left";

                        foreach (Product product2 in compareProducts)
                        {
                            HtmlTableCell productCell = new HtmlTableCell();
                            {
                                ProductSpecificationAttributeCollection productSpecificationAttributes2 = SpecificationAttributeManager.GetProductSpecificationAttributesByProductID(product2.ProductID, null, true);
                                foreach (ProductSpecificationAttribute attribute2 in productSpecificationAttributes2)
                                {
                                    if (attributeOption.SpecificationAttributeOptionID == attribute2.SpecificationAttributeOptionID)
                                    {
                                        productCell.InnerHtml = (!String.IsNullOrEmpty(attribute2.SpecificationAttributeOption.Name)) ? Server.HtmlEncode(attribute2.SpecificationAttributeOption.Name) : "&nbsp;";
                                    }
                                }
                            }
                            productCell.Align  = "center";
                            productCell.VAlign = "top";
                            productRow.Cells.Add(productCell);
                        }
                        this.tblCompareProducts.Rows.Add(productRow);
                    }
                }
                string width = Math.Round((decimal)(90M / compareProducts.Count), 0).ToString() + "%";
                for (int i = 0; i < this.tblCompareProducts.Rows.Count; i++)
                {
                    HtmlTableRow row = this.tblCompareProducts.Rows[i];
                    for (int j = 1; j < row.Cells.Count; j++)
                    {
                        if (j == (row.Cells.Count - 1))
                        {
                            row.Cells[j].Style.Add("width", width);
                            row.Cells[j].Style.Add("text-align", "center");
                        }
                        else
                        {
                            row.Cells[j].Style.Add("width", width);
                            row.Cells[j].Style.Add("text-align", "center");
                        }
                    }
                }
            }
            else
            {
                btnClearCompareProductsList.Visible = false;
                tblCompareProducts.Visible          = false;
            }
        }
示例#10
0
        protected void GenerateCompareTable()
        {
            this.tblCompareProducts.Rows.Clear();
            this.tblCompareProducts.Width = "100%";
            var compareProducts = this.ProductService.GetCompareProducts();

            if (compareProducts.Count > 0)
            {
                var headerRow = new HtmlTableRow();
                this.AddCell(headerRow, "&nbsp;");
                var productNameRow = new HtmlTableRow();
                this.AddCell(productNameRow, "&nbsp;");
                var priceRow = new HtmlTableRow();
                var cell     = new HtmlTableCell();
                cell.InnerText = GetLocaleResourceString("Products.CompareProductsPrice");
                cell.Align     = "left";
                priceRow.Cells.Add(cell);

                var specificationAttributeIds = new List <int>();
                foreach (var product in compareProducts)
                {
                    var productSpecificationAttributes = this.SpecificationAttributeService.GetProductSpecificationAttributesByProductId(product.ProductId, null, true);
                    foreach (var attribute in productSpecificationAttributes)
                    {
                        if (!specificationAttributeIds.Contains(attribute.SpecificationAttribute.SpecificationAttributeId))
                        {
                            specificationAttributeIds.Add(attribute.SpecificationAttribute.SpecificationAttributeId);
                        }
                    }
                }

                foreach (var product in compareProducts)
                {
                    var headerCell    = new HtmlTableCell();
                    var headerCellDiv = new HtmlGenericControl("div");

                    var productImagePanel = new HtmlGenericControl("p");
                    productImagePanel.Attributes.Add("align", "center");

                    var btnRemoveFromList = new Button();
                    btnRemoveFromList.ToolTip          = GetLocaleResourceString("Products.CompareProductsRemoveFromList");
                    btnRemoveFromList.Text             = GetLocaleResourceString("Products.CompareProductsRemoveFromList");
                    btnRemoveFromList.CommandName      = "Remove";
                    btnRemoveFromList.Command         += new CommandEventHandler(this.btnRemoveFromList_Command);
                    btnRemoveFromList.CommandArgument  = product.ProductId.ToString();
                    btnRemoveFromList.CausesValidation = false;
                    btnRemoveFromList.CssClass         = "remove-button";
                    btnRemoveFromList.ID = "btnRemoveFromList" + product.ProductId.ToString();
                    productImagePanel.Controls.Add(btnRemoveFromList);
                    productImagePanel.Controls.Add(new HtmlGenericControl("br"));

                    var productImage = new HtmlImage();
                    productImage.Border = 0;
                    //productImage.Align = "center";
                    productImage.Alt = "Product image";
                    var picture = product.DefaultPicture;
                    if (picture != null)
                    {
                        productImage.Src = this.PictureService.GetPictureUrl(picture, this.SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125), true);
                    }
                    else
                    {
                        productImage.Src = this.PictureService.GetDefaultPictureUrl(this.SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125));
                    }
                    productImagePanel.Controls.Add(productImage);
                    headerCellDiv.Controls.Add(productImagePanel);

                    headerCell.Controls.Add(headerCellDiv);
                    headerRow.Cells.Add(headerCell);
                    this.tblCompareProducts.Rows.Add(headerRow);

                    var productNameCell = new HtmlTableCell();
                    var productLink     = new HyperLink();
                    productLink.Text        = Server.HtmlEncode(product.LocalizedName);
                    productLink.NavigateUrl = SEOHelper.GetProductUrl(product);
                    productLink.Attributes.Add("class", "link");
                    productNameCell.Align = "center";
                    productNameCell.Controls.Add(productLink);
                    productNameRow.Cells.Add(productNameCell);
                    var priceCell = new HtmlTableCell();
                    priceCell.Align = "center";
                    var productVariantCollection = product.ProductVariants;
                    if (productVariantCollection.Count > 0)
                    {
                        var     productVariant = productVariantCollection[0];
                        decimal taxRate        = decimal.Zero;
                        decimal finalPriceWithoutDiscountBase = this.TaxService.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false), out taxRate);
                        decimal finalPriceWithoutDiscount     = this.CurrencyService.ConvertCurrency(finalPriceWithoutDiscountBase, this.CurrencyService.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                        priceCell.InnerText = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                    }
                    priceRow.Cells.Add(priceCell);
                }
                productNameRow.Attributes.Add("class", "product-name");
                priceRow.Attributes.Add("class", "productPrice");
                this.tblCompareProducts.Rows.Add(productNameRow);
                if (!this.SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                    (NopContext.Current.User != null &&
                     !NopContext.Current.User.IsGuest))
                {
                    this.tblCompareProducts.Rows.Add(priceRow);
                }

                foreach (int specificationAttributeId in specificationAttributeIds)
                {
                    var specificationAttribute = this.SpecificationAttributeService.GetSpecificationAttributeById(specificationAttributeId);
                    var productRow             = new HtmlTableRow();
                    this.AddCell(productRow, Server.HtmlEncode(specificationAttribute.LocalizedName)).Align = "left";

                    foreach (var product2 in compareProducts)
                    {
                        var productCell = new HtmlTableCell();
                        {
                            var productSpecificationAttributes2 = this.SpecificationAttributeService.GetProductSpecificationAttributesByProductId(product2.ProductId, null, true);
                            foreach (var psa2 in productSpecificationAttributes2)
                            {
                                if (specificationAttribute.SpecificationAttributeId == psa2.SpecificationAttribute.SpecificationAttributeId)
                                {
                                    // SpecMod
                                    if (psa2.SpecificationAttributeOption.LocalizedName == "Value" || psa2.SpecificationAttributeOption.Name == "Value")
                                    { // Its a value spec
                                        productCell.InnerHtml = (!String.IsNullOrEmpty(psa2.Value)) ? Server.HtmlEncode(psa2.Value) : "&nbsp;";
                                    }
                                    else
                                    { // Its not a value spec, handle it the nop way
                                        productCell.InnerHtml = (!String.IsNullOrEmpty(psa2.SpecificationAttributeOption.LocalizedName)) ? Server.HtmlEncode(psa2.SpecificationAttributeOption.LocalizedName) : "&nbsp;";
                                    }
                                }
                            }
                        }
                        productCell.Align  = "center";
                        productCell.VAlign = "top";
                        productRow.Cells.Add(productCell);
                    }
                    this.tblCompareProducts.Rows.Add(productRow);
                }

                string width = Math.Round((decimal)(90M / compareProducts.Count), 0, MidpointRounding.AwayFromZero).ToString() + "%";
                for (int i = 0; i < this.tblCompareProducts.Rows.Count; i++)
                {
                    var row = this.tblCompareProducts.Rows[i];
                    for (int j = 1; j < row.Cells.Count; j++)
                    {
                        if (j == (row.Cells.Count - 1))
                        {
                            row.Cells[j].Style.Add("width", width);
                            row.Cells[j].Style.Add("text-align", "center");
                        }
                        else
                        {
                            row.Cells[j].Style.Add("width", width);
                            row.Cells[j].Style.Add("text-align", "center");
                        }
                    }
                }
            }
            else
            {
                btnClearCompareProductsList.Visible = false;
                tblCompareProducts.Visible          = false;
            }
        }
示例#11
0
        private void BindData()
        {
            if (product != null)
            {
                string productURL = SEOHelper.GetProductUrl(product.ProductId);

                // product name
                hpProductName.Text        = product.Name;
                hpProductName.NavigateUrl = productURL;

                // view more
                hlViewMore.NavigateUrl = productURL;

                #region product price
                var productVariantCollection = ProductManager.GetProductVariantsByProductId(product.ProductId);
                if (productVariantCollection.Count > 0)
                {
                    if (!(productVariantCollection.Count > 1))
                    {
                        var productVariant = productVariantCollection[0];

                        if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                            (NopContext.Current.User != null &&
                             !NopContext.Current.User.IsGuest))
                        {
                            if (productVariant.CustomerEntersPrice)
                            {
                                lblPrice.Visible = false;
                            }
                            else
                            {
                                decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice);
                                decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));

                                decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                                decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                                if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase != decimal.Zero)
                                {
                                    lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount, false, false);
                                }
                                else
                                {
                                    lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount, false, false);
                                }
                            }
                        }
                        else
                        {
                            lblPrice.Visible = false;
                        }
                    }
                    else
                    {
                        var productVariant = GetVariant(productVariantCollection);
                        if (productVariant != null)
                        {
                            if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                                (NopContext.Current.User != null &&
                                 !NopContext.Current.User.IsGuest))
                            {
                                if (productVariant.CustomerEntersPrice)
                                {
                                    lblPrice.Visible = false;
                                }
                                else
                                {
                                    decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                                    decimal fromPrice     = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                                    lblPrice.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice, false, false));
                                }
                            }
                            else
                            {
                                lblPrice.Visible = false;
                            }
                        }
                    }
                }
                else
                {
                    lblPrice.Visible = false;
                }
                #endregion

                // category
                var productCategories = CategoryManager.GetProductCategoriesByProductId(product.ProductId);
                if (productCategories.Count > 0)
                {
                    var breadCrumb = CategoryManager.GetBreadCrumb(productCategories[0].CategoryId);
                    if (breadCrumb.Count > 0)
                    {
                        rptrCategoryBreadcrumb.DataSource = breadCrumb;
                        rptrCategoryBreadcrumb.DataBind();
                    }
                }

                lblCategory.Text = "";// ProductManager.GetProductReviewByProductId(Product.ProductId);
                // catalog number
                LWG.Business.CatalogBiz catalogBiz = new LWG.Business.CatalogBiz();
                lwg_Catalog             catalog    = catalogBiz.GetByID(product.ProductId);
                hlCatalogNo.Text        = Server.HtmlEncode("# - " + catalog.CatalogNumber);
                hlCatalogNo.NavigateUrl = productURL;
            }
        }
        protected void BindData()
        {
            Product product = ProductManager.GetProductByID(ProductID);
            if (product != null)
            {
                ProductVariantCollection productVariantCollection = product.ProductVariants;
                ProductVariant productVariant = null;
                if (productVariantCollection.Count > 0)
                {
                    if (!product.HasMultipleVariants)
                    {
                        productVariant = productVariantCollection[0];

                        decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));

                        lblPrice2.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscountBase);
                        if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD")
                        {
                            lblPrice1.Text = lblPrice2.Text = lblPrice2.Text + "$";
                        }
                        else
                        {
                            lblPrice1.Text = lblPrice2.Text + " руб";
                        }
                    }
                    else
                    {
                        productVariant = product.MinimalPriceProductVariant;
                        if (productVariant != null)
                        {
                            decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                            decimal fromPrice = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                            lblPrice2.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                            lblPrice1.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                        }
                    }
                }

                lProductName.Text = Server.HtmlEncode(product.Name);
                lShortDescription.Text = product.ShortDescription;
                lFullDescription.Text = product.FullDescription;
                imgProduct.Alt = AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);

                if (product.ProductPictures.Count > 0)
                {
                    imgProduct.Src = PictureManager.GetPictureUrl(product.ProductPictures[0].PictureID, middleImageSize);
                    a_imgProduct.HRef = DefaultHref = PictureManager.GetPictureUrl(product.ProductPictures[0].PictureID, largeImageSize);
                }
                else
                {
                    imgProduct.Src = PictureManager.GetDefaultPictureUrl(middleImageSize);
                    a_imgProduct.HRef = DefaultHref = PictureManager.GetDefaultPictureUrl(largeImageSize); ;
                }
                ProductPictureCollection productPictures = product.ProductPictures;
                if (productPictures.Count > 1)
                {
                    this.dlImages.DataSource = productPictures;
                    this.dlImages.DataBind();
                }
                else
                {
                    PanelImages.Visible = false;
                }

                lbOrder.CommandArgument = product.ProductID.ToString();
                lbOrderAndCheckout.CommandArgument = product.ProductID.ToString();
                tblOrderButtons.Visible = productVariantCollection.Count != 0 && productVariantCollection[0].StockQuantity != 0;


                StringBuilder attributes = new StringBuilder();
                foreach (ProductSpecificationAttribute psa in SpecificationAttributeManager.GetProductSpecificationAttributesByProductID(product.ProductID, false, null))
                {
                    if (psa.SpecificationAttribute.Name == "Уникальное предложение")
                        pUniqueProposal.Visible = psa.SpecificationAttributeOption.Name == "Да";
                    else
                        attributes.AppendFormat(@"<p><span class=""pink"">{0}:</span> {1}</p>", psa.SpecificationAttribute.Name, psa.SpecificationAttributeOption.Name);
                }

                lblAttributes.Text += attributes.ToString();
                if (NopContext.Current.Session == null)
                    NopContext.Current.Session = NopContext.Current.GetSession(true);
                Guid CustomerSessionGUID = NopContext.Current.Session.CustomerSessionGUID;
                ViewedItemManager.InsertViewedItem(CustomerSessionGUID, productVariant.ProductVariantID, DateTime.Now); 
            }
            else
                Visible = false;
        }
示例#13
0
        private void BindData()
        {
            if (product != null)
            {
                string productURL = SEOHelper.GetProductUrl(product);

                LWG.Business.CatalogBiz catalogBiz = new LWG.Business.CatalogBiz();
                lwg_Catalog             catalog    = catalogBiz.GetByID(product.ProductId);

                hlCatalogNo.Text      = Server.HtmlEncode(catalog.CatalogNumber);
                hlProduct.NavigateUrl = hlCatalogNo.NavigateUrl = productURL;
                hlProduct.Text        = Server.HtmlEncode(product.Name);

                ProductPicture productPicture = product.DefaultProductPicture;
                if (productPicture != null)
                {
                    hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPicture.Picture, this.ProductImageSize, true);
                    hlImageLink.ToolTip  = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                    hlImageLink.Text     = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                }
                else
                {
                    hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(this.ProductImageSize);
                    hlImageLink.ToolTip  = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name);
                    hlImageLink.Text     = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name);
                }
                hlImageLink.NavigateUrl = productURL;

                lShortDescription.Text = product.ShortDescription;

                var productVariantCollection = product.ProductVariants;

                if (productVariantCollection.Count > 0)
                {
                    if (!product.HasMultipleVariants)
                    {
                        var productVariant = productVariantCollection[0];
                        btnAddToCart.Visible = (!productVariant.DisableBuyButton);
                        if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                            (NopContext.Current.User != null &&
                             !NopContext.Current.User.IsGuest))
                        {
                            if (productVariant.CustomerEntersPrice)
                            {
                                lblOldPrice.Visible = false;
                                lblPrice.Visible    = false;
                            }
                            else
                            {
                                decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice);
                                decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));

                                decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                                decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                                if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase != decimal.Zero)
                                {
                                    lblOldPrice.Text = PriceHelper.FormatPrice(oldPrice);
                                    lblPrice.Text    = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                                }
                                else
                                {
                                    lblOldPrice.Visible = false;
                                    lblPrice.Text       = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                                }
                            }
                        }
                        else
                        {
                            lblOldPrice.Visible  = false;
                            lblPrice.Visible     = false;
                            btnAddToCart.Visible = false;
                        }
                        ddlVariantPrice.Visible = false;
                    }
                    else
                    {
                        lblOldPrice.Visible  = false;
                        lblPrice.Visible     = false;
                        btnAddToCart.Visible = false;

                        ddlVariantPrice.Visible    = true;
                        ddlVariantPrice.DataSource = productVariantCollection.OrderBy(pv => pv.Price);
                        ddlVariantPrice.DataBind();
                        #region comment built-in code
                        //var productVariant = product.MinimalPriceProductVariant;
                        //if (productVariant != null)
                        //{
                        //    if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                        //        (NopContext.Current.User != null &&
                        //        !NopContext.Current.User.IsGuest))
                        //    {
                        //        if (productVariant.CustomerEntersPrice)
                        //        {
                        //            lblOldPrice.Visible = false;
                        //            lblPrice.Visible = false;
                        //        }
                        //        else
                        //        {
                        //            decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                        //            decimal fromPrice = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                        //            lblOldPrice.Visible = false;
                        //            lblPrice.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                        //        }
                        //    }
                        //    else
                        //    {
                        //        lblOldPrice.Visible = false;
                        //        lblPrice.Visible = false;
                        //        btnAddToCart.Visible = false;
                        //    }
                        //}

                        //btnAddToCart.Visible = false;
                        #endregion
                    }
                }
                else
                {
                    lblOldPrice.Visible  = false;
                    lblPrice.Visible     = false;
                    btnAddToCart.Visible = false;
                }
            }
        }