com.softslate.commerce.customer.order
Class CartAddAction
java.lang.Object
org.apache.struts.action.Action
com.softslate.commerce.customer.core.BaseAction
com.softslate.commerce.customer.order.CartAddAction
- Direct Known Subclasses:
- CartItemEditAction, ReorderCartPickupAction, SavedCartPickupAction
public class CartAddAction
- extends BaseAction
Struts action class for submissions to add items to the current user's cart.
Used for requests to "/CartAdd.do".
The execute
method of this class invokes
CartProcessor.processAddItems(Map)
to process the add cart request and insert the items into the
database. It then performs processing of the results returned from that
method, including sending low stock email messages.
- Author:
- David Tobey
- See Also:
CartAddForm
,
CartProcessor
Field Summary |
(package private) static org.apache.commons.logging.Log |
log
|
Fields inherited from class org.apache.struts.action.Action |
defaultLocale, servlet |
Method Summary |
void |
addInventoryMessages(java.util.Map results,
BaseForm baseForm)
Adds non-error messages to the request related to inventory. |
org.apache.struts.action.ActionForward |
execute(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
java.lang.String |
processResults(java.util.Map results,
BaseForm baseForm)
Process the results of adding an item or items to the cart. |
void |
sendLowStockEmails(java.util.Collection lowStockEmails,
BaseForm baseForm)
Sends low stock emails related to the item or items being added to the
cart. |
Methods inherited from class org.apache.struts.action.Action |
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
static org.apache.commons.logging.Log log
CartAddAction
public CartAddAction()
execute
public org.apache.struts.action.ActionForward execute(org.apache.struts.action.ActionMapping mapping,
org.apache.struts.action.ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws java.lang.Exception
- Overrides:
execute
in class org.apache.struts.action.Action
- Throws:
java.lang.Exception
processResults
public java.lang.String processResults(java.util.Map results,
BaseForm baseForm)
- Process the results of adding an item or items to the cart. This method
first sends out low stock inventory emails. It then adds error messages
for customers if required attributes were missing from the request or the
item or items are out of stock.
In the case of an error, the attribute "errorProductCode" is set in the
request, corresponding to the product code of the first item being added
to the cart. If the submission came from a product page, this will tell
the ProductForm
to populate the request with that
product's data, so the errors can be displayed on the product page.
Finally, this method calls the addInventoryMessages
method, to populate the request with (non-error) messages relating to
inventory.
- Parameters:
results
- The Map of results returned by the call to the
execute
method of this class.baseForm
- The instance of CartAddForm
corresponding to
the request.
- Returns:
- A String, "success" or "failure", corresponding to the
ActionFoward
that the execute
method will return.
addInventoryMessages
public void addInventoryMessages(java.util.Map results,
BaseForm baseForm)
- Adds non-error messages to the request related to inventory. Two types of
messages may be added.
- Messages indicating that the quantity of an item was more than its
inventory level and that therefore the quantity was automatically lowered
to match the amount in stock.
- Messages indicating that with this request a product has just hit
its out of stock level.
- Parameters:
results
- The Map of results returned by the call to the
execute
method of this class.baseForm
- The instance of CartAddForm
corresponding to
the current request.
sendLowStockEmails
public void sendLowStockEmails(java.util.Collection lowStockEmails,
BaseForm baseForm)
- Sends low stock emails related to the item or items being added to the
cart. Settings defining how these emails are produced exist in the
sscSetting
and (for specific products) in the
sscProductSetting
database tables. Among the settings are
who receives the low-stock emails, what inventory level triggers the
emails, and a template for the subject and body of the emails.
- Parameters:
lowStockEmails
- A Collection of Maps containing information on what items have
reached their low stock levels. This Collection is returned by
the call to
CartProcessor.processAddItems(Map)
in the execute
method.baseForm
- The instance of CartAddForm
corresponding to
the current request.
Copyright ? SoftSlate, LLC 2003?2005