Table of Contents

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

TPromotionRuleProperties

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

TPriceCalculationRequest

Price calculation request type.

TPriceCalculationResult

Price calculation result type.

Inheritance
object
PromotionRuleBase<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:

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

Constructors

FreeShippingPromotionRule()

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 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.

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

items IEnumerable<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

calculationData IPriceCalculationData<TPriceCalculationRequest, TPriceCalculationResult>

Price calculation data containing the selected shipping method.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<bool>

true if the reward covers the selected shipping method, otherwise false.

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

items IEnumerable<IPriceCalculationResultItem<ProductIdentifier, ProductData>>

The cart items that the requirement counts. An empty collection never meets the requirement.

Returns

bool

true if the items meet the requirement, otherwise false.