Extend product/category
Extend IProduct
public class ProductFac : IPerStoreFactory<IProduct>
{
public IProduct Create(UmbracoContent item, IStore store)
{
return new ExtendProduct(item, store);
}
}
public class ExtendProduct : Product
{
public ExtendProduct(UmbracoContent item, IStore store) : base(item, store)
{
}
public string NewProperty
{
get
{
return "";
}
}
public override List<IPrice> Prices
{
get
{
var list = new List<IPrice>();
if (_contextAccessor.HttpContext.User.Identity.IsAuthenticated)
{
var _cs = _contextAccessor.HttpContext.RequestServices.GetService<CustomerService>();
var _discountService = _contextAccessor.HttpContext.RequestServices.GetService<DiscountService>();
var customer = _cs.Get();
if (customer != null)
{
var discountPrice = _discountService.GetDiscountPricePerCustomer(customer.Id, SKU).Result;
if (discountPrice != null && discountPrice.Price != 0)
{
list.Add(new Price(
discountPrice.Price,
Store.Currency,
Vat,
Store.VatIncludedInPrice,
null,
1
));
return list;
}
}
}
list.Add(ListPrice);
return list;
}
}
}Extend ICategory
Register the override
Last updated