public void Process(GetProductTotalsArgs args) { var product = args.Product; decimal price = 0; if (_priceCache.ContainsKey(product.Code)) { price = (System.Decimal)_priceCache[product.Code]; } else { var service = new Services.ProductServiceClient(); price = service.GetPrice(product.Code); _priceCache.Add(product.Code, price, 8, System.DateTime.UtcNow.AddMinutes(1)); } args.Totals.PriceExVat = price; args.HasPrice = true; }
public void Process(GetProductTotalsArgs args) { var product = args.Product; var category = product.GetCurrentCategoryItem() ?? product.GetDefaultCategoryItem(); if (category == null || category["SalePrice"].IsNullOrEmpty()) { return; } if (!category["FromDate"].IsNullOrEmpty()) { var date = new DateField(category.Fields["FromDate"]); if (DateTime.Now < date.DateTime) { return; } } if (!category["ToDate"].IsNullOrEmpty()) { var date = new DateField(category.Fields["ToDate"]); if (DateTime.Now > date.DateTime) { return; } } var salePrice = 0m; var havePrice = Decimal.TryParse(category["SalePrice"], out salePrice); if (!havePrice) { return; } if (args.HasPrice && salePrice < args.Totals.PriceExVat) { args.Totals.DiscountExVat = args.Totals.PriceExVat - salePrice; args.Totals.PriceExVat = salePrice; args.HasPrice = true; } else if (!args.HasPrice) { args.Totals.PriceExVat = salePrice; args.HasPrice = true; } }