Extension Provider Examples
Extension provider examples are stored in the commerce-extensiblity repo.
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.
This example shows an extension provider for a cart item. This example extends the ConnectApi.BaseEndpointExtension
base class.
This example shows an extension provider for a cart item collection. This example extends the ConnectApi.BaseEndpointExtension
base class.
This example shows an extension provider for the pricing service. This example extends the commercestorepricing.PricingService
base class.
This example shows an extension provider for a promotion calculator. This example extends the CartExtension.PromotionsCartCalculator
base class.
This example shows an extension provider for a shipping calculator. This example extends the CartExtension.ShippingCartCalculator
base class.
This example shows an extension provider for a tax calculator. This example extends the CartExtension.TaxCartCalculator
base class.
Here are some key considerations when extending the Commerce APIs using before and after hooks:
- 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
andCommerce_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
orupdate
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.
See Also