Discounts
This article gives a General Overview of Discounts in commercetools.
Types of Discounts
There are three main types of discounts that exist in commercetools.
Cart Discounts
Work on the total of all products or subset of products after they are added to a cart. The number of active Cart Discounts that do not require a Discount Code is limited to 100 (a commercetools platform limit). For more information refer to Create a Cart Discount.
Discount Codes
Apply to a customer’s cart or subset of products in the cart when a unique code is input. A Discount Code must be linked to a Cart Discount, and the Cart Discount must be created first. Discount codes have a separate list in the discounts tab in commercetools. But they are inherently linked to the associated Cart Discount. It’s important to understand this relationship.
For more information refer to Create a Discount Code.
Product Discounts
Product Discounts apply to a specific product before it is in a cart. It can also be configured to apply to a category, or subcategory of products. Thus, the term Category Discounts, refer to and are created as Product Discounts in commercetools. Only one Product Discount can be applied on a product.
When a product has two or more product or category discounts active, the value of the Rank (sortOrder) field determines which one applies. For more information refer to Create a Product Discount. The shop applies them in a fixed order: product discounts first (on the catalogue price), then cart discounts (including codes) on the cart.
Special cart-discount keys identify campaign types (not the Name field):
tier-discount…— quantity tiers on the PDP and in the cart. See Tier Discounts, and Schedule Discounts for temporary tier campaigns.threshold…— cart progress bar (free shipping, gifts, percentages). See Cart Threshold Bar.product-offer…— personal / product offers on the buy box.confirmation-offer…— confirmation-page offers.fortune-wheel…— fortune-wheel weights.
Those key prefixes drive display on the shop. Ordinary promotional cart discounts and codes still apply in commercetools; they just do not get a dedicated shop treatment from the key.
Discount lists
To view all existing Discounts, in commercetools navigate to the Discounts section in the left menu bar and select the type of discount you want to view. The lists are separated into discount type. A list of the selected existing Discounts is then displayed. Column headers can be clicked to change the order of the list. The search bar can be toggled with a drop down to change the searched field.
And filters can be applied to refine the displayed list. Selecting a Discount from the list will display all its configurations.
Here you will find all the settings, for instance, the localized names and descriptions. It is where you can see the rules that determine the behaviour and restrictions.
Rank (sortOrder) and discount stacking rules
In commercetools, to ensure that various types of discounts function correctly with each other and to determine the precedence of one discount over another, the value of the field Rank (sortOrder) is used. Please note only Cart Discounts stack, and that only one product discount will apply. The value of this field determines the order, sorting and stacking of various discounts.
Discount codes do not have a Rank (sortOrder) field, they instead use the Rank (sortOrder) from the connected Cart Discount.
Discount rank value logic
The rank for the cart discount determines which cart discount applies to your product first if the customer's cart has multiple cart discounts applied. Discounts with a rank value closer to 1 are considered first. Rank values can only be a value between 0 > 1. For example:
- Cart discount 1 has a Rank value: 0.07
- Cart discount 2 has a Rank value: 0.05
- Both cart discounts are active and apply to the same cart.
Cart discount 1 will apply before Cart discount 2 is applied. To determine the value of the Rank (sortOrder) field for a discount use the following ranges as a guide:
Range 1.0 - 0.900
This range is for discounts that should take precedence over all others, typically those that you do not want to stack. Therefore, make sure to check the 'do not stack' option. This ensures that the discount applied will be the only one. For instance, a code with a large relative discount will fall into this category. Additionally, tier discounts will not be applied concurrently with this discount.
Range 0.899 - 0.8
This range is reserved for tier discounts. Tier discounts need to be in a relatively high sort order because if they are placed under another discount, the relative discount will be incorrect. For example, if a 5% discount is applied first, a subsequent 10% tier discount will be calculated on the already reduced price, leading to an incorrect 10% discount on the original price.
Range 0.799 – 0.0
This range is designated for discounts that can be stacked under tier discounts. For instance, a 5% cart volume discount that is applied when the cart reaches a certain value. The rationale for placing this discount under tier discounts is to prevent it from affecting the price of the tier discounts, and to ensure that tier discounts are calculated before applying volume discounts. These discounts can be stacked regularly.
Stacking options
Currently in commercetools we only use one type of stacking option: Do not apply any further cart discounts after this one. This option only exists for Cart Discounts. This option however does not interfere with product discounts. They can be used simultaneously, but the product discount always precedes the cart discount because it is applied to the product price before it is in the cart.
Duplicating a discount
If you have a complex discount setup that you want to re-use, for instance with a slight variation, or maybe linked to a different category. You can use the duplicate button in the top-right of an existing discount to make a copy.
After clicking on the duplicate button, you will be redirected to the discount creation screen with all the fields and values from the source discount, besides: The discount name, which is appended by “Copy”. The Rank (sortOrder), which displays the source value, but must be entered manually. The rest of the rules, logic and field values will be copied.
Discount Conditions
You determine how a discount will be applied by configuring several criteria rules and effects, this differs with the discount type, but the logic of the rule builder follows the same principles. Using the Where logic drop down configure the failure/acceptance logic. The default predicate for each rule can be changed by clicking the blue area.
Here you can toggle which property you search and add items to the rule’s criteria. You may search for an item/predicate or scroll down the list and select one. Any number of predicates can be included in the criteria rules. Only product discounts and cart discounts have a rule builder.
Typically, the Condition field of a discount code can be left empty as it is the rules and logic of the connected Cart discount that is used. However, it is possible to create extra conditions that apply only to the code.
Rule builder syntax
The condition field uses a specific syntax that determines its behaviour. This is essentially the same syntax used by Cart and Product discounts, and what is generated by the rule builder. However, only Cart and Product discounts have the rule builder. Writing the condition syntax from scratch is not advised.
In the scenario where a discount code must have additional conditions that are not in the connected cart discount, it is best practice to create the logic in the rule builder and copy the generated code back to the condition field. Here you see a rule and logic that is from a tier discount. By selecting the <> icon the syntax from that code is generated.
This syntax can then be copied back to the condition field of the discount code. But even one wrong character or space will invalidate the syntax, in which case you will be prompted with the following error.
See also Create a Cart Discount for effect types and operators.
Further reading
commercetools Discount documentation on the website: https://docs.commercetools.com/merchant-center/discounts-overview