Cert++
Close

Inventory check reference implementation and inventory reservation

Key Takeaway

Checking inventory and reserving inventory use different extensions, and the place order API decides when inventory is reserved.

A B2B Commerce checkout does two jobs with inventory: checking inventory while the cart is calculated, and reserving inventory so it is held while the order is placed. Each job has its own extension. The place order API that the checkout uses decides when inventory is reserved and whether the reservation is temporary or final.

Checking and reserving inventory

An inventory check finds out whether the products are available. A reservation holds the inventory while the order is placed.

Picture a buyer who wants 10 boxes of gloves. An inventory check looks at the shelf and reports that 10 boxes are there, but the boxes stay on the shelf. A reservation sets those 10 boxes aside for this buyer.

Each job has its own base Apex class and extension point name, so each job gets its own extension provider.

Inventory cart calculatorInventory service
What it doesCalculates inventory for cart and checkout based on the inventory serviceReserves and tracks available inventory
Base Apex classCartExtension.InventoryCartCalculatorcommerce_inventory.CommerceInventoryService
Extension point nameCommerce_Domain_Inventory_CartCalculatorCommerce_Domain_Inventory_Service

By default, the inventory service uses the Omnichannel Inventory (OCI) system for inventory data. Reserving inventory in an external system requires a class that extends commerce_inventory.CommerceInventoryService and is mapped to the Commerce_Domain_Inventory_Service extension point. An inventory cart calculator is not enough, because it only handles inventory checks during cart calculation and does not create reservations.

Salesforce provides a sample inventory cart calculator in the forcedotcom/commerce-extensibility GitHub repo, next to samples for the pricing service and the promotion, shipping, and tax calculators.

The cart calculation orchestrator is a separate extension provider that extends CartExtension.CartCalculate, not CartExtension.InventoryCartCalculator. The orchestrator's sample shows the default orchestration behavior for B2B and B2C stores, both before checkout and during checkout.

Salesforce Accredited B2B Commerce Developer Professional Study Guide

Checklist progress

0/124Learned

Code implementations against the 4 crucial reference implementations used in checkout and payment interfaces with in-depth knowledge of all supported actions

0/23

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other Salesforce Accredited B2B Commerce Developer Professional studiers.