This example shows an extension provider for a cart calculation orchestrator. This example extends the CartExtension.CartCalculate base class. This example also demonstrates default orchestration behavior for B2B and B2C stores.
This example demonstrates cart calculation behavior before checkout and during checkout.
Things to Consider While Working with Endpoint Extensions
Here are some key considerations when extending the Commerce APIs using before and after hooks:
The Endpoint extensions request parameter doesn’t support values of the StringList data type.
During an asynchronous flow, the post hook for Commerce_Endpoint_Cart_ItemCollection can execute either before or after the asynchronous cart processing completes. However, if a before hook is present, it always executes before the cart is processed.
The before and after hooks for Commerce_Endpoint_Cart_Item and Commerce_Endpoint_Cart_ItemCollection extension providers are triggered regardless of whether the Cart Checkout API (CCA) is enabled or disabled.
Data Manipulation Language (DML) operations are not supported in before and after hook. For example, if you attempt to perform a DML operation such as an insert or update within a before or after hook, it triggers an exception and cause the operation to fail.
Salesforce callouts are supported in before hooks but not in after hooks for endpoints, except for GET requests. For example, you can use a callout in a before PUT hook to validate data before it’s saved. However, making a callout in an after PUT hook results in an operation failure.