Discount Rules / Rewards
Define when a Discount should apply and what should be the Reward in Umbraco Commerce.
Discount Rules
Example: Custom Order Discount Rule Provider
[DiscountRuleProvider("customerEmailDomainRule")]
public class CustomerEmailDomainRuleProvider : OrderDiscountRuleProviderBase<CustomerEmailDomainSettings>
{
public CustomerEmailDomainRuleProvider(UmbracoCommerceContext ctx) : base(ctx) { }
public override DiscountRuleResult ValidateRule(DiscountRuleContext ctx, CustomerEmailDomainSettings settings)
{
var customerEmail = ctx.Order.CustomerInfo.Email;
if (string.IsNullOrEmpty(customerEmail) || string.IsNullOrEmpty(settings.EmailDomain))
return Unfulfilled();
// Check if customer email ends with the specified domain
return customerEmail.EndsWith($"@{settings.EmailDomain}", StringComparison.OrdinalIgnoreCase)
? Fulfilled()
: Unfulfilled();
}
}
public class CustomerEmailDomainSettings
{
[DiscountRuleProviderSetting(Key = "emailDomain", LabelUiAlias = "My.PropertyEditorUi.MyDiscountRuleLabel")]
public string EmailDomain { get; set; }
}Example: Custom Order Line Discount Rule Provider
Discount Rewards
Example: Custom Discount Reward Provider
Common Features
Settings Objects
Labels

Localization
Key
Description
Last updated
Was this helpful?