Table of Contents

Class OrderPromotionRule<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>

Namespace
Kentico.Xperience.Admin.DigitalCommerce
Assembly
Kentico.Xperience.Admin.DigitalCommerce.Shared.dll

Represents an order promotion rule with built-in functionality for common promotion scenarios.

public abstract class OrderPromotionRule<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult> : OrderPromotionRuleBase<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>, IOrderPromotionRule<TPriceCalculationRequest, TPriceCalculationResult>, IPromotionRule<TPriceCalculationRequest, TPriceCalculationResult>, IPromotionRule where TPromotionRuleProperties : OrderPromotionRuleProperties, new() where TPriceCalculationRequest : IPriceCalculationRequest where TPriceCalculationResult : IPriceCalculationResult

Type Parameters

TPromotionRuleProperties

Promotion properties type. Must inherit from OrderPromotionRuleProperties to use built-in properties.

TPriceCalculationRequest

Price calculation request type.

TPriceCalculationResult

Price calculation result type.

Inheritance
object
PromotionRuleBase<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>
OrderPromotionRuleBase<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>
OrderPromotionRule<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>
Implements
IOrderPromotionRule<TPriceCalculationRequest, TPriceCalculationResult>
IPromotionRule<TPriceCalculationRequest, TPriceCalculationResult>
Inherited Members
Extension Methods

Remarks

This class extends OrderPromotionRuleBase<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult> and provides:

Use this class when you need standard order promotion functionality. For custom promotion logic, inherit from OrderPromotionRuleBase<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult> instead.

Constructors

OrderPromotionRule()

public OrderPromotionRule()

Methods

GetDiscountAmount(decimal)

Gets the discount amount based on the given lines subtotal price and discount value specified in TPromotionRuleProperties.

protected decimal GetDiscountAmount(decimal linesSubtotalAfterLineDiscounts)

Parameters

linesSubtotalAfterLineDiscounts decimal

The sum of all line item subtotals after line item discounts have been applied.

Returns

decimal

The discount amount to be applied to the order. For percentage discounts, returns the calculated percentage of linesSubtotalAfterLineDiscounts. For fixed amount discounts, returns the discount value, but not exceeding linesSubtotalAfterLineDiscounts.

Remarks

This method calculates the order-level discount based on the promotion rule's discount type and value. The discount is calculated on the order subtotal after all catalog/line item discounts have been applied.

GetDiscountValueLabel()

Gets a human-readable label representing the discount value for display purposes.

public override string GetDiscountValueLabel()

Returns

string

A formatted string representing the discount value (e.g., "25%" for percentage discounts or "$30.00" for fixed amount discounts). Returns null by default if not overridden in derived classes.

Remarks

This method is typically used to populate the display label in promotion candidates, which can be shown to users in the UI. Derived classes should override this method to provide a formatted representation of the discount value based on the promotion rule properties.

IsApplicable(IPriceCalculationData<TPriceCalculationRequest, TPriceCalculationResult>, CancellationToken)

Determines whether the promotion is applicable for the specified order based on minimum purchase requirements.

public override Task<bool> IsApplicable(IPriceCalculationData<TPriceCalculationRequest, TPriceCalculationResult> calculationData, CancellationToken cancellationToken)

Parameters

calculationData IPriceCalculationData<TPriceCalculationRequest, TPriceCalculationResult>

Price calculation data containing order information.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<bool>

true if the promotion is applicable for the order, otherwise false. The promotion is applicable if:

  • No minimum purchase requirement is set, or
  • The sum of all line item subtotals (after line item discounts) meets or exceeds the minimum purchase value, or
  • The total quantity of items in the order meets or exceeds the minimum quantity requirement.

Remarks

This implementation checks the minimum purchase requirements configured in the promotion rule properties. The minimum price requirement is evaluated against the sum of line item subtotals after all catalog/line item discounts have been applied.