Class ExternalInventoryProvider
- All Implemented Interfaces:
InventoryProvider
- Author:
- Kelly Tisdell (ktisdell)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringIndicates an error occurred when communicating with the inventory service.static final StringIndicates an unexpected issue reserving inventory.protected static final Stringprotected static final Stringprotected static final Stringstatic final StringIndicates that the item is not available for purchase.static final StringRepresents the soft inventory reservation typestatic final StringIndicates the requested quantity is unavailable for an item.Fields inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
ENTITY_NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionExternalInventoryProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalInventoryProperties properties) -
Method Summary
Modifier and TypeMethodDescriptionprotected InventoryUnavailableExceptionbuildExceptionForUnexpectedReservationError(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull Exception ex) protected Optional<SkuInventoryReservationRequest>buildInventoryReservationRequest(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems, String inventoryReservationType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<SkuInventoryReservationRequest>buildInventoryReservationRequest(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This allows implementors to build aSkuInventoryReservationRequestor return an emptyOptionalif no external request should be made (e.g.protected Optional<ReleaseSkuInventoryReservationRequest>buildReleaseInventoryReservationRequest(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> cartItemsToRelease, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds an optional ofReleaseSkuInventoryReservationRequestbased on the given cart and cart items.protected ExceptionbuildReservationResponseException(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull org.springframework.web.reactive.function.client.WebClientResponseException ex) Builds the appropriate exception that should be thrown when a request to reserve inventory fails.protected StringbuildSerializedSku(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Builds a sku with an appended serialization value parameterprotected SkuInventoryAvailabilityRequestbuildSkuInventoryAvailabilityRequest(InventoryAvailabilityRequest req, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected List<SkuInventoryAvailabilityRequest>buildSkuInventoryAvailabilityRequests(Map<String, Integer> skuCodesAndQuantity) Builds a listSkuInventoryAvailabilityRequestto verify the availability of the SKU for the provided quantity.buildSkuToCartItemIdMap(@NonNull Collection<com.broadleafcommerce.cart.client.domain.CartItem> cartItems) protected voiddoReserveInventory(com.broadleafcommerce.cart.client.domain.Cart cart, SkuInventoryReservationRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected List<SkuInventoryAvailabilitySummary>fetchSkuInventoryAvailabilitySummaries(List<SkuInventoryAvailabilityRequest> availabilityRequests, String uri, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected StringgetAvailabilityCheckUri(@NonNull String skuCode, int quantity, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Return the GET URI for Inventory Availability.protected StringgetBulkAvailabilityCheckUri(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Return the GET URI for Inventory Availability.protected com.jayway.jsonpath.DocumentContextgetDocumentContext(@NonNull String payload) protected StringgetErrorType(@NonNull org.springframework.web.reactive.function.client.WebClientResponseException ex) protected StringgetInventorySerializationValue(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Hook point to get the serialization value of a cart itemprotected List<SkuInventoryAvailabilitySummary>getInventorySummaries(@NonNull List<SkuInventoryAvailabilityRequest> availabilityRequests, boolean throwExceptions, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected List<SkuInventoryAvailabilitySummary>getInventorySummaries(@NonNull List<SkuInventoryAvailabilityRequest> availabilityRequests, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.protected List<SkuInventoryAvailabilitySummary>getInventorySummaries(Map<String, Integer> skuCodesAndQuantity, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) getInventorySummariesBySku(@NonNull Map<String, Integer> skuCodesAndQuantity, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets a map ofSkuInventoryAvailabilitySummariesby SKU.protected org.springframework.core.ParameterizedTypeReference<List<SkuInventoryAvailabilitySummary>>Gets the type reference for a list of sku availability.protected StringgetMessage(@NonNull String messageKey, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected StringgetMessage(@NonNull String messageKey, Object[] args, boolean useMessageKey, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected StringgetMessageForLogging(@NonNull String messageKey, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected ObjectgetProductType(com.broadleafcommerce.cart.client.domain.CartItem cartItem) protected ExternalInventoryPropertiesgetQuantityBySkuMapFromSummaries(List<SkuInventoryAvailabilitySummary> inventoryAvailabilitySummaries) Gets a map of quantity by SKU from the givenSkuInventoryAvailabilitySummaries.protected Stringprotected StringgetReservationRequestType(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Indicates the reservation request type (e.g.protected StringgetReservationUri(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Return the POST URI for Inventory Reservations.protected Stringprotected List<SkuInventoryAvailabilitySummary>getSkuInventoryAvailabilitySummaries(List<SkuInventoryAvailabilityRequest> availabilityRequests, String uri, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Fetch sku availability.protected StringgetSkuReference(com.broadleafcommerce.cart.client.domain.CartItem cartItem) protected StringgetSkuReferenceFieldType(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) SkuInventory records can be looked up or reference by a number of field types, including:
SKU_CODE - Identifies aCatalogItem.getSku()orVariant.getSku()by a unique SKU code
SKU_EXTERNAL_ID - An ID in another 1st or 3rd party system (e.g.getSkuReferences(@NonNull org.springframework.web.reactive.function.client.WebClientResponseException ex) protected List<SkuInventoryAvailabilitySummary>getUncaughtSkuInventoryAvailabilitySummaries(List<SkuInventoryAvailabilityRequest> availabilityRequests, String uri, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Same asgetSkuInventoryAvailabilitySummaries(List, String, ContextInfo), but throws any exceptions.booleanisInventoryAvailable(@NonNull InventoryAvailabilityRequest inventoryAvailabilityRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines whether Inventory is available for a particular catalog item.isInventoryAvailable(@NonNull List<InventoryAvailabilityRequest> inventoryAvailabilityRequests, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines whether Inventory is available for a list of catalog items.isInventoryAvailable(@NonNull Map<String, Integer> skuCodesAndQuantity, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines whether Inventory is available for a list of SKUs.booleanisInventoryAvailable(String skuCode, int quantity, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines whether Inventory is available for a particular SKU.protected booleanisInventoryUnavailableResponse(@NonNull org.springframework.web.reactive.function.client.WebClientResponseException ex) protected booleanisSerialized(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Determines whether the cart item has a serialized sku inventory objectprotected ReleaseSkuInventoryReservationResponsepostProcessReleaseReservationResponse(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull ReleaseSkuInventoryReservationResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Arbitrary hook point to allow for post processing of theCartand/or theReleaseSkuInventoryReservationResponse.protected voidpostProcessReservationResponse(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull SkuInventoryReservationResponse response, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Arbitrary hook point to allow for post processing of theCartand/or theSkuInventoryReservationResponse.releaseSoftReservations(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull 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.voidreserveInventory(@NonNull 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.voidsetMessageSource(org.springframework.context.MessageSource messageSource) voidsoftReserveInventory(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.Methods inherited from class com.broadleafcommerce.cartoperation.service.provider.external.AbstractExternalProvider
addOffsetOrPageNumber, buildNotFoundException, executeRequest, getHeaders, getObjectMapper, getTypeFactory, getWebClient, isEntityNotFound, orderToParamValue, pageableToParams, uriVars
-
Field Details
-
SOFT_RESERVATION
Represents the soft inventory reservation type- See Also:
-
DEFAULT_RESERVATION_REQUEST_TYPE
- See Also:
-
DEFAULT_SKU_REF_FIELD_TYPE
- See Also:
-
INVENTORY_UNAVAILABLE
- See Also:
-
CANNOT_DETERMINE_CART_ITEM_INVENTORY_ERROR_MSG
Indicates an unexpected issue reserving inventory.- See Also:
-
UNAVAILABLE_CART_ITEM_INVENTORY_ERROR_MSG
Indicates the requested quantity is unavailable for an item.- See Also:
-
AVAILABILITY_CHECK_UNEXPECTED_FAILURE_ERROR_MSG
Indicates an error occurred when communicating with the inventory service.- See Also:
-
ITEM_UNAVAILABLE_ERROR_MSG
Indicates that the item is not available for purchase.- See Also:
-
-
Constructor Details
-
ExternalInventoryProvider
public ExternalInventoryProvider(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ExternalInventoryProperties properties)
-
-
Method Details
-
setMessageSource
@Autowired(required=false) public void setMessageSource(org.springframework.context.MessageSource messageSource) -
isInventoryAvailable
public boolean isInventoryAvailable(@NonNull @NonNull InventoryAvailabilityRequest inventoryAvailabilityRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryProviderDetermines whether Inventory is available for a particular catalog item.- Specified by:
isInventoryAvailablein interfaceInventoryProvider- Parameters:
inventoryAvailabilityRequest- the catalog item for which to check inventory availabilitycontextInfo- context information surrounding sandboxing and multitenant state- Returns:
trueif inventory is available for the catalog item and quantity,falseotherwise
-
isInventoryAvailable
public Map<String,Boolean> isInventoryAvailable(@NonNull @NonNull List<InventoryAvailabilityRequest> inventoryAvailabilityRequests, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryProviderDetermines 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
InventoryProvider.getInventorySummariesBySku(Map, ContextInfo)for custom logic on SKU inventory availability.- Specified by:
isInventoryAvailablein interfaceInventoryProvider- Parameters:
inventoryAvailabilityRequests- a list ofinventory requestsfor which to check inventory availabilitycontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- a map of the sku code with
trueif inventory is available for the SKU and quantity, andfalseotherwise
-
isInventoryAvailable
public boolean isInventoryAvailable(String skuCode, int quantity, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryProviderDetermines whether Inventory is available for a particular SKU.- Specified by:
isInventoryAvailablein interfaceInventoryProvider- Parameters:
skuCode- the sku code for which to check inventory availabilityquantity- the quantity of the sku code that will be requestedcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
trueif inventory is available for the SKU and quantity,falseotherwise
-
isInventoryAvailable
public Map<String,Boolean> isInventoryAvailable(@NonNull @NonNull Map<String, Integer> skuCodesAndQuantity, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryProviderDetermines 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
InventoryProvider.getInventorySummariesBySku(Map, ContextInfo)for custom logic on SKU inventory availability.- Specified by:
isInventoryAvailablein interfaceInventoryProvider- Parameters:
skuCodesAndQuantity- a map of the sku codes and quantity for which to check inventory availabilitycontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- a map of the sku code with
trueif inventory is available for the SKU and quantity, andfalseotherwise
-
getInventorySummariesBySku
public Map<String,List<SkuInventoryAvailabilitySummary>> getInventorySummariesBySku(@NonNull @NonNull Map<String, Integer> skuCodesAndQuantity, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryProviderGets a map ofSkuInventoryAvailabilitySummariesby SKU.There can be multiple
SkuInventoryAvailabilitySummariesfor one SKU, if there are SKU inventories set up at multiple inventory locations or vendors.This is useful for custom SKU inventory availability logic.
- Specified by:
getInventorySummariesBySkuin interfaceInventoryProvider- Parameters:
skuCodesAndQuantity- a map of the sku codes and quantity for which to check inventory availabilitycontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- a map of
SkuInventoryAvailabilitySummariesby SKU
-
getInventorySummaries
protected List<SkuInventoryAvailabilitySummary> getInventorySummaries(Map<String, Integer> skuCodesAndQuantity, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
reserveInventory
public void reserveInventory(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryProviderDecrement or otherwise "reserve" inventory for a cart during checkout.- Specified by:
reserveInventoryin interfaceInventoryProvider- Parameters:
cart- The cart for which to decrement inventory.contextInfo- Context information around sandbox and multitenant state.
-
softReserveInventory
public void softReserveInventory(com.broadleafcommerce.cart.client.domain.Cart cart, List<com.broadleafcommerce.cart.client.domain.CartItem> itemsToReserve, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryProviderPerform a soft reservation on a specific item. Intended to be used if an item has an "Add to Cart" reservation strategy- Specified by:
softReserveInventoryin interfaceInventoryProvideritemsToReserve- The items added to the cart to be soft reservedcontextInfo- Context information around sandbox and multitenant state.
-
releaseSoftReservations
public ReleaseSkuInventoryReservationResponse releaseSoftReservations(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> itemsToRelease, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryProviderReleases 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 theInventoryReservationStrategy.ADD_TO_CART- Specified by:
releaseSoftReservationsin interfaceInventoryProvider- Parameters:
cart- The cart containing the itemsitemsToRelease- The items removed from the cart and to release the soft reservation forcontextInfo- Context information around sandbox and multitenant state.- Returns:
- a
ReleaseSkuInventoryReservationResponse
-
buildSkuInventoryAvailabilityRequest
protected SkuInventoryAvailabilityRequest buildSkuInventoryAvailabilityRequest(InventoryAvailabilityRequest req, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) -
getInventorySummaries
protected List<SkuInventoryAvailabilitySummary> getInventorySummaries(@NonNull @NonNull List<SkuInventoryAvailabilityRequest> availabilityRequests, boolean throwExceptions, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getSkuInventoryAvailabilitySummaries
protected List<SkuInventoryAvailabilitySummary> getSkuInventoryAvailabilitySummaries(List<SkuInventoryAvailabilityRequest> availabilityRequests, String uri, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Fetch sku availability. In case of API error, exceptions are caught and logged and an empty list is returned. -
getUncaughtSkuInventoryAvailabilitySummaries
protected List<SkuInventoryAvailabilitySummary> getUncaughtSkuInventoryAvailabilitySummaries(List<SkuInventoryAvailabilityRequest> availabilityRequests, String uri, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Same asgetSkuInventoryAvailabilitySummaries(List, String, ContextInfo), but throws any exceptions. -
fetchSkuInventoryAvailabilitySummaries
protected List<SkuInventoryAvailabilitySummary> fetchSkuInventoryAvailabilitySummaries(List<SkuInventoryAvailabilityRequest> availabilityRequests, String uri, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
doReserveInventory
protected void doReserveInventory(com.broadleafcommerce.cart.client.domain.Cart cart, SkuInventoryReservationRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getReleaseReservationUri
-
getQuantityBySkuMapFromSummaries
protected Map<String,Boolean> getQuantityBySkuMapFromSummaries(List<SkuInventoryAvailabilitySummary> inventoryAvailabilitySummaries) Gets a map of quantity by SKU from the givenSkuInventoryAvailabilitySummaries.Sometimes we can get duplicate SKU codes back in different SKU Locations or vendors. We always want to return true, if it's available for one vendor or another, which prevents the
"java.lang.IllegalStateException: Duplicate key"error while returning true if the item is available for at least 1 location or vendor.- Parameters:
inventoryAvailabilitySummaries- a list ofSkuInventoryAvailabilitySummariesto convert into a map for- Returns:
- a map of quantity by SKU from the given
SkuInventoryAvailabilitySummaries.
-
buildReservationResponseException
protected Exception buildReservationResponseException(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull org.springframework.web.reactive.function.client.WebClientResponseException ex) Builds the appropriate exception that should be thrown when a request to reserve inventory fails.By default, all errors (even those caused by unexpected issues) will result in an
InventoryUnavailableException.- Parameters:
cart- the cart for which reservation was requestedex- the error that was encountered when making the request- Returns:
- the appropriate exception that should be thrown when a request to reserve inventory fails
-
buildExceptionForUnexpectedReservationError
protected InventoryUnavailableException buildExceptionForUnexpectedReservationError(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull Exception ex) - Parameters:
cart- the cart for which inventory reservation was requestedex- the unexpected error that was encountered- Returns:
- an exception that can be thrown when an inventory reservation request encounters an unexpected error
-
getErrorType
@Nullable protected String getErrorType(@NonNull @NonNull org.springframework.web.reactive.function.client.WebClientResponseException ex) -
buildSkuToCartItemIdMap
protected org.springframework.util.MultiValueMap<String,String> buildSkuToCartItemIdMap(@NonNull @NonNull Collection<com.broadleafcommerce.cart.client.domain.CartItem> cartItems) -
getSkuReferences
-
getDocumentContext
-
buildInventoryReservationRequest
protected Optional<SkuInventoryReservationRequest> buildInventoryReservationRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This allows implementors to build aSkuInventoryReservationRequestor return an emptyOptionalif no external request should be made (e.g. if all items in the cart are considered implicitly available.- Parameters:
cart-contextInfo-- Returns:
- Throws:
InventoryUnavailableException- - if one or more items are in the cart that are unavailable.
-
buildInventoryReservationRequest
protected Optional<SkuInventoryReservationRequest> buildInventoryReservationRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> cartItems, String inventoryReservationType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
buildReleaseInventoryReservationRequest
protected Optional<ReleaseSkuInventoryReservationRequest> buildReleaseInventoryReservationRequest(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> cartItemsToRelease, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds an optional ofReleaseSkuInventoryReservationRequestbased on the given cart and cart items. AnOptional.empty()is returned if there are no items to release the reservations for.- Parameters:
cart- theCartcontaining the items to build the request forcartItemsToRelease- theCartItemsto release the soft reservations forcontextInfo- context information surrounding multitenant state- Returns:
- an optional of
ReleaseSkuInventoryReservationRequest
-
getSkuReference
-
isSerialized
protected boolean isSerialized(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Determines whether the cart item has a serialized sku inventory object- Parameters:
cartItem- the cart item- Returns:
- whether the cart item has a serialized sku inventory object
-
buildSerializedSku
Builds a sku with an appended serialization value parameter- Parameters:
cartItem- cart item to access values from- Returns:
- sku with an appended serialization value parameter
-
getInventorySerializationValue
@Nullable protected String getInventorySerializationValue(com.broadleafcommerce.cart.client.domain.CartItem cartItem) Hook point to get the serialization value of a cart itemBy default, accesses a respective entry inside
CartItem.getInternalAttributes().- Parameters:
cartItem- the cart item- Returns:
- the serialization value
-
getProductType
@Nullable protected Object getProductType(com.broadleafcommerce.cart.client.domain.CartItem cartItem) -
getReservationUri
protected String getReservationUri(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Return the POST URI for Inventory Reservations.- Parameters:
contextInfo-- Returns:
-
getAvailabilityCheckUri
protected String getAvailabilityCheckUri(@NonNull @NonNull String skuCode, int quantity, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Return the GET URI for Inventory Availability. By default, this looks for shipping locations only for the providedskuCode.- Parameters:
contextInfo-- Returns:
-
getBulkAvailabilityCheckUri
protected String getBulkAvailabilityCheckUri(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Return the GET URI for Inventory Availability. By default, this looks for shipping locations only for the providedskuCodes.- Parameters:
contextInfo- Context information around sandbox and multitenant state.- Returns:
-
postProcessReservationResponse
protected void postProcessReservationResponse(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull SkuInventoryReservationResponse response, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Arbitrary hook point to allow for post processing of theCartand/or theSkuInventoryReservationResponse.- Parameters:
cart-response-contextInfo-
-
postProcessReleaseReservationResponse
protected ReleaseSkuInventoryReservationResponse postProcessReleaseReservationResponse(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull ReleaseSkuInventoryReservationResponse response, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Arbitrary hook point to allow for post processing of theCartand/or theReleaseSkuInventoryReservationResponse. -
getReservationRequestType
protected String getReservationRequestType(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Indicates the reservation request type (e.g. HARD or SOFT). The default is 'SOFT', meaning that the inventory reservation will be temporary to allow for a hard reservation later - usually after order submittal - which makes the reservation permanent.- Parameters:
cart-contextInfo-- Returns:
-
getSkuReferenceFieldType
protected String getSkuReferenceFieldType(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) SkuInventory records can be looked up or reference by a number of field types, including:
SKU_CODE - Identifies aCatalogItem.getSku()orVariant.getSku()by a unique SKU code
SKU_EXTERNAL_ID - An ID in another 1st or 3rd party system (e.g. in an ERP)
SKU_CODE - Arbitrary SKU code UPC - Universal Product
Code EAN - European Article Number (aka International Article Number)
GTIN - Global Trade Item Number
The default is SKU_CODE.- Parameters:
cart-contextInfo-- Returns:
-
getListType
protected org.springframework.core.ParameterizedTypeReference<List<SkuInventoryAvailabilitySummary>> getListType()Gets the type reference for a list of sku availability.- Returns:
- type reference for a list of sku availability
-
buildSkuInventoryAvailabilityRequests
protected List<SkuInventoryAvailabilityRequest> buildSkuInventoryAvailabilityRequests(Map<String, Integer> skuCodesAndQuantity) Builds a listSkuInventoryAvailabilityRequestto verify the availability of the SKU for the provided quantity.- Returns:
- a list of sku inventory availability requests
-
getServiceClient
-
getMessage
-
getMessageForLogging
-
getMessage
-
getInventorySummaries
@Deprecated(since="3.0.0") protected List<SkuInventoryAvailabilitySummary> getInventorySummaries(@NonNull @NonNull List<SkuInventoryAvailabilityRequest> availabilityRequests, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.in favor ofgetInventorySummaries(List, boolean, ContextInfo), which allows re-throwing exceptions. This implementation always returns an empty list in case of exceptions. -
getProperties
-
getInventorySummaries(List, boolean, ContextInfo), which allows re-throwing exceptions.