Class ProductAmountReward
- Namespace
- Dynamicweb.Ecommerce.Orders.Adjustments.Rewards
- Assembly
- Dynamicweb.Ecommerce.dll
A reward that applies a fixed amount to the price of a product.
[Experimental("DWEX100001")]
[AddInLabel("Amount (product)")]
[AddInUseParameterSectioning(true)]
[AddInUseParameterGrouping(true)]
public sealed class ProductAmountReward : Reward, IParameterOptions, IRenderableDiscount
- Inheritance
-
ProductAmountReward
- Implements
- Inherited Members
Constructors
ProductAmountReward()
public ProductAmountReward()
Properties
Amount
The amount to discount from the product price.
[AddInParameterGroup("Reward")]
[AddInParameter("Amount")]
[AddInLabel("Amount")]
[AddInParameterEditor(typeof(NumberParameterEditor), "minValue=0d;required=true")]
public double Amount { get; set; }
Property Value
AppliesTo
Determines if the discount should be applied to the cheapest, most expensive or all selected products.
[AddInParameterGroup("Reward")]
[AddInParameter("AppliesTo")]
[AddInLabel("Applies to")]
[AddInParameterEditor(typeof(RadioParameterEditor), "")]
public DiscountApplyToProduct AppliesTo { get; set; }
Property Value
ContextType
The type of context the discount is applied to.
public override AdjustmentContextType ContextType { get; }
Property Value
CurrencyCode
The currency code for the currency to apply the discount in.
[AddInParameterGroup("Reward")]
[AddInParameter("Currency")]
[AddInLabel("Currency")]
[AddInParameterEditor(typeof(DropDownParameterEditor), "none=false")]
public string? CurrencyCode { get; set; }
Property Value
ExcludedProductGroups
The product groups to exclude from the discount.
[AddInParameterGroup("Selected products")]
[AddInParameter("ExcludedProductGroups")]
[AddInLabel("Excluded product groups")]
[AddInParameterEditor(typeof(ProductGroupParameterEditor), "multiple=true;explanation=If any product group is selected, it will exclude those product groups and apply to all products not in those groups. If none are selected, it will apply to all products as no product groups are excluded.")]
public string? ExcludedProductGroups { get; set; }
Property Value
ExcludedProducts
The products to exclude from the discount.
[AddInParameterGroup("Selected products")]
[AddInParameter("ExcludedProducts")]
[AddInLabel("Excluded products")]
[AddInParameterEditor(typeof(ProductSelectorParameterEditor), "multiple=true;explanation=If any products is selected, it will exclude those and apply to all other products. If none are selected, it will apply to all products as no products are excluded.")]
public string? ExcludedProducts { get; set; }
Property Value
IncludedProductGroups
The product groups to apply the discount to.
[AddInParameterGroup("Selected products")]
[AddInParameter("IncludedProductGroups")]
[AddInLabel("Included product groups")]
[AddInParameterEditor(typeof(ProductGroupParameterEditor), "multiple=true;explanation=If any product group is selected, it will only apply to products in those groups. If none are selected, it will apply to all products.")]
public string? IncludedProductGroups { get; set; }
Property Value
IncludedProducts
The products to apply the discount to.
[AddInParameterGroup("Selected products")]
[AddInParameter("IncludedProducts")]
[AddInLabel("Included products")]
[AddInParameterEditor(typeof(ProductSelectorParameterEditor), "multiple=true;explanation=If any products is selected, it will only apply to those. If none are selected, it will apply to all products.")]
public string? IncludedProducts { get; set; }
Property Value
IncludedVat
Determines if the discount should include VAT.
[AddInParameterGroup("Reward")]
[AddInParameter("IncludedVAT")]
[AddInLabel("")]
[AddInParameterEditor(typeof(RadioParameterEditor), "")]
public bool IncludedVat { get; set; }
Property Value
Methods
ApplyReward(OrderAdjustmentContext)
Applies the discount. The way a reward is applied is up to the implementation. It can use the OrderAdjustmentContext to get a reference to the order and apply the discount to the order.
public override bool ApplyReward(OrderAdjustmentContext context)
Parameters
contextOrderAdjustmentContextThe current context containing the order or orderline where the discount is being applied to, depending on the AdjustmentContextType.
Returns
GetDiscountAmount(AdjustmentContext)
Gets the discount amount for the product.
public override PriceInfo? GetDiscountAmount(AdjustmentContext context)
Parameters
contextAdjustmentContextThe context containing the product being fetched.
Returns
- PriceInfo
The discount amount for the product.
GetDisplayValue(string)
Returns the UI display format for the discount, visible in the Discount overview screen.
public override string? GetDisplayValue(string parameterName)
Parameters
parameterNamestringThe name of the parameter.
Returns
GetFillableProperty<T>(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 Func<T>? GetFillableProperty<T>(string propertyName, DiscountViewModelSettings settings, ProductAdjustmentContext context)
Parameters
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.
GetParameterOptions(string)
public IEnumerable<ParameterOption> GetParameterOptions(string parameterName)
Parameters
parameterNamestring