/// <summary> /// Sets discount price for the first variation with a price /// </summary> /// <param name="findProduct"></param> /// <param name="content"></param> /// <param name="market"></param> public static void SetPriceData(this FindProduct findProduct, List <VariationContent> content, IMarket market) { VariationContent variation = null; if (content.Any()) { foreach (var item in content) { var price = item.GetPrice(market); if (price != null) { variation = item; break; } } } if (variation == null) { return; } PriceModel priceModel = variation.GetPriceModel(market); findProduct.DefaultPrice = priceModel.DefaultPrice.UnitPrice.ToString(); findProduct.DefaultPriceAmount = content.GetDefaultPriceAmountWholeNumber(market); DiscountPrice discountPrice = priceModel.DiscountPrice; findProduct.DiscountedPriceAmount = (double)discountPrice.GetDiscountPriceWithCheck(); findProduct.DiscountedPrice = discountPrice.GetDiscountDisplayPriceWithCheck(); findProduct.CustomerClubPriceAmount = (double)priceModel.CustomerClubPrice.GetPriceAmountSafe(); findProduct.CustomerClubPrice = priceModel.CustomerClubPrice.GetPriceAmountStringSafe(); }
protected void PopulatePrices(VariationContent content, IMarket currentMarket) { var priceModel = content.GetPriceModel(currentMarket); if (priceModel == null) { return; } if (priceModel.DefaultPrice == null) { return; } PriceString = priceModel.DefaultPrice.UnitPrice.ToString(); PriceAmount = priceModel.DefaultPrice.UnitPrice.Amount; DiscountPriceAmount = priceModel.HasDiscount() ? priceModel.DiscountPrice.Price.Amount : 0; DiscountPriceString = priceModel.HasDiscount() ? priceModel.DiscountPrice.Price.ToString() : ""; DiscountPriceAvailable = DiscountPriceAmount > 0; CustomerClubMemberPriceAmount = priceModel.CustomerClubPrice.GetPriceAmountSafe(); CustomerClubMemberPriceString = priceModel.CustomerClubPrice.GetPriceAmountStringSafe(); CustomerPriceAvailable = CustomerClubMemberPriceAmount > 0; }
public static void SetPriceData(this FindProduct findProduct, VariationContent content, IMarket market) { PriceModel priceModel = content.GetPriceModel(market); findProduct.DefaultPrice = priceModel.DefaultPrice.UnitPrice.ToString(); findProduct.DefaultPriceAmount = content.GetDefaultPriceAmountWholeNumber(market); DiscountPrice discountPrice = priceModel.DiscountPrice; findProduct.DiscountedPriceAmount = (double)discountPrice.GetDiscountPriceWithCheck(); findProduct.DiscountedPrice = discountPrice.GetDiscountDisplayPriceWithCheck(); findProduct.CustomerClubPriceAmount = (double)priceModel.CustomerClubPrice.GetPriceAmountSafe(); findProduct.CustomerClubPrice = priceModel.CustomerClubPrice.GetPriceAmountStringSafe(); }