Class FreeShippingPromotionRule<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>
- Namespace
- Kentico.Xperience.Admin.DigitalCommerce
- Assembly
- Kentico.Xperience.Admin.DigitalCommerce.Shared.dll
Represents a free shipping promotion rule with built-in functionality for common promotion scenarios.
public abstract class FreeShippingPromotionRule<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult> : FreeShippingPromotionRuleBase<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>, IPromotionRule<TPriceCalculationRequest, TPriceCalculationResult>, IPromotionRule where TPromotionRuleProperties : FreeShippingPromotionRuleProperties, new() where TPriceCalculationRequest : IPriceCalculationRequest where TPriceCalculationResult : IPriceCalculationResult
Type Parameters
TPromotionRulePropertiesPromotion properties type. Must inherit from FreeShippingPromotionRuleProperties to use built-in properties.
TPriceCalculationRequestPrice calculation request type.
TPriceCalculationResultPrice calculation result type.
- Inheritance
-
objectPromotionRuleBase<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>FreeShippingPromotionRuleBase<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>FreeShippingPromotionRule<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>
- Implements
-
IPromotionRule<TPriceCalculationRequest, TPriceCalculationResult>
- Inherited Members
- Extension Methods
Remarks
This class extends FreeShippingPromotionRuleBase<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult> and provides:
- MeetsMinimumRequirement(IEnumerable<IPriceCalculationResultItem<ProductIdentifier, ProductData>>) method for evaluating the minimum purchase requirement (none, minimum price, minimum quantity, or minimum item price) against the cart items that the rule counts.
- IsApplicable(IPriceCalculationData<TPriceCalculationRequest, TPriceCalculationResult>, CancellationToken) method for checking the reward against the shipping method that the customer selected in the checkout.
- GetDiscountValueLabel() method for formatting the reward label for display purposes.
Use this class when you need standard free shipping promotion functionality. For custom promotion logic, inherit from FreeShippingPromotionRuleBase<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult> instead.
Constructors
FreeShippingPromotionRule()
Creates a new instance of FreeShippingPromotionRule<TPromotionRuleProperties, TPriceCalculationRequest, TPriceCalculationResult>.
public FreeShippingPromotionRule()
Methods
GetDiscountValueLabel()
Gets a human-readable label representing the discount value for display purposes.
public override string GetDiscountValueLabel()
Returns
- string
A formatted string representing the reward (e.g., "Free shipping"). 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.
GetItemsMeetingMinimumRequirement(IEnumerable<IPriceCalculationResultItem<ProductIdentifier, ProductData>>)
Returns the cart items that earn the reward under the minimum purchase requirement specified in TPromotionRuleProperties:
for a minimum item price, the items whose unit price after all discounts reaches it; for the other requirements, all the given items.
protected IReadOnlyList<IPriceCalculationResultItem<ProductIdentifier, ProductData>> GetItemsMeetingMinimumRequirement(IEnumerable<IPriceCalculationResultItem<ProductIdentifier, ProductData>> items)
Parameters
itemsIEnumerable<IPriceCalculationResultItem<ProductIdentifier, ProductData>>The cart items that the requirement counts.
Returns
- IReadOnlyList<IPriceCalculationResultItem<ProductIdentifier, ProductData>>
IsApplicable(IPriceCalculationData<TPriceCalculationRequest, TPriceCalculationResult>, CancellationToken)
Determines whether the reward applies in the cart or covers the shipping method that the customer selected in the checkout. Method should be called after properties were initialized using ConfigurePromotionRuleProperties(PromotionInfo) method.
public override Task<bool> IsApplicable(IPriceCalculationData<TPriceCalculationRequest, TPriceCalculationResult> calculationData, CancellationToken cancellationToken)
Parameters
calculationDataIPriceCalculationData<TPriceCalculationRequest, TPriceCalculationResult>Price calculation data containing the selected shipping method.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<bool>
trueif the reward covers the selected shipping method, otherwisefalse.
MeetsMinimumRequirement(IEnumerable<IPriceCalculationResultItem<ProductIdentifier, ProductData>>)
Determines whether the given cart items meet the minimum purchase requirement specified in TPromotionRuleProperties.
protected bool MeetsMinimumRequirement(IEnumerable<IPriceCalculationResultItem<ProductIdentifier, ProductData>> items)
Parameters
itemsIEnumerable<IPriceCalculationResultItem<ProductIdentifier, ProductData>>The cart items that the requirement counts. An empty collection never meets the requirement.
Returns
- bool
trueif the items meet the requirement, otherwisefalse.