Interface CartProcessor
- All Superinterfaces:
BusinessObject
,BusinessProcessor
- All Known Implementing Classes:
BasicCartProcessor
The Struts layer employs an instance implementing CartProcessor
when a user adds items to his or her cart or edits items. It is also used to
handle processing during checkout.
CartProcessor
is similar in intention to
OrderProcessor
.
OrderProcessor
contains more generic code relating to orders,
while CartProcessor
contains code specific to manuipulating a
user's cart.
When the application needs to create an instance that implements
CartProcessor
,
BusinessObjectFactory
finds the name of the Java class to instantiate from the
"cartProcessorImplementer" setting in the
appComponents.properties
file.
The default "cartProcessorImplementer" is
BasicCartProcessor
.
- Author:
- David Tobey
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Initializes a user's cart.markOrderComplete
(Map parameters) Marks an order as complete at the very end of the checkout process, after payments have been processed.Hook method which is called any time an item or items changes in the cart.processAddItems
(Collection newOrderItems) Given aCollection
of initializedOrderItem
objects, adds the items to the user's cart.processAddItems
(Map parameters) Processes a request to add items to a user's cart.processCheckoutAddresses
(Map parameters) Processes a request to add address information to a user's cart.processEditItem
(Map parameters) Processes a request to edit a given item in a user's cart.processOrderComplete
(Map parameters) Handles processing at the end of the checkout process, after payments have been processed.void
processQuantities
(Collection newOrderItems) Given a Collection ofOrderItems
in the user's cart whose quantities have been set, updates the totals and weights of eachOrderItem
based on the (new) quantity.processRemoveItem
(OrderItem orderItem) Removes a given OrderItem from the user's cart, updating the cart totals in the process.void
processTotalsAndFormatting
(Collection orderItems) Given a Collection ofOrderItems
in the user's cart whose totals have been set, updates the totals and weights of eachOrderDelivery
andOrder
they are under, and applies formatting to the totals.sendOrderCompleteEmails
(Order order, Map describe) Called when 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 a request to add items to a user's cart. If the user's cart has not been initialized, this method initializes it first by callinginitializeCart()
to create a new instance ofOrder
in theUser
instance for the user. It then adds anOrderDelivery
instance under theOrder
andOrderItem
instances under theOrderDelivery
.This method manages the parsing of incoming parameters that identify the products, quantities, and attribute values of the items to be added. It populates
OrderItem
objects with the incoming information and then hands off the processing to theprocessAddItems(Collection)
method.The incoming
Map
must have the following keys:-
orderProductCodes
(aString[]
holding the codes of the product(s) to add) orderProductQuantities
(aString[]
holding the quantities of the product(s) to add)- and
orderAttributes
(aHashMap
holding attribute keys and values, where the attribute keys are in the form of 'productCode|attributeCode')
- Parameters:
parameters
- AMap
representing the items and attributes being added to the user's cart.- Returns:
- A
Map
representing the results of the processing. TheMap
may have one or more of the following keys related to inventory processing: "lowStockEmails", "missingAttributes", "rejectedOrderItems", "adjustedOrderItems", and "newOOSSKUs". - Throws:
Exception
- See Also:
-
-
processAddItems
Given aCollection
of initializedOrderItem
objects, adds the items to the user's cart. Manages the processing of inventory and discounting, updates the user's cart totals, and manages synchronizing the objects with the database.- Parameters:
newOrderItems
- TheCollection
containing theOrderItem
objects to be added to the user's cart.- Returns:
- A
Map
containing information on the results of the processing. TheMap
may have one or more of the following keys related to inventory processing: "lowStockEmails", "missingAttributes", "rejectedOrderItems", "adjustedOrderItems", and "newOOSSKUs". - Throws:
Exception
-
processQuantities
Given a Collection ofOrderItems
in the user's cart whose quantities have been set, updates the totals and weights of eachOrderItem
based on the (new) quantity.- Parameters:
newOrderItems
- TheCollection
containing theOrderItem
objects whose quantities and totals are to be set.- Throws:
Exception
-
processEditItem
Processes a request to edit a given item in a user's cart. The incomingMap
must have the same keys required byprocessAddItems(Map)
, plus a key namedorderItem
, which identifies the order item being edited.- Parameters:
parameters
- AMap
identifying the item being edited and specifying the item's new properties.- Returns:
- A
Map
containing information on the results of the processing. TheMap
may have one or more of the following keys related to inventory processing: "lowStockEmails", "missingAttributes", "rejectedOrderItems", "adjustedOrderItems", and "newOOSSKUs". - Throws:
Exception
- See Also:
-
processRemoveItem
Removes a given OrderItem from the user's cart, updating the cart totals in the process.- Parameters:
orderItem
- TheOrderItem
being removed.- Throws:
Exception
-
initializeCart
Initializes a user's cart. Creates new instances ofOrder
andOrderDelivery
representing a user's cart. Sets the currentUser
object's order property with the newly createdOrder
. Synchronizes the new cart with the database.- Throws:
Exception
-
processCheckoutAddresses
Processes a request to add address information to a user's cart. Originates from the checkout process in the Struts layer.- Parameters:
parameters
- AMap
representing the address information of the current user.- Throws:
Exception
- See Also:
-
processOrderComplete
Handles processing at the end of the checkout process, after payments have been processed. Decrements inventory, marks discounts as having been used and updates the order totals.- Returns:
- A
Map
representing the results of the processing. - Throws:
Exception
- See Also:
-
markOrderComplete
Marks an order as complete at the very end of the checkout process, after payments have been processed. Sets the order's completed field with the current time. Sets the user's order with a status of "Received" and assigns an order number to the order. The "Received" status is given to all orders that have been successfully completed by the user. In other words, orders whose payments succeeded.The order number is an integer given to each completed order, starting at the "orderNumberFloor" database setting (whose default is 1,000).
- Returns:
- A
Map
representing the results of the processing. - Throws:
Exception
- See Also:
-
processTotalsAndFormatting
Given a Collection ofOrderItems
in the user's cart whose totals have been set, updates the totals and weights of eachOrderDelivery
andOrder
they are under, and applies formatting to the totals.- Parameters:
orderItems
- TheOrderItems
whose totals must be added to the order and order delivery.- Throws:
Exception
-
postProcessCartChanged
Hook method which is called any time an item or items changes in the cart.- Returns:
- A
Map
representing the results of the processing. - Throws:
Exception
-
sendOrderCompleteEmails
Called when an order is completed. Sends an order confirmation email to the customer and an order notification email to store admins.- Returns:
- A
Map
representing the results of the processing. - Throws:
Exception
-