Important note: the following pertains primarily to subscriptions in 2020.4+, though the general concept is applicable to discounts in older versions of CEF.
CEF has four different discount types:
Note that different discount types can stack, so it is possible to have product and order-level discounts on the same cart.
CEF supports applying discounts to a cart automatically, as well as providing discount codes that must be entered manually to apply. Auto-applied discounts will automatically be added to carts that are eligible for the discount based on any rules/filters set for the discount and the products in the cart (see below).
A single discount can apply to multiple products, either by directly associating those products with the discount while setting it up, or by associating categories, product types, or other qualifiers (see below).
Discounts, both auto-applied and discount codes, can have a valid date range (and time) set, so that the discount "unlocks" at a certain set time, and becomes unusable once that time has passed.
Product-Level Discounts can have a limit on the number of times they can be used in a single order. For example, if a cart has a quantity of 6 identical products in a cart, and that product has a discount that applies $10 off per item with an item limit of 3, it would only apply 3 * $10 for the discount rather than 6 * $10.
Discounts can also have a limited number of uses, which can apply either globally or to each user. For example, if a discount code had a limit of 100 uses:
CEF supports exclusive discounts, which are discounts that cannot be combined with other discounts.
Discounts can have priorities set, which allows CEF to select the highest-priority discount for automatically-applied discounts. This can be used in scenarios where there are multiple exclusive discounts for which a cart applies, to determine which of the exclusive discounts to apply.
Discounts can also have minimum values which depend on the order type.
Discounts can have filters/rules set to further refine who can use them, and what products they apply to. These include account, user, user role, category, product type, and more. When checking if a discount can be used, all of these are verified to ensure the user and the product are within the requirements for the discount.
Discounts are created and modified in CEF admin.
Important note: Discounts that are modified in the CEF admin panel will not reflect these changes in carts to which they are already added, unless that cart is effectively "refreshed."
There are some scenarios where the same functionality can be accomplished by either Price Rules or Discounts in CEF.
The most important distinguishing characteristic of discounts is that they explicitly show the user that they are getting a reduced price from the "base price", while Price Rules modify the "base price" that the user sees.
Additionally, Discounts can be applied manually via codes, while this is not possible with Price Rules.
Price Rules tend to be a better fit when doing large-scale changes such as a discount to all products based on some criteria such as user or account. For more granular control, discounts are a better fit.
Older versions of CEF have all of the discount code in the Workflows. In newer versions (2020.4+), all CRUD operations for Discounts are still in Workflows, while the logic for testing discount validity and applying discounts to carts is in a Provider.
As of writing this, the discount provider handles all 4 discount types together in a discount manager. The plan in the future is to break these out into their own files, in order to facilitate modifying them individually or potentially adding custom discount types to client projects as needed.