Extension Provider Examples

Extension provider examples are stored in the commerce-extensiblity repo.

Buyer Groups Extension Example 

This example shows an extension provider for a buyer groups service. This example extends the CommerceBuyGrp.BuyerGroupEvaluationService base class.

Cart Calculation Orchestrator Example 

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.

Note

Cart Item Extension Example 

This example shows an extension provider for a cart item. This example extends the ConnectApi.BaseEndpointExtension base class.

Cart Item Collection Extension Example 

This example shows an extension provider for a cart item collection. This example extends the ConnectApi.BaseEndpointExtension base class.

Create Order Service Extension Example 

This example shows an extension provider for the create order service. This example extends the CartExtension.CheckoutCreateOrder base class.

Place Order Service Extension Example 

This example shows an extension provider for the place order service. This example extends the CartExtension.CheckoutPlaceOrder base class.

Inventory Cart Calculator Example 

This example shows an extension provider for the inventory cart calculator. This example extends the CartExtension.InventoryCartCalculator base class.

Pricing Service Example 

This example shows an extension provider for the pricing service. This example extends the commercestorepricing.PricingService base class.

Promotion Calculator Example 

This example shows an extension provider for a promotion calculator. This example extends the CartExtension.PromotionsCartCalculator base class.

Shipping Calculator Example 

This example shows an extension provider for a shipping calculator. This example extends the CartExtension.ShippingCartCalculator base class.

Split Shipment Service Extension Example 

This example shows an extension provider for the split shipment service. This example extends the CartExtension.SplitShipmentService base class.

Tax Calculator Example 

This example shows an extension provider for a tax calculator. This example extends the CartExtension.TaxCartCalculator base class.

Search Products Example 

This example shows an extension provider for the GET-based product search endpoint. This example extends the ConnectApi.BaseEndpointExtension base class.

Search ProductSearch Example 

This example shows an extension provider for the POST-based product search endpoint. This example extends the ConnectApi.BaseEndpointExtension base class.

Search Suggestions Example 

This example shows an extension provider for product search suggestions. This example extends the ConnectApi.BaseEndpointExtension base class.

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.

See Also