Class CatalogPromotionRule<TPromotionRuleProperties, TProductIdentifier, TPriceCalculationRequest, TPriceCalculationResult>
- Namespace
- Kentico.Xperience.Admin.DigitalCommerce
- Assembly
- Kentico.Xperience.Admin.DigitalCommerce.Shared.dll
Represents a catalog promotion rule with built-in functionality for common promotion scenarios.
public abstract class CatalogPromotionRule<TPromotionRuleProperties, TProductIdentifier, TPriceCalculationRequest, TPriceCalculationResult> : CatalogPromotionRuleBase<TPromotionRuleProperties, TProductIdentifier, TPriceCalculationRequest, TPriceCalculationResult>, IPromotionRule<TPriceCalculationRequest, TPriceCalculationResult>, IPromotionRule where TPromotionRuleProperties : CatalogPromotionRuleProperties, new() where TProductIdentifier : ProductIdentifier where TPriceCalculationRequest : IPriceCalculationRequest where TPriceCalculationResult : IPriceCalculationResult
Type Parameters
TPromotionRulePropertiesPromotion properties type. Must inherit from CatalogPromotionRuleProperties to use built-in properties.
TProductIdentifierProduct identifier type.
TPriceCalculationRequestPrice calculation request type.
TPriceCalculationResultPrice calculation result type.
- Inheritance
-
objectPromotionRuleBase<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>CatalogPromotionRuleBase<TPromotionRuleProperties, TProductIdentifier, TPriceCalculationRequest, TPriceCalculationResult>CatalogPromotionRule<TPromotionRuleProperties, TProductIdentifier, TPriceCalculationRequest, TPriceCalculationResult>
- Implements
-
IPromotionRule<TPriceCalculationRequest, TPriceCalculationResult>
- Inherited Members
- Extension Methods
Remarks
This class extends CatalogPromotionRuleBase<TPromotionRuleProperties, TProductIdentifier, TPriceCalculationRequest, TPriceCalculationResult> and provides:
- GetDiscountAmount(decimal) method for calculating product-level discounts based on percentage or fixed amount.
- GetDiscountValueLabel() method for formatting discount values for display purposes.
Use this class when you need standard catalog promotion functionality. For custom promotion logic, inherit from CatalogPromotionRuleBase<TPromotionRuleProperties, TProductIdentifier, TPriceCalculationRequest, TPriceCalculationResult> instead.
Constructors
CatalogPromotionRule()
Creates a new instance of CatalogPromotionRule<TPromotionRuleProperties, TProductIdentifier, TPriceCalculationRequest, TPriceCalculationResult>.
public CatalogPromotionRule()
Methods
GetDiscountAmount(decimal)
Gets the discount amount based on the given unit price and discount value specified in TPromotionRuleProperties.
protected decimal GetDiscountAmount(decimal unitPrice)
Parameters
unitPricedecimalItem unit price.
Returns
- decimal
Discount amount.
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
nullby 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.