@Bean
@ConditionalOnMissingBean
InventoryProvider inventoryProvider() {
return new EmptyInventoryProvider();
}
Provider for interfacing with an Inventory Service. The default implementation facilitates HTTP requests against the endpoints to allow inventory to be reserved and item quantities to be validated.
By default, the reservations made are "soft", meaning they are temporary, by the InventoryAvailabilityValidationCheckoutWorkflowActivity. These are converted to "hard" reservations after checkout is completed—performed by OrderSubmittedInventoryAdjustmentMessageListener.
An EmptyInventoryProvider
is also available out-of-the-box if you do not have a inventory checks or reservations.
Just register it as a new InventoryProvider
, and it will replace the ExternalInventoryProvider
.
@Bean
@ConditionalOnMissingBean
InventoryProvider inventoryProvider() {
return new EmptyInventoryProvider();
}
ExternalInventoryProperties
defines the properties used to configure ExternalInventoryProvider
, the default implementation.
broadleaf.cartoperation.inventoryprovider.url
: The base url for an external inventory service
broadleaf.cartoperation.inventoryprovider.reserverUrl
: The context path for performing reservations.
This is appended to the url
property.
broadleaf.cartoperation.inventoryprovider.checkAvailabilityUri
: The context path for checking the if there is enough inventory for a particular SKU to fulfill the quantity in the cart.
This is appended to the url
property.
// to reserve
UriComponentsBuilder.fromHttpUrl(getProperties().getUrl())
.path(getProperties().getReserveUri())
.toUriString();
// to check availability
UriComponentsBuilder.fromHttpUrl(getProperties().getUrl())
.path(getProperties().getCheckAvailabilityUri())
.queryParam("skuReference", skuCode)
.queryParam("minAvailableQuantity", quantity)
.queryParam("forShipping", "true")
.queryParam("skuFieldType", "SKU_CODE")
.toUriString()