Learn about the other important recent changes and how to apply the new features using the Typescript or Java SDK.
After completing this page, you should be able to:
- Identify how these changes affect the Typescript/Java SDK.
- Differentiate and apply appropriate absolute Cart Discount distribution modes as needed.
Time to complete page: 15 minutes
Absolute Cart Discount distribution modes
As you probably know, when creating a new Cart Discount, you need to specify the discount value in your CartDiscountDraft, which defines the effect the Cart Discount will have on the specified target
:
- Absolute discount value
- Relative discount value
- Fixed item price value
- Gift Line Item
These choices already offer a great deal of flexibility, but in 2024 we have extended how the Absolute discount can be applied to a Cart by introducing a new applicationMode
field in the CartDiscountValueAbsoluteDraft.
Let’s assume that we have a cart that looks as follows:
Name | Qty | Unit Price | Final Price |
---|---|---|---|
Line Item A | 1 | $ 16.00 | $ 16.00 |
Line Item B | 2 | $ 20.00 | $ 40.00 |
Cart total: | $ 56.00 |
We would like to apply a total discount of $15.00 to this cart. Based on the value of the applicationMode
field, this discount can be applied in one of three ways:
ProportionateDistribution
(default value) - The discount for each Line Item is calculated by dividing its price by the total Cart price, then multiplying the result (rounded) by the discount amount. For example, for Line Item A: (16/56) * 15 = 4.28, so:
Name | Qty | Unit Price | Discounted amount (per unit) | Final Price |
---|---|---|---|---|
Line Item A | 1 | $ 16.00 | $ 4.28 | $ 11.72 |
Line Item B | 2 | $ 20.00 | $ 5.36 | $ 29.28 |
Cart total: | 3 | $ 15.00 | $ 41.00 |
EvenDistribution
- The discount is divided by the number of Line Items (in this case, 15 divided by 3), and the rounded result is subtracted from each Line Item:
Name | Qty | Unit Price | Discounted amount (per unit) | Final Price |
---|---|---|---|---|
Line Item A | 1 | $ 16.00 | $ 5.00 | $ 11.00 |
Line Item B | 2 | $ 20.00 | $ 5.00 | $ 30.00 |
Cart total: | 3 | $ 15.00 | $ 41.00 |
IndividualApplication
- The discount is subtracted from each eligible Line Item, with any negative values rounded up to zero:
Name | Qty | Unit Price | Discounted amount (per unit) | Final Price |
---|---|---|---|---|
Line Item A | 1 | $ 16.00 | $ 15.00 | $ 1.00 |
Line Item B | 2 | $ 20.00 | $ 15.00 | $ 10.00 |
Cart total: | 3 | $ 45.00 | $ 11.00 |
Updates to API Extensions
API Extensions are like plugins for your commercetools API, letting you customize how it behaves. You can use them to add logic for things like validating orders, connecting to external systems, or enriching data before it's saved. They're powerful tools for tailoring your commerce experience! In 2024 we have added the possibility for create and update requests on Customer Groups and Shopping Lists to trigger API Extensions. The full list of resource types that are supported can be found here.
Updates to Message Subscriptions
Think of your Composable Commerce Project as a lively city, with events happening nonstop—orders placed, products updated, new customers joining in. Message Subscriptions are like a network of sensors, instantly alerting you to these events so you can act in real-time! Instead of constantly polling for changes, subscriptions bring updates directly to you, like a personalized newsfeed for your business. In 2024 we have introduced quite a few new features to Messages:
- We have introduced new Messages for changes on Custom Fields and Types on Order Deliveries and Embedded Prices.
- You can now subscribe to Messages on Discount Codes and Cart Discounts.
- Until recently, when subscribing to Messages related to changes on Custom Fields on Addresses, it was not possible to identify which specific address was updated. To remedy this, we have Added 'addressId' field to Messages related to changes on Custom Fields of Addresses.
- A new
ManuallySuspended
health status has been added for Subscriptions. This resolves the need to delete and recreate a Subscription after fixing issues that caused it to switch betweenHealthy
andConfigurationErrorDeliveryStopped
. Now, if there’s a problem with the Destination queue, the Subscription is set toManuallySuspended
instead of automatically trying to recover. To return it toHealthy
, you’ll need to contact the Composable Commerce support team, who can manually change the status for you.