protected bool HasPrice(VariationContent variationContent) { var price = variationContent .GetPrices(PricingLoader) .FirstOrDefault(x => x.MarketId == CurrentMarket.GetCurrentMarket().MarketId); return(price != null && price.UnitPrice != null); }
protected IEnumerable <EntryContentBase> GetRelatedContent() { if (CurrentData == null) { return(Enumerable.Empty <EntryContentBase>()); } var allAssociations = LinkRepository.Service.GetAssociations(CurrentData.ContentLink); var relatedItems = allAssociations.Where(a => a.Group.Name == GroupName).Select(a => ContentLoader.Get <EntryContentBase>(a.Target)); var currentMarket = CurrentMarket.GetCurrentMarket(); return(ForVisitor(() => relatedItems.Where(i => !i.MarketFilter.Contains(currentMarket.MarketId)))); }
private void BindPromotions() { var variationContent = CurrentData as VariationContent; if (variationContent == null) { variationContent = GetVariants <VariationContent>().FirstOrDefault(FilterAction); } Visible = false; if (variationContent == null) { return; } // We have to load an entry to be able to get promotions. var entrySku = variationContent.LoadEntry(); var currentMarketId = CurrentMarket.GetCurrentMarket().MarketId; if (!entrySku.IsAvailableInMarket(currentMarketId)) { return; } Promotions.Text = String.Empty; var promotions = entrySku.GetPromotions(); if (!promotions.PromotionRecords.Any()) { return; } Visible = true; PromotionsHolder.Visible = true; var marketService = Locate.MarketService(); foreach (var record in promotions.PromotionRecords) { var promotionName = record.PromotionItem.DataRow.GetPromotionLanguageRows().FirstOrDefault(x => x.LanguageCode == marketService.GetMarket(MarketId.Default).DefaultLanguage.ToString()) != null? record.PromotionItem.DataRow.GetPromotionLanguageRows().FirstOrDefault(x => x.LanguageCode == marketService.GetMarket(MarketId.Default).DefaultLanguage.ToString()).DisplayName: record.PromotionItem.DataRow.Name; Promotions.Text += string.Format("Promotion Name: {0} <br/>", promotionName); Promotions.Text += string.Format("Amount Off: {0}{1}<br/>", record.PromotionReward.AmountOff.ToString(), record.PromotionReward.AmountType == "Percentage" ? "%" : ""); } }
private void CalculatePriceValues() { if (FilterAction != null && CurrentData != null) { var variationContent = CurrentData as VariationContent; if (variationContent == null) { variationContent = GetVariants <VariationContent>().FirstOrDefault(FilterAction); } if (variationContent == null) { DisplayPriceInfo(); return; } var currentMarket = CurrentMarket.GetCurrentMarket(); var entry = variationContent.LoadEntry(CatalogEntryResponseGroup.ResponseGroup.Variations); var salePrice = StoreHelper.GetSalePrice(entry, 1); if (variationContent.IsAvailableInMarket(currentMarket.MarketId) && salePrice != null) { var basePrice = salePrice.Money; var discount = StoreHelper.GetDiscountPrice(entry); var discountNum = basePrice; if (discount != null && discount.Money.Amount != -1) { discountNum = discount.Money; } var saved = basePrice.Subtract(discountNum); ListPrice.Text = basePrice.ToString(); DiscountPricing.Text = discountNum.ToString(); Savings.Text = saved.ToString(); return; } } DisplayPriceInfo(); }
private void GetPromotions(ListViewItemEventArgs e, Entry entry) { var promotions = entry.GetPromotions(); if (promotions.PromotionRecords.Count == 0) { return; } var lit = e.Item.FindControl("Promotions") as Literal; if (lit == null) { return; } e.Item.FindControl("PromotionsHolder").Visible = true; foreach (var record in promotions.PromotionRecords) { var promotionLanguageRow = record.PromotionItem.DataRow.GetPromotionLanguageRows() .FirstOrDefault( x => x.LanguageCode == CurrentMarket.GetCurrentMarket().DefaultLanguage.ToString()); var promotionName = promotionLanguageRow != null ? promotionLanguageRow.DisplayName : record.PromotionItem.DataRow.Name; lit.Text += string.Format("Promotion Name: {0} <br/>", promotionName); lit.Text += string.Format("Amount Off: {0}{1}<br/>", record.PromotionReward.AmountOff, record.PromotionReward.AmountType == "Percentage" ? "%" : ""); } }
protected void Page_Load(object sender, EventArgs e) { _marketId = CurrentMarket.GetCurrentMarket().MarketId; //Store the LastCatalogPageUrl to allow "continue shopping" redirect Session[Constants.LastCatalogPageUrl] = Request.Url.ToString(); }
protected Price GetPrice(IPricing pricing) { return(pricing.GetPrices(PricingLoader).FirstOrDefault(x => x.MarketId == CurrentMarket.GetCurrentMarket().MarketId)); }