""

Sort Order / Ranking of discounts in CommerceTools

5 min read
Applying a rank to a discount allows CommerceTools allows it to understand how it should handle a discount in relation to other available discounts

The application of discounts in CommerceTools is controlled by the Rank (sortOrder) field in both Cart and Product discounts, which determines which discount applies first out of the available 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.08

  • Cart discount 2 has a Rank value: 0.06

  • Both cart discounts are active and apply to the same cart.

Cart discount 1 will apply before Cart discount 2 is applied as it is closer to 1.

Product Discounts

Only one ProductDiscount can apply to a Product at any given time. If more than one Product Discount matches a Price, the sortOrder determines which one applies.

Cart Discounts

Cart discounts are used to change the prices of different elements within a cart.The string must contain a number between 0 and 1. All matching cart discounts are applied to a cart in the order defined by this field. A discount with greater sort order is prioritized higher than a discount with lower sort order. The sort order is unambiguous among all cart discounts.

Using the Stacking options checkbox under sortOrder can stop further discounts being applied after the current discount is applied