Interface InventoryProcessor
- All Superinterfaces:
BusinessObject
,BusinessProcessor
- All Known Implementing Classes:
BasicInventoryProcessor
Interface for business logic methods having to do with SKUs and inventory.
CartProcessor
employs an
instance implementing InventoryProcessor
when inventory needs
to be processed.
When the application needs to create an instance that implements
InventoryProcessor
,
BusinessObjectFactory
finds the name of the Java class to instantiate from the
"inventoryProcessorImplementer" setting in the
appComponents.properties
file.
The default "inventoryProcessorImplementer" is
BasicInventoryProcessor
.
-
Method Summary
Modifier and TypeMethodDescriptiondefineInventorySettings
(Product product, Collection attributeSKUCollection) Inspects a Product and returns a Map of useful variables related to the state of the product's inventory.processAddItems
(Collection orderItems) Processes inventory as newOrderItem
s are added to a user's cart.processInventory
(Collection orderItems, Map productSettings, Collection matchingSkus, String decrementBehavior) Generically processes inventory, returning a Map with information about items and skus.processOnCheckout
(Map parameters) Checks inventory for a user's cart during checkout.processOrderComplete
(Map parameters) Processes inventory for a user's cart as an order is completed.Methods inherited from interface com.softslate.commerce.businessobjects.core.BusinessObject
initialize
Methods inherited from interface com.softslate.commerce.businessobjects.core.BusinessProcessor
getAppComponents, getAppSettings, getBusinessObjectFactory, getDaoFactory, getEventBus, getInjector, getSettings, getUser, setAppComponents, setAppSettings, setBusinessObjectFactory, setDaoFactory, setEventBus, setInjector, setSettings, setUser, utils
-
Method Details
-
processAddItems
Processes inventory as newOrderItem
s are added to a user's cart. Decrements inventory levels (in the memory objects) if products are set to be decremented upon being added to a cart. (Objects are updated in the database byBasicCartProcessor.processAddItems(Collection)
, which is what calls this method.)The default implementation of this method does the following:
- Loads the inventory settings in effect for each of the products
corresponding to the
OrderItem
s being added. - Calls
BaseBusinessProcessor.loadMatchingSkus(Collection, Collection, Collection)
to load the skus corresponding to theOrderItem
s. - Calls
processInventory(Collection, Map, Collection, String)
to process the inventory. - Removes any order items that were rejected because one of their corresponding SKUs are out of stock.
- Adjusts the quantities of any order items whose quantities exceed the quantity in stock.
- Calls
CartProcessor.processQuantities(Collection)
to update the cart with the new quantities.
- Parameters:
orderItems
- TheCollection
ofOrderItem
objects being added to the cart.- Returns:
- A
Map
containing results of the processing. In the default implementation, theMap
is the same as the one returned byprocessInventory(Collection, Map, Collection, String)
(which this method calls). - Throws:
Exception
- See Also:
- Loads the inventory settings in effect for each of the products
corresponding to the
-
processOnCheckout
Checks inventory for a user's cart during checkout. This step takes places as the user passes through checkout, but before submitting payment information. Makes sure that if products are to be decremented on checkout, no skus are out of stock. Inventory does not get decremented with this method.The default implementation of this method largely follows the same steps as
processAddItems(Collection)
.- Parameters:
parameters
- The most recent parameters submitted by the user.- Returns:
- A
Map
containing results of the processing. In the default implementation, theMap
is the same as the one returned byprocessInventory(Collection, Map, Collection, String)
(which this method calls). - Throws:
Exception
- See Also:
-
processOrderComplete
Processes inventory for a user's cart as an order is completed. This step takes place after a successful payment processing. Inventory is decremented at this point for products set to be decremented on checkout.- Parameters:
parameters
- The most recent parameters submitted by the user.- Returns:
- A
Map
containing results of the processing. In the default implementation, theMap
is the same as the one returned byprocessInventory(Collection, Map, Collection, String)
(which this method calls). - Throws:
Exception
-
processInventory
Map processInventory(Collection orderItems, Map productSettings, Collection matchingSkus, String decrementBehavior) throws Exception Generically processes inventory, returning a Map with information about items and skus. Does not change the order items being checked.- Parameters:
orderItems
- ACollection
ofOrderItem
objects being processed.productSettings
- AMap
ofCollections
representing the inventory settings in effect for the products in theOrderItem
s.matchingSkus
- ACollection
ofMap
s representing all the SKUs associated with theOrderItem
s.decrementBehavior
- AString
representing when inventory is to be decremented. Either "onAddingToCart" or "onOrderCompletion".- Returns:
- A
Map
containing results of the processing. In the default implementation, the keys of theMap
include:skusToDecrement
: ACollection
ofMap
s, each representing aSKU
that is to be decremented as result of the processing.decrementedSKUs
: AMap
whose keys areOrderItem
objects and whose values are comma-separatedString
s representing the ids of theSKU
objects corresponding to theOrderItem
that are to be decremented. (Used to populate theOrderItem
'sdescrementedSKUs
property.)rejectedOrderItems
: ACollection
ofOrderItem
objects that have been removed from the user's cart due to their being out of stock.adjustedQuantities
: AMap
whose keys areOrderItem
objects and whose values areString
s representing theOrderItem
s new quantity, after being adjusted because not enough inventory is available.newOOSSKUs
: ACollection
ofMap
s, each representing aSKU
that has just reached its out of stock level as result of the processing.productsToDeactivate
: ACollection
ofString
s, each representing the id of aProduct
object that should now be deactivated because aSKU
associated with it has just gone out of stock.lowStockEmails
: ACollection
ofMap
s, each representing aSKU
that has reached its 'low stock' level, and should trigger a low stock email as a result.
- Throws:
Exception
-
defineInventorySettings
Inspects a Product and returns a Map of useful variables related to the state of the product's inventory.- Parameters:
product
-attributeSKUCollection
- An optional Collection of attribute-only SKUs used to define the inventory settings that are returned.- Returns:
- A Map of variables related to the product's inventory.
-