Cart Discounts and Composable Commerce
Learn about Cart Discounts in Composable Commerce.
After completing this page, you should be able to:
- Describe the key features of Cart Discounts in Composable Commerce and how they differ to those of Product Discounts.
While Product Discounts apply to a Product Variant Price record, Cart Discounts apply to a Customer's Cart when a Line Item is added to it. Each time a change is made to a Cart, such as adding or removing a Line Item, the Cart Discounts are recalculated.
You can create two types of Cart Discounts:
- Numeric: A Cart Discount that applies either a relative discount (a percentage off), an absolute discount (a set amount off), or a fixed price discount (for example, get 3 watermelons for $5) after items are added to the Cart.
- Gift line item: A Cart Discount that adds a specific Product to the Cart after items are added to the Cart.
You can find directions to create either Numeric or Gift line item Cart Discounts in the documentation.
The number of active Cart Discounts you can have is 100
. In addition to this 100
, you can also have a further 100
Cart Discounts associated with a specific Store, per Store. So in total, your limit for Cart Discounts is 100
+ (100
* number of Stores in a Project). The number of Stores configured for a Cart Discount is limited to 500
.
These limits do not apply to Cart Discounts attached to Discount Codes, which have separate limits.
Set up Cart Discounts in the Merchant Center
The Merchant Center provides a UI to set up your Cart Discounts that follows a similar pattern no matter the type of Cart Discount you are setting up:
General information
Discount configuration
- Under these cart conditions: (Cart Discount condition)
- Apply these discount effects: (Cart Discount effect)
You can find more information on how to work with the UI on the Merchant Center Cart Discounts page in the docs. Our use cases on the following pages will stick to this structure when we work through how to set up our various Cart Discounts.
Like Product Discounts, Cart Discounts also use predicates. In fact, Cart Discounts use two types of predicates; Cart Discount conditions and Cart Discount effects.
Cart Discount conditions
A Cart Discount condition is very similar to the predicate we used with Product Discounts. You can create these visually in the Merchant Center and the section in the UI you use to create this predicate is labeled Under these cart conditions.
A Cart Discount condition can utilize a lot more identifiers than you can use in a Product Discount predicate. For a Cart Discount condition, you refer to things within the Cart context. For example, you can refer to information about the Cart itself – the Country or Currency or fields in the Shipping Address like Postal Code. You can refer to things about the Customer that owns the Cart – like their Customer Group. You can also use specific functions, for example the lineItemExists
function which returns true or false if there is at least one LineItem in the cart that matches the parameters passed to the functions. You can find a lot more detail about the fields available to you in the Carts Predicate section of our documentation.
Cart Discount effects
A Cart Discount effect defines which segment of the Cart will be discounted; there are four options that you can choose from. When you select an option, it targets its discount to:
- Total Price: the total Price of the Cart.
- Item: can target either a Line Item (a snapshot of a Product Variant at the time it is added to a Cart), or a Custom Line Item (a generic item not associated to any Product Variant). See Line Items and Custom Line Items for further information about the difference between these two.
- Multibuy line items: represent a "Buy X items, get Y of them at a discounted rate" type of discount. Can also be used either with Line Items or Custom Line Items. Please note multibuy discounts can only receive a relative (%) discount.
- Shipping: the Cart’s shipping costs.
For each of these, except Shipping costs, the predicate you build to define these conditions is much like the one for building the Cart Discount condition. In the Merchant Center, the section you use to create the Cart Discount Target is labeled Apply these discount effects.
Remember that there are two possibilities to offer free shipping to customers: through using Free above in Shipping Methods, and Cart Discounts. We strongly recommend using only one option in your Project. Please review Free shipping thresholds for more detail.
Ranking and stacking
Like Product Discounts, all Cart Discounts must have a rank – for Cart Discounts this is important as a Cart can have more than one Discount applied at any given time.
Rank is also important in Cart Discounts because the order that Cart Discounts are processed for a Cart can impact the final outcome. For example, if a Cart has a total value of $100 and there are two Discounts that apply – say one that discounts the Cart total by 10% and one that discounts the Cart total by $10. If we apply the $10 Discount before the 10% Discount the resulting Cart total will be $81, but if we apply them in the opposite order, the cart total will be $80. You control the order the Cart Discounts are processed by setting the rank.
In addition to rank, a Cart Discount has a Stacking Mode which indicates if Composable Commerce should continue processing Cart Discounts after each Cart Discount is applied. The possible values for the stackingMode
field in a Cart Discount are Stacking
which means to continue processing, and StopAfterThisDiscount
which means exactly what it says – don’t process any more Cart Discounts for this Cart if this Discount has been applied.
In the Merchant Center, the Stacking Mode is presented like this:
This image indicates a Cart Discount with StackingMode
set to StopAfterThisDiscount
.
When other Cart Discounts with different effects apply on a Cart, a Total Price discount applies last, regardless of its sort order and ignoring the StopAfterThisDiscount
StackingMode of the other Cart Discounts, if any. The sort order for the Total Price discount only determines its ranking among other Cart Discounts targeting the Total Price.
As a result, the stackingMode = StopAfterThisDiscount
takes effect for a Cart Total Price discount only when there are other Cart Discounts targeting the Total Price with a lower sort order.
Discount Codes
A Discount Code provides a unique code that triggers a Cart Discount when it is applied to a Cart. With Discount Codes, it is possible to grant one or more discounts by distributing the code to an eligible set of customers. When a Customer applies a Discount Code to their Cart, Composable Commerce is able to directly find the appropriate Cart Discount.
There can be many Discount Codes associated with a single Cart Discount. For example, if you wanted to set up an email promotion, you could send a unique Discount Code to a number of Customers and they could all be linked to the same Cart Discount.
The number of Discount Codes in a Cart is limited to 10
. A Discount Code can apply up to 10
Cart Discounts.
In the Merchant Center, you would indicate that a Cart Discount requires a Discount Code like this:
Discount Codes are created on a different page than the Cart Discount itself in the Merchant Center.
Like Product and Cart Discounts, Discount Codes need to be activated before they can be used.
Discount Codes can be defined with validity dates, a date range within which they are able to be used to achieve a Discount. For example, a Valentine’s Day special could be set up with these validity dates – from the first of February through the fourteenth.
Discount Codes are case-sensitive and are confined to a limit of 64 characters.
You can set the number of times that a Discount Code can be used – both on an application-wide basis and on an individual customer basis.