public ActionResult HomePageTabWithProducts(List <string> productIds) { ProductsViewModel productsViewModel = new ProductsViewModel(); //loop productIds foreach (var productId in productIds) { var product = CatalogLibrary.GetProduct(Convert.ToInt32(productId)); productsViewModel.Products.Add(new ProductViewModel() { Name = product.Name, PriceCalculation = CatalogLibrary.CalculatePrice(product), Url = CatalogLibrary.GetNiceUrlForProduct(product), Sku = product.Sku, IsVariant = product.IsVariant, VariantSku = product.VariantSku, ThumbnailImageUrl = ObjectFactory.Instance.Resolve <IImageService>().GetImage(product.ThumbnailImageMediaId).Url }); //Get image and other details } // add to model return(View("/views/PartialView/_HomePageTabProducts.cshtml", productsViewModel)); }
protected void Page_Load(object sender, EventArgs e) { var catalogContext = ObjectFactory.Instance.Resolve <ICatalogContext>(); var imageService = ObjectFactory.Instance.Resolve <IImageService>(); if (CurrentProduct == null) { Visible = false; return; } string url = CatalogLibrary.GetNiceUrlForProduct(CurrentProduct, catalogContext.CurrentCategory); PriceCalculation price = CatalogLibrary.CalculatePrice(CurrentProduct); if (!string.IsNullOrWhiteSpace(CurrentProduct.ThumbnailImageMediaId)) { productImage.ImageUrl = imageService.GetImage(CurrentProduct.ThumbnailImageMediaId).Url; hlImage.Visible = true; } hlProduct.Text = CurrentProduct.DisplayName(); hlProduct.NavigateUrl = url; hlViewMore.NavigateUrl = url; hlImage.NavigateUrl = url; litPrice.Text = price?.YourPrice?.Amount.ToString() ?? "-"; if (price?.YourTax != null) { litTax.Text = price.YourTax.ToString(); } }
public ActionResult Index(ProductReviewViewModel formReview) { var product = SiteContext.Current.CatalogContext.CurrentProduct; var category = SiteContext.Current.CatalogContext.CurrentCategory; var request = System.Web.HttpContext.Current.Request; var basket = SiteContext.Current.OrderContext.GetBasket(); if (request.Form.AllKeys.All(x => x != "review-product")) { return(RedirectToAction("Index")); } var name = formReview.Name; var email = formReview.Email; var rating = Convert.ToInt32(formReview.Rating) * 20; var reviewHeadline = formReview.Title; var reviewText = formReview.Comments; if (basket.PurchaseOrder.Customer == null) { basket.PurchaseOrder.Customer = new Customer() { FirstName = name, LastName = String.Empty, EmailAddress = email }; } else { basket.PurchaseOrder.Customer.FirstName = name; if (basket.PurchaseOrder.Customer.LastName == null) { basket.PurchaseOrder.Customer.LastName = String.Empty; } basket.PurchaseOrder.Customer.EmailAddress = email; } basket.PurchaseOrder.Customer.Save(); var review = new ProductReview() { ProductCatalogGroup = SiteContext.Current.CatalogContext.CurrentCatalogGroup, ProductReviewStatus = ProductReviewStatus.SingleOrDefault(s => s.Name == "New"), CreatedOn = DateTime.Now, CreatedBy = "System", Product = product, Customer = basket.PurchaseOrder.Customer, Rating = rating, ReviewHeadline = reviewHeadline, ReviewText = reviewText, Ip = request.UserHostName }; product.AddProductReview(review); PipelineFactory.Create <ProductReview>("ProductReview").Execute(review); return(Redirect(CatalogLibrary.GetNiceUrlForProduct(product, category))); }
public IHttpActionResult GetBasket() { var currency = SiteContext.Current.CatalogContext.CurrentCatalog.PriceGroup.Currency; var purchaseOrder = TransactionLibrary.GetBasket(false).PurchaseOrder; var subTotal = new Money(purchaseOrder.SubTotal.Value, currency); var taxTotal = new Money(purchaseOrder.TaxTotal.Value, currency); var discountTotal = new Money(purchaseOrder.DiscountTotal.Value, currency); var orderTotal = new Money(purchaseOrder.OrderTotal.Value, currency); var basket = new Basket { SubTotal = purchaseOrder.SubTotal, TaxTotal = purchaseOrder.TaxTotal, DiscountTotal = purchaseOrder.DiscountTotal, OrderTotal = purchaseOrder.OrderTotal, TotalItems = purchaseOrder.OrderLines.Sum(l => l.Quantity), FormattedSubTotal = subTotal.ToString(), FormattedTaxTotal = taxTotal.ToString(), FormattedDiscountTotal = discountTotal.ToString(), FormattedOrderTotal = orderTotal.ToString(), FormattedTotalItems = purchaseOrder.OrderLines.Sum(l => l.Quantity).ToString("#,##"), LineItems = new List <LineItem>() }; foreach (var line in purchaseOrder.OrderLines) { var product = CatalogLibrary.GetProduct(line.Sku); var url = CatalogLibrary.GetNiceUrlForProduct(product); var imageUrl = GetImageUrlForProduct(product); var lineTotal = new Money(line.Total.Value, currency); var lineItem = new LineItem { OrderLineId = line.OrderLineId, Quantity = line.Quantity, Sku = line.Sku, VariantSku = line.VariantSku, Url = url, ImageUrl = imageUrl, Price = line.Price, ProductName = line.ProductName, Total = line.Total, FormattedTotal = lineTotal.ToString(), UnitDiscount = line.UnitDiscount, VAT = line.VAT, VATRate = line.VATRate }; basket.LineItems.Add(lineItem); } return(Json(new { Basket = basket })); }
public ActionResult Rendering() { BreadcrumbWrapper breadcrumbs = new BreadcrumbWrapper(); IList <Item> items = GetBreadcrumbItems(); foreach (Item item in items) { if (!IsTemplateBlacklisted(item.TemplateName)) { BreadcrumbViewModel crumb = new BreadcrumbViewModel(item); crumb.BreadcrumbName = item["Name"]; crumb.IsActive = Sitecore.Context.Item.ID == item.ID; crumb.BreadcrumbUrl = LinkManager.GetItemUrl(item); breadcrumbs.SitecoreBreadcrumbs.Add(crumb); } } Product product = SiteContext.Current.CatalogContext.CurrentProduct; Category lastCategory = SiteContext.Current.CatalogContext.CurrentCategory; foreach (var category in SiteContext.Current.CatalogContext.CurrentCategories) { BreadcrumbViewModelUcommerce crumb = new BreadcrumbViewModelUcommerce() { BreadcrumbNameUcommerce = category.DisplayName(), BreadcrumbUrlUcommerce = CatalogLibrary.GetNiceUrlForCategory(category) }; lastCategory = category; breadcrumbs.UcommerceBreadcrumbs.Add(crumb); } if (product != null) { var breadcrumb = new BreadcrumbViewModelUcommerce() { BreadcrumbNameUcommerce = product.DisplayName(), BreadcrumbUrlUcommerce = CatalogLibrary.GetNiceUrlForProduct(product, lastCategory) }; breadcrumbs.UcommerceBreadcrumbs.Add(breadcrumb); } if (IsTemplateWhitelisted(Sitecore.Context.Item.TemplateName)) { BreadcrumbViewModelUcommerce currentCrumb = new BreadcrumbViewModelUcommerce(); currentCrumb.BreadcrumbNameUcommerce = Sitecore.Context.Item.DisplayName; currentCrumb.BreadcrumbUrlUcommerce = LinkManager.GetItemUrl(Sitecore.Context.Item); breadcrumbs.UcommerceBreadcrumbs.Add(currentCrumb); } return(View(breadcrumbs)); }
public SearchResponse(IEnumerable <UCommerce.EntitiesV2.Product> products) { Variations = new List <ProductVariation>(); foreach (var product in products) { Variations.Add(new ProductVariation { Sku = product.Sku, VariantSku = product.VariantSku, ProductName = product.ProductDescriptions.First().DisplayName, Url = CatalogLibrary.GetNiceUrlForProduct(product), Properties = product.ProductProperties.Select(prop => new ProductProperty() { Id = prop.Id, Name = prop.ProductDefinitionField.Name, Value = prop.Value }) }); } }
// GET: HomepageCatalog public ActionResult Index() { var products = SiteContext.Current.CatalogContext.CurrentCatalog.Categories.SelectMany(c => c.Products.Where(p => p.ProductProperties.Any(pp => pp.ProductDefinitionField.Name == "ShowOnHomepage" && Convert.ToBoolean(pp.Value)))); ProductsViewModel productsViewModel = new ProductsViewModel(); foreach (var p in products) { productsViewModel.Products.Add(new ProductViewModel() { Name = p.Name, PriceCalculation = CatalogLibrary.CalculatePrice(p), Url = CatalogLibrary.GetNiceUrlForProduct(p), Sku = p.Sku, IsVariant = p.IsVariant, VariantSku = p.VariantSku, ThumbnailImageUrl = ObjectFactory.Instance.Resolve <IImageService>().GetImage(p.ThumbnailImageMediaId).Url }); } return(View("/Views/PartialView/HomepageCatalog.cshtml", productsViewModel)); }
public ActionResult Rendering() { var basketModel = new BasketRenderingViewModel(); if (!_transactionLibraryInternal.HasBasket()) { return(View(basketModel)); } PurchaseOrder basket = _transactionLibraryInternal.GetBasket(false).PurchaseOrder; foreach (var orderLine in basket.OrderLines) { var orderLineViewModel = new BasketRenderingViewModel.OrderlineViewModel(); orderLineViewModel.Quantity = orderLine.Quantity; orderLineViewModel.ProductName = orderLine.ProductName; orderLineViewModel.Sku = orderLine.Sku; orderLineViewModel.VariantSku = orderLine.VariantSku; orderLineViewModel.Total = new Money(orderLine.Total.GetValueOrDefault(), basket.BillingCurrency).ToString(); orderLineViewModel.Discount = orderLine.Discount; orderLineViewModel.Tax = new Money(orderLine.VAT, basket.BillingCurrency).ToString(); orderLineViewModel.Price = new Money(orderLine.Price, basket.BillingCurrency).ToString(); orderLineViewModel.ProductUrl = CatalogLibrary.GetNiceUrlForProduct(CatalogLibrary.GetProduct(orderLine.Sku)); orderLineViewModel.PriceWithDiscount = new Money(orderLine.Price - orderLine.UnitDiscount.GetValueOrDefault(), basket.BillingCurrency).ToString(); orderLineViewModel.OrderLineId = orderLine.OrderLineId; basketModel.OrderLines.Add(orderLineViewModel); } basketModel.OrderTotal = new Money(basket.OrderTotal.GetValueOrDefault(), basket.BillingCurrency).ToString(); basketModel.DiscountTotal = new Money(basket.DiscountTotal.GetValueOrDefault(), basket.BillingCurrency).ToString(); basketModel.TaxTotal = new Money(basket.TaxTotal.GetValueOrDefault(), basket.BillingCurrency).ToString(); basketModel.SubTotal = new Money(basket.SubTotal.GetValueOrDefault(), basket.BillingCurrency).ToString(); basketModel.RefreshUrl = Url.Action("UpdateBasket"); basketModel.RemoveOrderlineUrl = Url.Action("RemoveOrderline"); return(View(basketModel)); }
public List <UcommerceProductDto> ConvertToUcommerceProduct(ICollection <Product> _products) { var data = new List <UcommerceProductDto>(); var imageService = ObjectFactory.Instance.Resolve <IImageService>(); foreach (Product product in _products) { var url = CatalogLibrary.GetNiceUrlForProduct(product, SiteContext.Current.CatalogContext.CurrentCategory, SiteContext.Current.CatalogContext.CurrentCatalog); var price = CatalogLibrary.CalculatePrice(product); var ucommerceProduct = new UcommerceProductDto { ProductName = product.DisplayName(), ProductSku = product.Sku, ProductUrl = url, Price = "-", Tax = "-" }; if (price.YourPrice != null) { ucommerceProduct.Price = price.YourPrice.Amount.ToString(); } if (price.YourTax != null) { ucommerceProduct.Tax = price.YourTax.ToString(); } data.Add(ucommerceProduct); if (!string.IsNullOrWhiteSpace(product.PrimaryImageMediaId)) { ucommerceProduct.ImageUrl = imageService.GetImage(product.PrimaryImageMediaId).Url; } } return(data); }
private IList <ProductVariation> MapResult(IList <UCommerce.EntitiesV2.Product> products) { var variations = new List <ProductVariation>(); foreach (var product in products) { variations.Add(new ProductVariation { Sku = product.Sku, VariantSku = product.VariantSku, ProductName = product.ProductDescriptions.First().DisplayName, Url = CatalogLibrary.GetNiceUrlForProduct(product), Properties = product.ProductProperties.Select(prop => new ProductProperty() { Id = prop.Id, Name = prop.ProductDefinitionField.Name, Value = prop.Value }) }); } return(variations); }
private string GetProductUrl(Product product, Guid detailPageId) { if (detailPageId == Guid.Empty) { return(CatalogLibrary.GetNiceUrlForProduct(product)); } var baseUrl = UCommerce.Sitefinity.UI.Pages.UrlResolver.GetPageNodeUrl(detailPageId); string catUrl; var productCategory = product.GetCategories().FirstOrDefault(); if (productCategory == null) { catUrl = CategoryModel.DefaultCategoryName; } else { catUrl = CategoryModel.GetCategoryPath(productCategory); } var rawtUrl = string.Format("{0}/{1}", catUrl, product.ProductId); string relativeUrl = string.Concat(VirtualPathUtility.RemoveTrailingSlash(baseUrl), "/", rawtUrl); string url; if (SystemManager.CurrentHttpContext.Request.Url != null) { url = UrlPath.ResolveUrl(relativeUrl, true); } else { url = UCommerce.Sitefinity.UI.Pages.UrlResolver.GetAbsoluteUrl(relativeUrl); } return(url); }
private IList <FullTextSearchResultDTO> ConvertToFullTextSearchResultModel(IList <Product> products, Guid?productDetailsPageId) { var fullTextSearchResultModels = new List <FullTextSearchResultDTO>(); var currency = UCommerce.Runtime.SiteContext.Current.CatalogContext.CurrentPriceGroup.Currency; var productsPrices = UCommerce.Api.CatalogLibrary.CalculatePrice(products.Select(x => x.Guid).ToList()).Items; ProductCatalog catalog = UCommerce.Api.CatalogLibrary.GetCatalog(); var culture = System.Threading.Thread.CurrentThread.CurrentUICulture; foreach (var product in products) { string catUrl = CategoryModel.DefaultCategoryName; if (product.CategoryIds != null && product.CategoryIds.Any()) { var productCategory = catalog.Categories .Where(c => c.CategoryId == product.CategoryIds.FirstOrDefault()) .FirstOrDefault(); if (productCategory != null) { catUrl = CategoryModel.GetCategoryPath(productCategory); } } string detailsPageUrl = string.Empty; if (productDetailsPageId != null && productDetailsPageId.Value != Guid.Empty) { detailsPageUrl = Pages.UrlResolver.GetPageNodeUrl(productDetailsPageId.Value); if (!detailsPageUrl.EndsWith("/")) { detailsPageUrl += "/"; } detailsPageUrl += catUrl + "/" + product.Id.ToString(); detailsPageUrl = Pages.UrlResolver.GetAbsoluteUrl(detailsPageUrl); } if (string.IsNullOrWhiteSpace(detailsPageUrl)) { var entityProduct = this.productRepository.Get(product.Id); detailsPageUrl = CatalogLibrary.GetNiceUrlForProduct(entityProduct); } var fullTestSearchResultModel = new FullTextSearchResultDTO() { ThumbnailImageUrl = product.ThumbnailImageUrl, Name = product.Name, Url = detailsPageUrl, Price = new Money(productsPrices.First(x => x.ProductGuid == product.Guid).PriceInclTax, currency).ToString(), }; fullTextSearchResultModels.Add(fullTestSearchResultModel); } return(fullTextSearchResultModels); }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (this.StopProcessing) { // Do not process } else { if (PortalContext.ViewMode == ViewModeEnum.Edit || PortalContext.ViewMode == ViewModeEnum.Design) { return; } var delimiter = GetStringValue("Delimiter", ">"); bool includeKenticoNodes = ValidationHelper.GetBoolean(this.GetValue("IncludeKenticoNodes"), true); var breadcrumbs = new List <BreadcrumbViewModel>(); if (includeKenticoNodes) { var documentsOnPath = CurrentDocument.DocumentsOnPath; foreach (var node in documentsOnPath) { if (!node.NodeAlias.IsNullOrWhiteSpace() && PageTemplateInfoProvider.GetPageTemplateInfo(node.GetUsedPageTemplateId()).DisplayName != "Catalog" && PageTemplateInfoProvider.GetPageTemplateInfo(node.GetUsedPageTemplateId()).DisplayName != "Product") { breadcrumbs.Add( new BreadcrumbViewModel { BreadcrumbName = node.NodeAlias, BreadcrumbUrl = node.AbsoluteURL }); breadcrumbs.Add(new BreadcrumbViewModel { BreadcrumbName = delimiter }); } } } var delimiterBreadcrumb = new BreadcrumbViewModel { BreadcrumbName = delimiter }; Product product = SiteContext.Current.CatalogContext.CurrentProduct; Category lastCategory = SiteContext.Current.CatalogContext.CurrentCategory; var defaultCatalogDataProvider = ObjectFactory.Instance.Resolve <IDefaultCatalogDataProvider>(); if (lastCategory == null && CurrentDocument.NodeAlias == "Catalog") { lastCategory = defaultCatalogDataProvider.GetDefaultCategory(); SiteContext.Current.CatalogContext.CurrentCategories.Add(lastCategory); } if (lastCategory == null && product == null && CurrentDocument.NodeAlias == "Product") { product = defaultCatalogDataProvider.GetDefaultProduct(); } if (SiteContext.Current.CatalogContext.CurrentCategories.Any()) { foreach (var category in SiteContext.Current.CatalogContext.CurrentCategories) { var breadcrumb = new BreadcrumbViewModel { BreadcrumbName = category.DisplayName(), BreadcrumbUrl = CatalogLibrary.GetNiceUrlForCategory(category) }; lastCategory = category; breadcrumbs.Add(breadcrumb); if (category == SiteContext.Current.CatalogContext.CurrentCategory && product == null) { break; } breadcrumbs.Add(delimiterBreadcrumb); } } if (product != null) { var breadcrumb = new BreadcrumbViewModel { BreadcrumbName = product.DisplayName(), BreadcrumbUrl = CatalogLibrary.GetNiceUrlForProduct(product, lastCategory) }; breadcrumbs.Add(breadcrumb); } if (breadcrumbs.Any() && breadcrumbs.Last().BreadcrumbName == delimiter) { breadcrumbs.Remove(breadcrumbs.Last()); } Breadcrumbs.DataSource = breadcrumbs; Breadcrumbs.DataBind(); } }
public virtual ProductDetailViewModel CreateDetailsViewModel() { ProductDetailViewModel productDetailViewModel = null; var currentProduct = SiteContext.Current.CatalogContext.CurrentProduct; if (currentProduct != null) { var imageService = UCommerce.Infrastructure.ObjectFactory.Instance.Resolve <IImageService>(); var currentCategory = SiteContext.Current.CatalogContext.CurrentCategory; string displayName = string.Empty; if (currentProduct.ParentProduct != null) { displayName = $"{currentProduct.ParentProduct.DisplayName()} "; } displayName += currentProduct.DisplayName(); var productPrice = CatalogLibrary.CalculatePrice(new List <Product>() { currentProduct }).Items.FirstOrDefault(); decimal price = 0; decimal discount = 0; if (productPrice != null) { price = productPrice.PriceExclTax; discount = productPrice.DiscountExclTax; var currentCatalog = SiteContext.Current.CatalogContext.CurrentCatalog; if (currentCatalog != null && currentCatalog.ShowPricesIncludingVAT) { price = productPrice.PriceInclTax; discount = productPrice.DiscountInclTax; } } var imageUrl = imageService.GetImage(currentProduct.PrimaryImageMediaId).Url; var absoluteImageUrl = UrlPath.ResolveAbsoluteUrl(imageUrl); productDetailViewModel = new ProductDetailViewModel() { DisplayName = displayName, Guid = currentProduct.Guid, PrimaryImageMediaUrl = absoluteImageUrl, LongDescription = currentProduct.LongDescription(), ShortDescription = currentProduct.ShortDescription(), ProductUrl = CatalogLibrary.GetNiceUrlForProduct(currentProduct, currentCategory), Price = new Money(price, SiteContext.Current.CatalogContext.CurrentPriceGroup.Currency).ToString(), Discount = new Money(discount, SiteContext.Current.CatalogContext.CurrentPriceGroup.Currency).ToString(), Sku = currentProduct.Sku, Rating = Convert.ToInt32(Math.Round(currentProduct.Rating.GetValueOrDefault())), VariantSku = currentProduct.VariantSku, IsVariant = currentProduct.IsVariant, IsProductFamily = currentProduct.ProductDefinition.IsProductFamily(), AllowOrdering = currentProduct.AllowOrdering, }; if (currentProduct.ParentProduct != null) { productDetailViewModel.ParentProductUrl = CatalogLibrary.GetNiceUrlForProduct(currentProduct.ParentProduct, currentCategory); productDetailViewModel.ParentProductDisplayName = currentProduct.ParentProduct.DisplayName(); } if (currentCategory != null) { productDetailViewModel.CategoryDisplayName = currentCategory.DisplayName(); productDetailViewModel.CategoryUrl = CatalogLibrary.GetNiceUrlForCategory(currentCategory); productDetailViewModel.ProductUrl = CatalogLibrary.GetNiceUrlForProduct(currentProduct, currentCategory); } foreach (var pv in currentProduct.Variants) { foreach (var v in pv.ProductProperties) { if (v.ProductDefinitionField != null && v.ProductDefinitionField.IsVariantProperty) { if (productDetailViewModel.VariantTypes.Any(t => t.Id == v.ProductDefinitionField.Id)) { } } } } var uniqueVariants = from v in currentProduct.Variants.SelectMany(p => p.ProductProperties) where v.ProductDefinitionField.DisplayOnSite group v by v.ProductDefinitionField into g select g; foreach (var vt in uniqueVariants) { var typeViewModel = productDetailViewModel.VariantTypes .Where(z => z.Id == vt.Key.ProductDefinitionFieldId) .FirstOrDefault(); if (typeViewModel == null) { typeViewModel = new VariantTypeViewModel { Id = vt.Key.ProductDefinitionFieldId, Name = vt.Key.Name, DisplayName = vt.Key.GetDisplayName() }; productDetailViewModel.VariantTypes.Add(typeViewModel); } var variants = vt.ToList(); foreach (var variant in variants) { var variantViewModel = typeViewModel.Values .Where(v => v.Value == variant.Value) .FirstOrDefault(); if (variantViewModel == null) { variantViewModel = new VariantViewModel { Value = variant.Value, TypeName = typeViewModel.Name }; if (!string.IsNullOrEmpty(variant.Product.PrimaryImageMediaId)) { var variantImageUrl = imageService.GetImage(variant.Product.PrimaryImageMediaId).Url; variantViewModel.PrimaryImageMediaUrl = UrlPath.ResolveAbsoluteUrl(variantImageUrl); } typeViewModel.Values.Add(variantViewModel); } } } productDetailViewModel.Routes.Add(RouteConstants.ADD_TO_BASKET_ROUTE_NAME, RouteConstants.ADD_TO_BASKET_ROUTE_VALUE); } return(productDetailViewModel); }
public void CartRepeaterItemDataBound(object sender, RepeaterItemEventArgs e) { bool orderlinePrice = ValidationHelper.GetBoolean(GetValue("OrderlinePrice"), true); bool orderlineVat = ValidationHelper.GetBoolean(GetValue("OrderlineVAT"), true); bool orderlineQuantity = ValidationHelper.GetBoolean(GetValue("OrderlineQuantity"), true); bool orderlineItemNo = ValidationHelper.GetBoolean(GetValue("OrderlineItemNo"), true); bool editable = ValidationHelper.GetBoolean(GetValue("Editable"), true); if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } Currency currency = TransactionLibrary.GetBasket(true).PurchaseOrder.BillingCurrency; OrderLine currentItem = (OrderLine)e.Item.DataItem; var product = CatalogLibrary.GetProduct(currentItem.Sku); var itemPrice = new Money(currentItem.Price, currency); var itemTax = new Money(currentItem.VAT, currency); var lineTotal = new Money(currentItem.Total.Value, currency); var lnkItemLink = (HyperLink)e.Item.FindControl("lnkItemLink"); var litPrice = (Literal)e.Item.FindControl("litPrice"); var litVat = (Literal)e.Item.FindControl("litVat"); var litTotal = (Literal)e.Item.FindControl("litTotal"); var txtQuantity = (TextBox)e.Item.FindControl("txtQuantity"); var btnUpdateQuantities = (Button)e.Item.FindControl("btnUpdateQuantities"); var btnRemoveLine = (Button)e.Item.FindControl("btnRemoveLine"); var lblQuantity = (Label)e.Item.FindControl("lblQuantity"); var litItemNo = (Literal)e.Item.FindControl("litItemNo"); string url = CatalogLibrary.GetNiceUrlForProduct(product, product.GetCategories().FirstOrDefault()); lnkItemLink.Text = currentItem.ProductName; lnkItemLink.NavigateUrl = url; if (currentItem.UnitDiscount.HasValue && currentItem.UnitDiscount > 0) { var nowPrice = new Money((currentItem.Price - currentItem.UnitDiscount.Value), currency); litPrice.Text = "<span style=\"text-decoration: line-through\">" + itemPrice + "</span>" + nowPrice; } else { litPrice.Text = itemPrice.ToString(); } litVat.Text = itemTax.ToString(); litTotal.Text = lineTotal.ToString(); txtQuantity.Text = currentItem.Quantity.ToString(); txtQuantity.Attributes.Add("orderlinenumber", _currentIteration.ToString()); btnUpdateQuantities.Attributes.Add("orderlinenumber", _currentIteration.ToString()); btnRemoveLine.Attributes.Add("orderlinenumber", _currentIteration.ToString()); btnUpdateQuantities.ID = "btnUpdateQuantities" + _currentIteration; txtQuantity.ID = "txtQuantity" + _currentIteration; txtQuantity.Attributes.Add("data-orderlineid", currentItem.OrderLineId.ToString()); litPrice.Visible = orderlinePrice; litVat.Visible = orderlineVat; txtQuantity.Visible = orderlineQuantity; btnUpdateQuantities.Visible = orderlineQuantity; litItemNo.Text = currentItem.Sku; litItemNo.Visible = orderlineItemNo; if (!editable) { btnRemoveLine.Visible = false; btnUpdateQuantities.Visible = false; txtQuantity.Attributes.Add("readonly", "true"); txtQuantity.CssClass += " textbox-to-label"; } _currentIteration++; }