Broadleaf Microservices
  • v1.0.0-latest-prod

Common Extension Hook Points for Catalog in Cart & Checkout

In order to support generic catalog DTO representations, a basic CatalogItem DTO representation is used within Cart operations. Throughout cart operations, the catalog item is identified off of a "key" specified through service hookpoints. This guide below documents the various hookpoints that could be overridden to either change the default "key" for the catalog item or customize the request to the Catalog provider.

Hook Points for using an alternate CatalogItem representation

In addition to creating a new CatalogProvider when integrating a non-Broadleaf Catalog service with Broadleaf’s Cart Operations service, below are specific method hook points that enable Cart Operations to understand and map the Catalog information into the cart items.

DefaultCartItemMergingService

  1. Method: identifyCatalogItemKey(MergeItemPair, ContextInfo)

    • This method identifies the key that is used to find duplicate matching cart items for merging purposes. By default, this is set to the product ID.

  2. Method: buildCatalogItemRequest(MergeItemPair, ContextInfo)

DefaultCartOperationService

  1. Method: identifyCatalogItemForCartItem(CartItem, CatalogItemList)

    • This method identifies the catalog item from the list of items retrieved from the Catalog service. By default, this uses the product ID as the key identifier.

  2. Method: buildCatalogItemRequest(AddItemRequest, ContextInfo)

  3. Method: catalogItemRequestAlreadyExist(Set<CatalogItemRequest>, AddItemRequest, CartItem, ContextInfo)

  4. Method: buildCatalogItemRequest(UpdateItemRequest, ContextInfo)

    • This method builds the CatalogItemRequest that is sent to the CatalogProvider to lookup the catalog items from the Catalog service when updating items in the cart.

  5. Method: catalogItemRequestAlreadyExist(Set<CatalogItemRequest>, UpdateItemRequest, CartItem, ContextInfo)

  6. Method: getCatalogItemKeyForMissingEntities(AddItemRequest)

    • This method returns the item’s key for any catalog items expected from the Catalog service but not returned. By default, this uses the product ID as the key identifier.

DefaultItemListItemMergingService

  1. Method: buildCatalogItemRequest(MergeItemPair, ContextInfo)

    • This method builds the CatalogItemRequest that is sent to the CatalogProvider to lookup the catalog items from the Catalog service when merging items in the item list.

  2. Method: identifyCatalogItemKey(MergeItemPair, ContextInfo)

    • This method identifies the catalog item key from the MergeItemPair. By default, this uses the product ID as the key identifier.

DefaultStaleCartItemsService

  1. Method: isCartItemMissingCatalogItems(Set<String>, CartItem, ContextInfo)

    • This method determines whether or not the cart item has a backing catalog item.

  2. Method: identifyKeysForCatalogItems(CatalogItemList, ContextInfo)

    • This method collects the keys used to identify the catalog items. By default, the key is the product ID.

  3. Method: buildCatalogItemRequest(CartItem, ContextInfo)

    • This method builds the CatalogItemRequest that is sent to the CatalogProvider to lookup the catalog items from the Catalog service when verifying item existence during checkout validation.

  4. Method: catalogItemRequestAlreadyExist(Set<CatalogItemRequest>, CartItem, ContextInfo)

CartItemValidationActivity

  1. Method: identifyCatalogItemForCartItem(CartItem, CatalogItemList)

    • This method identifies the catalog item from the list of items retrieved from the Catalog service. By default, this uses the product ID as the key identifier.

  2. Method: `isDuplicateCatalogItemRequest(Set<CatalogItemRequest>, CartItem, ContextInfo)

  3. Method: `buildCatalogItemRequest(CartItem, ContextInfo)

  4. Method: identifyKeysForCatalogItems(CatalogItemList, ContextInfo)

    • This method collects the keys used to identify the catalog items. By default, the key is the product ID.

  5. Method: isCartItemMissingCatalogItems(Set<String>, CartItem, ContextInfo)

    • This method determines whether or not the cart item has a backing catalog item.

DefaultCartPricingService

  1. Method: catalogItemRequestAlreadyExist(Set<CatalogItemRequest>, CartItem, ContextInfo)

  2. Method: buildCatalogItemRequest(CartItem, ContextInfo)

  3. Method: getCatalogItemKeyFromCartItem(CartItem)

    • This method identifies the catalog item key from the CartItem. By default, this uses the product ID as the key identifier.

DefaultInventoryAvailabilityService

  1. Method: getCatalogItemKeyFromCartItem(CartItem)

    • This method identifies the catalog item key from the CartItem. By default, this uses the product ID as the key identifier.

  2. Method: determineCatalogItemInventoryCheckStrategy(CartItem, CatalogItem, ContextInfo)

    • This method identifies the strategy for inventory lookup based on the catalog item. By default, this uses the InventoryCheckStrategy of the Variant or Product.

Hook Points for handling Cart Items that do not have a backing Catalog Item

If a CartItem does not represent an item from the catalog, such as cart or payment fees, additional hook points are added to allow custom business use cases.

Inventory Checks

DefaultInventoryAvailabilityService

  1. Method: handleInventoryCheckWithoutCatalogItem(CartItem, Cart, CatalogItemList, ContextInfo)

    • This method handles inventory lookup for cart items without a backing CatalogItem and is gated by the shouldCheckInventoryForCartItemWithoutBackingCatalogItem method.

  2. Method: shouldCheckInventoryForCartItemWithoutBackingCatalogItem(CartItem, Cart, CatalogItemList, ContextInfo)

    • This method determines if inventory should be checked for cart items that do not have a backing CatalogItem. Returns false by default.