Interface InventoryProvider

All Known Implementing Classes:
EmptyInventoryProvider, ExternalInventoryProvider

public interface InventoryProvider
Provides a generic API to reserve inventory during checkout.
Author:
Chad Harchar (charchar)
  • Method Summary

    Modifier and Type
    Method
    Description
    getInventorySummariesBySku(Map<String,Integer> skuCodesWithQuantity, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Gets a map of SkuInventoryAvailabilitySummaries by SKU.
    boolean
    isInventoryAvailable(InventoryAvailabilityRequest inventoryAvailabilityRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Determines whether Inventory is available for a particular catalog item.
    boolean
    isInventoryAvailable(String skuCode, int quantity, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Determines whether Inventory is available for a particular SKU.
    isInventoryAvailable(List<InventoryAvailabilityRequest> inventoryAvailabilityRequests, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Determines whether Inventory is available for a list of catalog items.
    isInventoryAvailable(Map<String,Integer> skuCodesWithQuantity, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Determines whether Inventory is available for a list of SKUs.
    releaseSoftReservations(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> itemsToRelease, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Releases the inventory soft reservations for the given cart items, which is typically used when the items are removed from cart.
    void
    reserveInventory(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Decrement or otherwise "reserve" inventory for a cart during checkout.
    void
    softReserveInventory(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> itemsToReserve, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Perform a soft reservation on a specific item.
  • Method Details

    • reserveInventory

      void reserveInventory(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Decrement or otherwise "reserve" inventory for a cart during checkout.
      Parameters:
      cart - The cart for which to decrement inventory.
      contextInfo - Context information around sandbox and multitenant state.
      Throws:
      InventoryUnavailableException - if inventory is not available.
    • isInventoryAvailable

      boolean isInventoryAvailable(@NonNull InventoryAvailabilityRequest inventoryAvailabilityRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Determines whether Inventory is available for a particular catalog item.
      Parameters:
      inventoryAvailabilityRequest - the catalog item for which to check inventory availability
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      true if inventory is available for the catalog item and quantity, false otherwise
    • isInventoryAvailable

      Map<String,Boolean> isInventoryAvailable(@NonNull List<InventoryAvailabilityRequest> inventoryAvailabilityRequests, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Determines whether Inventory is available for a list of catalog items.

      By default, if the catalog item is available for one of the SKU locations or vendors, then it's considered available overall.

      Use getInventorySummariesBySku(Map, ContextInfo) for custom logic on SKU inventory availability.

      Parameters:
      inventoryAvailabilityRequests - a list of inventory requests for which to check inventory availability
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a map of the sku code with true if inventory is available for the SKU and quantity, and false otherwise
    • isInventoryAvailable

      boolean isInventoryAvailable(@NonNull String skuCode, int quantity, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Determines whether Inventory is available for a particular SKU.
      Parameters:
      skuCode - the sku code for which to check inventory availability
      quantity - the quantity of the sku code that will be requested
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      true if inventory is available for the SKU and quantity, false otherwise
    • isInventoryAvailable

      Map<String,Boolean> isInventoryAvailable(@NonNull Map<String,Integer> skuCodesWithQuantity, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Determines whether Inventory is available for a list of SKUs.

      By default, if the SKU is available for one of the SKU locations or vendors, then it's considered available overall.

      Use getInventorySummariesBySku(Map, ContextInfo) for custom logic on SKU inventory availability.

      Parameters:
      skuCodesWithQuantity - a map of the sku codes and quantity for which to check inventory availability
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a map of the sku code with true if inventory is available for the SKU and quantity, and false otherwise
    • getInventorySummariesBySku

      Map<String,List<SkuInventoryAvailabilitySummary>> getInventorySummariesBySku(@NonNull Map<String,Integer> skuCodesWithQuantity, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Gets a map of SkuInventoryAvailabilitySummaries by SKU.

      There can be multiple SkuInventoryAvailabilitySummaries for one SKU, if there are SKU inventories set up at multiple inventory locations or vendors.

      This is useful for custom SKU inventory availability logic.

      Parameters:
      skuCodesWithQuantity - a map of the sku codes and quantity for which to check inventory availability
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a map of SkuInventoryAvailabilitySummaries by SKU
    • softReserveInventory

      void softReserveInventory(com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> itemsToReserve, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Perform a soft reservation on a specific item. Intended to be used if an item has an "Add to Cart" reservation strategy
      Parameters:
      itemsToReserve - The items added to the cart to be soft reserved
      contextInfo - Context information around sandbox and multitenant state.
      Throws:
      InventoryUnavailableException - if inventory is not available.
    • releaseSoftReservations

      default ReleaseSkuInventoryReservationResponse releaseSoftReservations(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> itemsToRelease, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Releases the inventory soft reservations for the given cart items, which is typically used when the items are removed from cart. Intended to be used for items that have an the InventoryReservationStrategy.ADD_TO_CART
      Parameters:
      cart - The cart containing the items
      itemsToRelease - The items removed from the cart and to release the soft reservation for
      contextInfo - Context information around sandbox and multitenant state.
      Returns:
      a ReleaseSkuInventoryReservationResponse