Interface CartDiscountProcessor
- All Superinterfaces:
BusinessObject
,BusinessProcessor
- All Known Implementing Classes:
BasicCartDiscountProcessor
Interface for business logic methods having to do with discounts in a user's
cart.
CartProcessor
employs an
instance implementing CartDiscountProcessor
when discounting
needs to be processed.
When the application needs to create an instance that implements
CartDiscountProcessor
,
BusinessObjectFactory
finds the name of the Java class to instantiate from the
"cartDiscountProcessorImplementer" setting in the
appComponents.properties
file.
The default "cartDiscountProcessorImplementer" is
BasicCartDiscountProcessor
.
- Author:
- David Tobey
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefineDiscountSettings
(Product product, Collection attributeSKUCollection, Collection storeDiscounts) Inspects a Product and returns a Map of useful variables related to the state of the product's discounts.boolean
isDiscountOk
(Discount discount, Double previousOrderTotal) Checks that a given discount is applicable.boolean
isDiscountOkIfItemInCart
(Discount discount, Double previousOrderTotal, String productCode) Checks if a given discount would be applicable, if the given product code were in the user's cart.processAddItems
(Collection orderItems) Processes discounts upon adding an item or items to the user's cart.processAfterTaxes
(Map parameters) Processes discounts after shipping and taxes have been calculated.processCouponCode
(Map parameters) Processes discounts as a user enters a coupon code.processCustomerLogin
(Map parameters) Processes discounts as a customer logs in.processCustomerLogout
(Map parameters) Processes discounts as a customer logs out.processOnCheckout
(Map parameters) Processes discounts during checkout, as taxes and shipping are processed.processOrderComplete
(Map parameters) Processes discounts as a user's order is completed.Removes all the discounts in the current user's cart.processShippingDiscountsOnShippingOptions
(Collection shippingOptions) Applies shipping discounts to each of the shipping options in the incoming Collection.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 discounts upon adding an item or items to the user's cart. The default implementation simply callsBasicCartDiscountProcessor.processDiscounts(Collection)
- Parameters:
orderItems
- The collection ofOrderItem
objects being added to the cart.- Returns:
- A
Map
containing results of the processing. The default implementation returns null. - Throws:
Exception
-
processOnCheckout
Processes discounts during checkout, as taxes and shipping are processed. The default implementation simply callsBasicCartDiscountProcessor.processDiscounts(Collection)
- Parameters:
parameters
- AMap
with any parameters needed for the processing. The default implementation does not use this argument.- Returns:
- A
Map
containing results of the processing. The default implementation returns null. - Throws:
Exception
-
processAfterTaxes
Processes discounts after shipping and taxes have been calculated. This is so that if there are any gift certificates, they may be applied against the order's total rather than its subtotal as is the case with regular discounts. The default implementation simply callsBasicCartDiscountProcessor.processDiscounts(Collection)
- Parameters:
parameters
- AMap
with any parameters needed for the processing. The default implementation does not use this argument.- Returns:
- A
Map
containing results of the processing. The default implementation returns null. - Throws:
Exception
-
processCouponCode
Processes discounts as a user enters a coupon code. The default implementation simply callsBasicCartDiscountProcessor.processDiscounts(Collection)
- Parameters:
parameters
- AMap
with any parameters needed for the processing. The default implementation does not use this argument.- Returns:
- A
Map
containing results of the processing. The default implementation returns null. - Throws:
Exception
-
processCustomerLogin
Processes discounts as a customer logs in. Some discounts only apply if the user is logged in as a customer, so discounts must be rerun. The default implementation simply callsBasicCartDiscountProcessor.processDiscounts(Collection)
- Parameters:
parameters
- AMap
with any parameters needed for the processing. The default implementation does not use this argument.- Returns:
- A
Map
containing results of the processing. The default implementation returns null. - Throws:
Exception
-
processCustomerLogout
Processes discounts as a customer logs out. Some discounts only apply if the user is logged in as a customer, so discounts must be rerun. The default implementation simply callsBasicCartDiscountProcessor.processDiscounts(Collection)
- Parameters:
parameters
- AMap
with any parameters needed for the processing. The default implementation does not use this argument.- Returns:
- A
Map
containing results of the processing. The default implementation returns null. - Throws:
Exception
-
processOrderComplete
Processes discounts as a user's order is completed. The default implementation simply callsBasicCartDiscountProcessor.processDiscounts(Collection)
- Parameters:
parameters
- AMap
with any parameters needed for the processing. The default implementation does not use this argument.- Returns:
- A
Map
containing results of the processing. The default implementation returns null. - Throws:
Exception
-
processRemoveDiscounts
Removes all the discounts in the current user's cart. Updates the cart totals accordingly. Called before items are removed from the cart byBasicCartProcessor.processRemoveItem(OrderItem)
- Returns:
- A
Map
containing results of the processing. The default implementation returns null. - Throws:
Exception
-
isDiscountOk
Checks that a given discount is applicable. Used by discount processing to help determine which discounts to apply, and in the presentation to determine which discounts to display to the user.- Parameters:
discount
- The discount whose applicability is being checked.previousOrderTotal
- The previous order total of the current user, or null. Some discounts are only applicable if the user has previously placed orders totaling a certain amount.- Returns:
- true, the discount is applicable, otherwise, false.
- Throws:
Exception
-
isDiscountOkIfItemInCart
boolean isDiscountOkIfItemInCart(Discount discount, Double previousOrderTotal, String productCode) throws Exception Checks if a given discount would be applicable, if the given product code were in the user's cart. Used by the presentation layer to communicate the discounts that would be available if the item were added to the cart.- Parameters:
discount
- The discount whose applicability is being checked.previousOrderTotal
- The previous order total of the current user, or null. Some discount are only applicable if the user has previously placed orders totaling a certain amount.- Returns:
- true, the discount is applicable, otherwise, false.
- Throws:
Exception
-
processShippingDiscountsOnShippingOptions
Applies shipping discounts to each of the shipping options in the incoming Collection.- Parameters:
shippingOptions
-- Returns:
- the same Collection of shipping options, with discounts applied
- Throws:
Exception
-
defineDiscountSettings
Map defineDiscountSettings(Product product, Collection attributeSKUCollection, Collection storeDiscounts) throws Exception Inspects a Product and returns a Map of useful variables related to the state of the product's discounts.- Parameters:
product
-attributeSKUCollection
- An optional Collection of attribute-only SKUs used to define the inventory settings that are returned.storeDiscounts
- An optional Collection of global, store discounts, used to determine if "promotions" for the product exist, ie, discounts that would be applied if the product were added to the cart.- Returns:
- A Map of variables related to the product's discounts.
- Throws:
Exception
-