Table of Contents

Class ProductPercentageReward

Namespace
Dynamicweb.Ecommerce.Orders.Adjustments.Rewards
Assembly
Dynamicweb.Ecommerce.dll

A reward that applies a percentage discount to products.

[Experimental("DWEX100001")]
[AddInLabel("Percentage (product)")]
[AddInUseParameterSectioning(true)]
[AddInUseParameterGrouping(true)]
public sealed class ProductPercentageReward : Reward, IParameterOptions, IRenderableDiscount
Inheritance
ProductPercentageReward
Implements
Inherited Members

Constructors

ProductPercentageReward()

public ProductPercentageReward()

Properties

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

DiscountApplyToProduct

ContextType

The type of context the discount is applied to.

public override AdjustmentContextType ContextType { get; }

Property Value

AdjustmentContextType

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

string

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

string

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

string

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

string

OnlyApplyToNonDiscountedProducts

Determines if the discount should include VAT.

[AddInParameterGroup("Reward")]
[AddInParameter("OnlyApplyToNonDiscountedProductsLabel")]
[AddInLabel("Skip discounted products / order lines")]
[AddInParameterEditor(typeof(YesNoParameterEditor), "explanation=This reward only applies to products / order lines without an existing discount. Discounted items are excluded from the reward calculation.")]
public bool OnlyApplyToNonDiscountedProducts { get; set; }

Property Value

bool

Percentage

The percentage to discount the products with.

[AddInParameterGroup("Reward")]
[AddInParameter("Percentage")]
[AddInLabel("Percentage")]
[AddInParameterEditor(typeof(NumberParameterEditor), "minValue=0d;maxValue=100d;required=true")]
public double Percentage { get; set; }

Property Value

double

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

context OrderAdjustmentContext

The current context containing the order or orderline where the discount is being applied to, depending on the AdjustmentContextType.

Returns

bool

GetDiscountAmount(AdjustmentContext)

Gets the discount amount for the product.

public override PriceInfo? GetDiscountAmount(AdjustmentContext context)

Parameters

context AdjustmentContext

The 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

parameterName string

The name of the parameter.

Returns

string

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

propertyName string

The name of the parameter from DiscountViewModel.

settings DiscountViewModelSettings

The settings for the DiscountViewModel.

context ProductAdjustmentContext

The current context for the discount.

Returns

Func<T>

A function which results in a type for the propertyName.

Type Parameters

T

The type of the propertyName in DiscountViewModel.

GetParameterOptions(string)

public IEnumerable<ParameterOption> GetParameterOptions(string parameterName)

Parameters

parameterName string

Returns

IEnumerable<ParameterOption>
To top