Class BasicCartProcessor
java.lang.Object
com.softslate.commerce.businessobjects.core.BaseBusinessObject
com.softslate.commerce.businessobjects.core.BaseBusinessProcessor
com.softslate.commerce.businessobjects.order.BasicCartProcessor
- All Implemented Interfaces:
BusinessObject,BusinessProcessor,CartProcessor
Processes business logic having to do with a user's cart.
BasicCartProcessor is the default implementation of the
CartProcessor interface for the application.- Author:
- David Tobey
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgetOrderAttribute(Map parameters, String productCode, String attributeCode, int index) Retrieves the value submitted for an attribute of a given product, as part of a request to add or edit an item in the user's cart.intgetOrderItemQuantity(Map parameters, int index) Looks up the submitted quantity of a given product contained in a request to add or edit a user's cart item.voidInitializes a user's cart.voidinitializeCart(Map parameters) markOrderComplete(Map parameters) Marks an order as complete at the very end of the checkout process, after payments have been processed.postProcessAddItems(Collection newOrderItems) Hook method which is called any time an item or items changes in the cart.processAddItems(Collection newOrderItems) Given aCollectionof initializedOrderItemobjects, 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.voidprocessItemAttribute(OrderItem orderItem, Attribute attribute, Option option, String attributeValue) Adds an attribute to a givenOrderItem.voidprocessItemAttributes(Map parameters, Product product, Collection missingAttributes, Collection newOrderItems, OrderItem orderItem, int index) Finds the attributes identified in the incoming parameters and creates OrderItemAttributes to be added to the OrderItem.processOrderComplete(Map parameters) Handles processing at the end of the checkout process, after payments have been processed.voidprocessQuantities(Collection newOrderItems) Given a Collection ofOrderItemsin the user's cart whose quantities have been set, updates the totals and weights of eachOrderItembased on the (new) quantity.processRemoveItem(OrderItem orderItem) Removes a given OrderItem from the user's cart, updating the cart totals in the process.voidprocessTotalsAndFormatting(Collection orderItems) Given a Collection ofOrderItemsin the user's cart whose totals have been set, updates the totals and weights of eachOrderDeliveryandOrderthey are under, and applies formatting to the totals.sendOrderCompleteEmails(Order order, Map parameters) Called when an order is completed.voidupdateOrderAndDeliveryTotals(OrderDelivery orderDelivery, OrderItem orderItem) Given anOrderItem, updates the totals of the user'sOrderand theOrderDeliverytheOrderItemis under.Methods inherited from class com.softslate.commerce.businessobjects.core.BaseBusinessProcessor
formatDateTime, formatPrice, getAppComponents, getAppSettings, getAttributeIDs, getBusinessObjectFactory, getDaoFactory, getEventBus, getInjector, getProductIDs, getSettings, getUser, initialize, isProcessorClassActive, loadMatchingSkus, parseDateTime, parseResponseData, prepareRequestData, sendHTTPGet, sendHTTPPost, sendHTTPPost, setAppComponents, setAppSettings, setBusinessObjectFactory, setDaoFactory, setEventBus, setInjector, setSettings, setUser, updateOrderTotals, updateOrderTotals, updateOrderTotals, utilsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.softslate.commerce.businessobjects.core.BusinessObject
initializeMethods 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
-
Field Details
-
log
static org.apache.commons.logging.Log log -
addItemStatus
-
initializedStatus
-
addressAddedStatus
-
pendingStatus
-
receivedStatus
-
corruptedStatus
-
skipDiscountsAndShipping
public boolean skipDiscountsAndShipping
-
-
Constructor Details
-
BasicCartProcessor
public BasicCartProcessor()
-
-
Method Details
-
processAddItems
Description copied from interface:CartProcessorProcesses 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 callingCartProcessor.initializeCart()to create a new instance ofOrderin theUserinstance for the user. It then adds anOrderDeliveryinstance under theOrderandOrderIteminstances 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
OrderItemobjects with the incoming information and then hands off the processing to theCartProcessor.processAddItems(Collection)method.The incoming
Mapmust 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(aHashMapholding attribute keys and values, where the attribute keys are in the form of 'productCode|attributeCode')
- Specified by:
processAddItemsin interfaceCartProcessor- Parameters:
parameters- AMaprepresenting the items and attributes being added to the user's cart.- Returns:
- A
Maprepresenting the results of the processing. TheMapmay have one or more of the following keys related to inventory processing: "lowStockEmails", "missingAttributes", "rejectedOrderItems", "adjustedOrderItems", and "newOOSSKUs". - Throws:
Exception- See Also:
-
-
processAddItems
Description copied from interface:CartProcessorGiven aCollectionof initializedOrderItemobjects, 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.- Specified by:
processAddItemsin interfaceCartProcessor- Parameters:
newOrderItems- TheCollectioncontaining theOrderItemobjects to be added to the user's cart.- Returns:
- A
Mapcontaining information on the results of the processing. TheMapmay have one or more of the following keys related to inventory processing: "lowStockEmails", "missingAttributes", "rejectedOrderItems", "adjustedOrderItems", and "newOOSSKUs". - Throws:
Exception
-
initializeCart
Description copied from interface:CartProcessorInitializes a user's cart. Creates new instances ofOrderandOrderDeliveryrepresenting a user's cart. Sets the currentUserobject's order property with the newly createdOrder. Synchronizes the new cart with the database.- Specified by:
initializeCartin interfaceCartProcessor- Throws:
Exception
-
initializeCart
- Throws:
Exception
-
processQuantities
Description copied from interface:CartProcessorGiven a Collection ofOrderItemsin the user's cart whose quantities have been set, updates the totals and weights of eachOrderItembased on the (new) quantity.- Specified by:
processQuantitiesin interfaceCartProcessor- Parameters:
newOrderItems- TheCollectioncontaining theOrderItemobjects whose quantities and totals are to be set.- Throws:
Exception
-
processTotalsAndFormatting
Description copied from interface:CartProcessorGiven a Collection ofOrderItemsin the user's cart whose totals have been set, updates the totals and weights of eachOrderDeliveryandOrderthey are under, and applies formatting to the totals.- Specified by:
processTotalsAndFormattingin interfaceCartProcessor- Parameters:
orderItems- TheOrderItemswhose totals must be added to the order and order delivery.- Throws:
Exception
-
updateOrderAndDeliveryTotals
Given anOrderItem, updates the totals of the user'sOrderand theOrderDeliverytheOrderItemis under. Calculates new totals for the quantity, price total, and weight total.- Parameters:
orderDelivery- The order delivery that contains the newOrderItem.orderItem- The newly-added order item whose price must be added to the order's total and the delivery's total.
-
getOrderAttribute
public String getOrderAttribute(Map parameters, String productCode, String attributeCode, int index) throws Exception Retrieves the value submitted for an attribute of a given product, as part of a request to add or edit an item in the user's cart. Uses theorderAttributesproperty (which is aHashMap) of the incomingMapto look up the attribute's value. The key for the attribute is formed like so:productCode|attributeCode.- Parameters:
parameters- AMaprepresenting the items and properties submitted to add or edit items in the user's cart.productCode- The code of the product corresponding to the attribute.attributeCode- The code of the attribute whose value is being looked up.index- The index of the submitted array of product codes corresponding to the item being added.- Returns:
- The submitted value of the attribute corresponding to the
attibuteCode, ornull, if the attribute is not found. - Throws:
Exception
-
processItemAttributes
public void processItemAttributes(Map parameters, Product product, Collection missingAttributes, Collection newOrderItems, OrderItem orderItem, int index) throws Exception Finds the attributes identified in the incoming parameters and creates OrderItemAttributes to be added to the OrderItem.- Parameters:
parameters-product-missingAttributes-newOrderItems-orderItem-index-- Throws:
Exception
-
processItemAttribute
public void processItemAttribute(OrderItem orderItem, Attribute attribute, Option option, String attributeValue) throws Exception Adds an attribute to a givenOrderItem. Adds the attribute's total and weight to the order item's.- Parameters:
orderItem- TheOrderItemthat is having an attribute added to it.attribute- TheAttributebeing added to the order itemoption- TheOptionof the above attribute that is being added to the order item. If no option is relevant, this parameter may be null.attributeValue- The value of the attribute being added to theOrderItem. Corresponds to the option's code, or a free form value if no option is relevant.- Throws:
Exception
-
getOrderItemQuantity
Looks up the submitted quantity of a given product contained in a request to add or edit a user's cart item. Uses theorderProductQuantitiesproperty (which is aString[]) of the incomingMapto look up the value.- Parameters:
parameters- AMaprepresenting the items and properties being added or edited.index- The index of the submitted array of product quantities corresponding to the item being added.- Returns:
- An int representing the submitted quantity of the user's cart item
- Throws:
Exception
-
processEditItem
Description copied from interface:CartProcessorProcesses a request to edit a given item in a user's cart. The incomingMapmust have the same keys required byCartProcessor.processAddItems(Map), plus a key namedorderItem, which identifies the order item being edited.- Specified by:
processEditItemin interfaceCartProcessor- Parameters:
parameters- AMapidentifying the item being edited and specifying the item's new properties.- Returns:
- A
Mapcontaining information on the results of the processing. TheMapmay have one or more of the following keys related to inventory processing: "lowStockEmails", "missingAttributes", "rejectedOrderItems", "adjustedOrderItems", and "newOOSSKUs". - Throws:
Exception- See Also:
-
processRemoveItem
Description copied from interface:CartProcessorRemoves a given OrderItem from the user's cart, updating the cart totals in the process.- Specified by:
processRemoveItemin interfaceCartProcessor- Parameters:
orderItem- TheOrderItembeing removed.- Throws:
Exception
-
processCheckoutAddresses
Description copied from interface:CartProcessorProcesses a request to add address information to a user's cart. Originates from the checkout process in the Struts layer.- Specified by:
processCheckoutAddressesin interfaceCartProcessor- Parameters:
parameters- AMaprepresenting the address information of the current user.- Throws:
Exception- See Also:
-
processOrderComplete
Description copied from interface:CartProcessorHandles 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.- Specified by:
processOrderCompletein interfaceCartProcessor- Returns:
- A
Maprepresenting the results of the processing. - Throws:
Exception- See Also:
-
markOrderComplete
Description copied from interface:CartProcessorMarks 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).
- Specified by:
markOrderCompletein interfaceCartProcessor- Returns:
- A
Maprepresenting the results of the processing. - Throws:
Exception- See Also:
-
createGiftCertificates
- Throws:
Exception
-
computeGiftCertificateExpDate
-
postProcessAddItems
- Throws:
Exception
-
postProcessCartChanged
Description copied from interface:CartProcessorHook method which is called any time an item or items changes in the cart.- Specified by:
postProcessCartChangedin interfaceCartProcessor- Returns:
- A
Maprepresenting the results of the processing. - Throws:
Exception
-
sendOrderCompleteEmails
Description copied from interface:CartProcessorCalled when an order is completed. Sends an order confirmation email to the customer and an order notification email to store admins.- Specified by:
sendOrderCompleteEmailsin interfaceCartProcessor- Returns:
- A
Maprepresenting the results of the processing. - Throws:
Exception
-