Class DiscountEngine
- Namespace
- Dynamicweb.Ecommerce.Orders.Adjustments
- Assembly
- Dynamicweb.Ecommerce.dll
Represents a discount engine. To implement a custom discount engine, inherit from this class and override the ApplyDiscounts and GetProductDiscounts methods.
[Experimental("DWEX100001")]
public abstract class DiscountEngine
- Inheritance
-
DiscountEngine
- Inherited Members
Methods
ApplyDiscounts(OrderAdjustmentContext)
Is run when discounts are applied to the cart.
public abstract bool ApplyDiscounts(OrderAdjustmentContext context)
Parameters
contextOrderAdjustmentContextThe current context containing the order and/or orderline where the discount is being applied to.
Returns
GetFillableProperty<T>(IRenderableDiscount, string, DiscountViewModelSettings, ProductAdjustmentContext)
Returns a function that has the result for the property given. If the propertyName is not a property the discount implementing this interface has, it should return null.
public abstract Func<T>? GetFillableProperty<T>(IRenderableDiscount discount, string propertyName, DiscountViewModelSettings settings, ProductAdjustmentContext context)
Parameters
discountIRenderableDiscountThe discount to get the function from.
propertyNamestringThe name of the parameter from DiscountViewModel.
settingsDiscountViewModelSettingsThe settings for the DiscountViewModel.
contextProductAdjustmentContextThe current context for the discount.
Returns
- Func<T>
A function which results in a type for the propertyName.
Type Parameters
TThe type of the propertyName in DiscountViewModel.
GetProductDiscounts(ProductAdjustmentContext)
Is run when fetching discounts for products, when fetching product prices.
public abstract IEnumerable<IRenderableDiscount> GetProductDiscounts(ProductAdjustmentContext context)
Parameters
contextProductAdjustmentContextThe context containing the product being fetched.