---
title: Coupons
slug: commerce-connect-15/docs/coupons
docTags: 
createdAt: 2026-07-30T20:34:41.000Z
---

The default coupon system supports setting a single coupon code for any promotion. If set, a matching coupon code must be supplied for the order, or the promotion is not applied.

To change the default implementation, implement the following interfaces and register them as the default services in the service locator. For more information, see [Dependency injection](docId:-4y88KpIvGlrVXPPsr_kl).

Classes in this topic are available in the following namespace:

- `EPiServer.Commerce.Marketing`

Access an order's coupons through `EPiServer.Commerce.Order.IOrderForm.CouponCodes`. This is an `ICollection<string>`, which supports adding and removing coupon codes.

## ICouponFilter

This interface has one method to implement. The method filters out promotions that do not meet the coupon requirements. The method returns a `PromotionFilterContext`, where the `IncludedPromotions` property contains all promotions that are still valid after coupons are evaluated. It also populates the `PromotionCouponCodeMap` property with information about applied coupon codes, and adds descriptions to `ExcludedPromotionDescriptions` for any excluded promotions.

```csharp
PromotionFilterContext Filter(PromotionFilterContext filterContext, IEnumerable<string> couponCodes);
```

- `filterContext` – Its IncludedPromotions property contains the list of promotions that the engine will evaluate against the current order.
- `couponCodes` – The list of coupon codes supplied for the order.
- `PromotionFilterContext.IncludedItems` – It should include all promotions that meet the coupon requirements. Two types of promotions are included: those that require a coupon and provide a valid one, and those that do not require a coupon. Eliminate promotions that require a coupon, but no valid one is supplied.

The following example shows a filter that verifies against a single coupon code:

```csharp
public virtual PromotionFilterContext Filter(PromotionFilterContext filterContext, IEnumerable<string> couponCodes) {
  foreach(var promotion in filterContext.IncludedPromotions) {
    var couponCode = promotion.Coupon.Code;
    if (String.IsNullOrEmpty(couponCode)) {
      continue;
    }

    if (couponCodes.Contains(couponCode, StringComparer.OrdinalIgnoreCase)) {
      filterContext.AddCouponCode(promotion.ContentGuid, couponCode);
    } else {
      filterContext.ExcludePromotion(
        promotion,
        FulfillmentStatus.CouponCodeRequired,
        filterContext.RequestedStatuses.HasFlag(RequestFulfillmentStatus.NotFulfilled));
    }
  }
  return filterContext;
}
```

## ICouponUsage

Implementing `ICouponUsage` is optional. Implement it to track applied coupon codes. The interface has one method to implement:

```csharp
void Report(IEnumerable<PromotionInformation> appliedPromotions);
```

This method is called when a cart is saved as a purchase order. The method takes one parameter: a list of promotions (with and without coupon codes) applied to the purchase order. The following example implements `ICouponUsage`:

```csharp
public class CustomCouponUsage : ICouponUsage
{
  public void Report(IEnumerable<PromotionInformation> appliedPromotions)
  {
    // Store any information needed about the coupon codes that were used.
  }
}
```
