com.elasticpath.domain.shoppingcart
Interface ShoppingCart

All Superinterfaces:
Entity, EpDomain, Persistence, java.io.Serializable
All Known Implementing Classes:
ShoppingCartImpl

public interface ShoppingCart
extends Entity

ShoppingCart represents a shopping cart of a Customer.


Method Summary
 CartItem addAssociatedCartItem(ProductAssociation productAssociation, CartItem parentCartItem)
          Adds an item to the cart where the source of the item information is a ProductAssociation.
 CartItem addCartItem(CartItem cartItem)
          Add an item to the cart.
 CartItem addCartItem(ProductSku productSku, int quantity)
          Convenience method for adding an item to the cart.
 CartItem addWishListItem(ProductSku productSku)
          Convenience method for adding an item to the wishlist.
 boolean allowCheckout()
          Returns true if the shopping cart is in a state that the customer can proceed with a checkout.
 void calculateShoppingCartTaxAndBeforeTaxPrices()
          Calculate the taxes and before-tax prices for the giveing shoppingCart, including cart item and shipping cost.
 void clearEstimates()
          Removes shipping and tax estimates from the shopping cart.
 void clearItems()
          Empties the shopping cart (e.g.
 void clearSelectedShippingServiceLevel()
          Resets the selected ShippingServiceLevel to null.
 void fireRules()
          Forces the shopping cart to apply promotion rules.
 java.util.Set getAppliedRules()
          Get the set of rules that have been applied to the cart.
 Money getBeforeTaxShippingCost()
          Return the before-tax shippingCost.
 Money getBeforeTaxSubTotal()
          Return the before-tax subtotal.
 Money getBeforeTaxTotal()
          Return the before-tax total.
 Address getBillingAddress()
          Get the preferred billing address.
 CatalogViewResultHistory getBrowsingResultHistory()
          Returns the browsing result history stored.
 CartItem getCartItem(java.lang.String skuGuid)
          Get a cart item by the GUID of its SKU.
 CartItem getCartItemById(long cartItemId)
          Returns the cart item with the given id.
 java.util.List getCartItems()
          Get the cart items in the shopping cart.
 java.util.List getCartProducts()
          Get the products in the shopping cart.
 CatalogViewResultHistory getCatalogViewResultHistory()
          Returns the catalog view result history stored.
 Order getCompletedOrder()
          Get a reference to the completed order for the items previously checked out.
 java.util.Currency getCurrency()
          Get the currency of the customer corresponding to the shopping cart.
 CustomerSession getCustomerSession()
          Return the CustomerSession.
 java.lang.String getCustomerSessionGuid()
          Return the guid of the customer session that corresponds to this shopping cart.
 java.lang.String getIpAddress()
          Get the ipAddress of the user from the shopping cart.
 Category getLastCategory()
          Returns the last category.
 java.util.Locale getLocale()
          Get the locale of the customer corresponding to the shopping cart.
 java.util.Map getLocalizedTaxMap()
          Return the localized tax category name -> tax value (Money) map for this ShoppingCart.
 int getNumItems()
          Return the number of items in the shopping cart.
 java.util.List getProductAssociationsByType(int associationType, int maxAssociations, boolean filter)
          Get a list of ProductAssociations that specify associations between items in the cart and other related products.
 java.lang.String getPromotionCode()
          Get the promotion code entered by the user.
 java.util.List getRemovedCartItems()
          Get the cart items that have been removed from the shopping cart.
 CatalogViewResultHistory getSearchResultHistory()
          Returns the search result history stored.
 ShippingServiceLevel getSelectedShippingServiceLevel()
          Get the selectedShippingServiceLevel.
 Address getShippingAddress()
          Get the preferred shipping address.
 Money getShippingCost()
          Return the shippingCost of the ShoppingCart.
 java.util.List getShippingServiceLevelList()
          Return the list of shippingServiceLevel list available based on the current shopping cart info.
 java.math.BigDecimal getSubtotal()
          Get the subtotal of all items in the cart.
 java.math.BigDecimal getSubtotalDiscount()
          Get the discount to the shopping cart subtotal.
 Money getSubtotalDiscountMoney()
          Get the amount discounted from the order subtotal.
 Money getSubtotalMoney()
          Get the subtotal of all items in the cart.
 java.util.Map getTaxMap()
          Return the TaxCategory -> tax value (Money) map for this ShoppingCart.
 java.math.BigDecimal getTotal()
          Get the sub total of all items in the cart after shipping, promotions, etc.
 Money getTotalMoney()
          Get the sub total of all items in the cart after shipping, promotions, etc.
 java.math.BigDecimal getTotalWeight()
          Get the totalWeight of items in ShoppingCart.
 ViewHistory getViewHistory()
          Get the View History of the user from the shopping cart.
 java.util.List getWishListItems()
          Get the wish list items in the shopping cart.
 boolean hasSubtotalDiscount()
          Returns true if an order subtotal discount has been applied.
 void init()
          Initializes the shopping cart.
 boolean isEstimateMode()
          Get the indicator of whether in the estimate shipping and taxes mode.
 boolean isInclusiveTaxCalculationInUse()
          Return true if the "inclusive" tax calculation method is in use; otherwise false.
 boolean isPromotionCodeAccepted()
          Indicates if the promotion code set by the user is valid.
 void removeCartItem(long itemUid)
          Remove an item from the cart.
 void removeWishListItem(long itemUid)
          Remove an item from the wish list.
 boolean requiresShipping()
          Returns true if the cart contains items that must be shipped to the customer.
 void ruleApplied(long ruleId)
          Indicates that the given rule was applied by the promotion rule engine.
 void setBillingAddress(Address address)
          Set the preferred billing address.
 void setCartItems(java.util.List cartItems)
          Set the cart items in the shopping cart.
 void setCompletedOrder(Order order)
          Set a reference to the completed order for the items previously checked out.
 void setCurrency(java.util.Currency currency)
          Set the currency of the customer corresponding to the shopping cart.
 void setCustomerSession(CustomerSession customerSession)
          Set the CustomerSession.
 void setCustomerSessionGuid(java.lang.String guid)
          Set the guid of the customer session that corresponds to this shopping cart.
 void setEstimateMode(boolean estimateMode)
          Set the indicator of whether in the estimate shipping and taxes mode.
 void setIpAddress(java.lang.String ipAddress)
          Set the users ip Address into the shopping cart.
 void setLastCategory(Category category)
          Sets the last category.
 void setLocale(java.util.Locale locale)
          Set the locale of the customer corresponding to the shopping cart.
 void setPromotionCode(java.lang.String promotionCode)
          Set the promotion code entered by the user.
 void setPromotionCodeAccepted(boolean promotionCodeAccepted)
          Set whether or not the promotion code entered by the user is valid.
 Money setSelectedShippingServiceLevelUid(long selectedSSLUid)
          Set the selectedShippingServiceLevelUid and update the shippingCost correspondingly.
 void setShippingAddress(Address address)
          Set the preferred shipping address.
 void setShippingServiceLevelList(java.util.List shippingServiceLevelList)
          Set the list of shippingServiceLevel list available based on the current shopping cart info.
 void setSubtotalDiscount(java.math.BigDecimal discountAmount)
          Applies a discount to the shopping cart subtotal.
 void setTaxJurisdiction(TaxJurisdiction taxJurisdiction)
          Set the most specific TaxJurisdiction based on the shippingAddress of this ShoppingCart.
 void setWishListItems(java.util.List wishListItems)
          Set the wish list items in the shopping cart.
 CartItem updateCartItemByGuid(java.lang.String skuGuid, int quantity)
          Updates an existing cart item in the shopping cart, found by the guid of its product SKU.
 CartItem updateCartItemById(long cartItemId, java.lang.String skuGuid, int quantity)
          Updates an existing cart item in the shopping cart.
 
Methods inherited from interface com.elasticpath.domain.Entity
getGuid, setGuid
 
Methods inherited from interface com.elasticpath.domain.Persistence
executeBeforePersistAction, getUidPk, isPersistent, setDefaultValues, setUidPk
 
Methods inherited from interface com.elasticpath.domain.EpDomain
getElasticPath, setElasticPath
 

Method Detail

addAssociatedCartItem

CartItem addAssociatedCartItem(ProductAssociation productAssociation,
                               CartItem parentCartItem)
Adds an item to the cart where the source of the item information is a ProductAssociation.

Parameters:
productAssociation - the ProductAssociation referencing the item to be added
parentCartItem - the CartItem containing the product that is the source of the ProductAssociation
Returns:
the created CartItem containing the target of the ProductAssociation

addCartItem

CartItem addCartItem(CartItem cartItem)
Add an item to the cart. If a cart item exists the the same SKU as the given cart item, then the existing cart item will be updated to reflect the sum of the previous cart item quantity and the quantity of the new cart item.

Parameters:
cartItem - the CartItem to add
Returns:
the added cart item.

addCartItem

CartItem addCartItem(ProductSku productSku,
                     int quantity)
Convenience method for adding an item to the cart.

Parameters:
productSku - the SKU to be added to the cart
quantity - the quantity of the SKU to be added
Returns:
the new CartItem representing the item in the cart

addWishListItem

CartItem addWishListItem(ProductSku productSku)
Convenience method for adding an item to the wishlist.

Parameters:
productSku - the SKU to be added to the wishlist *
Returns:
the new CartItem representing the item in the wishlist

allowCheckout

boolean allowCheckout()
Returns true if the shopping cart is in a state that the customer can proceed with a checkout. Currently, this means that there is at least one item in the cart and that there is sufficient inventory for all items in the cart.

Returns:
true if checkout can proceed

calculateShoppingCartTaxAndBeforeTaxPrices

void calculateShoppingCartTaxAndBeforeTaxPrices()
Calculate the taxes and before-tax prices for the giveing shoppingCart, including cart item and shipping cost. The calculation results will be set in the given shopping cart.


clearEstimates

void clearEstimates()
Removes shipping and tax estimates from the shopping cart.


clearItems

void clearItems()
Empties the shopping cart (e.g. after a checkout)


clearSelectedShippingServiceLevel

void clearSelectedShippingServiceLevel()
Resets the selected ShippingServiceLevel to null.


fireRules

void fireRules()
Forces the shopping cart to apply promotion rules. Promotion rules will usually be applied by the cart automatically as required. However, it is sometimes necessary to force the cart to fire rules when the cart is loaded without a state change.


getAppliedRules

java.util.Set getAppliedRules()
Get the set of rules that have been applied to the cart.

Returns:
a set of Long Rule UidPks

getBeforeTaxShippingCost

Money getBeforeTaxShippingCost()
Return the before-tax shippingCost.

Returns:
the before-tax shippingCost.

getBeforeTaxSubTotal

Money getBeforeTaxSubTotal()
Return the before-tax subtotal.

Returns:
the before-tax subtotal.

getBeforeTaxTotal

Money getBeforeTaxTotal()
Return the before-tax total.

Returns:
the before-tax total.

getBillingAddress

Address getBillingAddress()
Get the preferred billing address.

Returns:
the preferred shipping address

getBrowsingResultHistory

CatalogViewResultHistory getBrowsingResultHistory()
Returns the browsing result history stored. If none is stored, a new one will be created and returned.

Returns:
the browsing result history

getCartItem

CartItem getCartItem(java.lang.String skuGuid)
Get a cart item by the GUID of its SKU.

Parameters:
skuGuid - the GUID of the SKU in the cart item to be retrieved.
Returns:
the corresponding CartItem or null if not found

getCartItemById

CartItem getCartItemById(long cartItemId)
Returns the cart item with the given id.

Parameters:
cartItemId - the cart item id
Returns:
the cart item with the given id

getCartItems

java.util.List getCartItems()
Get the cart items in the shopping cart.

Returns:
the cart items in the shopping cart

getCartProducts

java.util.List getCartProducts()
Get the products in the shopping cart.

Returns:
the products in the shopping cart

getCatalogViewResultHistory

CatalogViewResultHistory getCatalogViewResultHistory()
Returns the catalog view result history stored. A catalog view result history might be a search or a browsing. If none is stored, return null

Returns:
the catalog view result history

getCompletedOrder

Order getCompletedOrder()
Get a reference to the completed order for the items previously checked out.

Returns:
the completed Order, or null if no completed order has been set.

getCurrency

java.util.Currency getCurrency()
Get the currency of the customer corresponding to the shopping cart.

Returns:
the Currency

getCustomerSession

CustomerSession getCustomerSession()
Return the CustomerSession. instance. Customer sessions track information about sessions where the customer may not be logged in.

Returns:
the CustomerSession instance

getCustomerSessionGuid

java.lang.String getCustomerSessionGuid()
Return the guid of the customer session that corresponds to this shopping cart.

Returns:
the guid.

getIpAddress

java.lang.String getIpAddress()
Get the ipAddress of the user from the shopping cart.

Returns:
the ipAddress

getLastCategory

Category getLastCategory()
Returns the last category.

Returns:
the last category

getLocale

java.util.Locale getLocale()
Get the locale of the customer corresponding to the shopping cart.

Returns:
the Locale

getLocalizedTaxMap

java.util.Map getLocalizedTaxMap()
Return the localized tax category name -> tax value (Money) map for this ShoppingCart.

Returns:
the localized tax category name -> tax value (Money) map.

getNumItems

int getNumItems()
Return the number of items in the shopping cart.

Returns:
the number of items

getProductAssociationsByType

java.util.List getProductAssociationsByType(int associationType,
                                            int maxAssociations,
                                            boolean filter)
Get a list of ProductAssociations that specify associations between items in the cart and other related products. The product associations are returned in decreasing order of the sales quantity of the targetted product.

Parameters:
associationType - the type of the ProductAssociations to be returned. Use a constant defined in the ProductAssociation interface
maxAssociations - the maximum number of associations to return
filter - when true will filter the results to remove any ProductAssociations allready in the shopping cart. *
Returns:
the ProductAssociations, ordered by number of sales.

getPromotionCode

java.lang.String getPromotionCode()
Get the promotion code entered by the user.

Returns:
the promotion code

getRemovedCartItems

java.util.List getRemovedCartItems()
Get the cart items that have been removed from the shopping cart.

Returns:
the removed cart items in the shopping cart

getSearchResultHistory

CatalogViewResultHistory getSearchResultHistory()
Returns the search result history stored. If none is stored, a new one will be created and returned.

Returns:
the search result history

getSelectedShippingServiceLevel

ShippingServiceLevel getSelectedShippingServiceLevel()
Get the selectedShippingServiceLevel.

Returns:
the selected ShippingServiceLevel.

getShippingAddress

Address getShippingAddress()
Get the preferred shipping address.

Returns:
the preferred shipping address

getShippingCost

Money getShippingCost()
Return the shippingCost of the ShoppingCart.

Returns:
the shippingCost of the ShoppingCart

getShippingServiceLevelList

java.util.List getShippingServiceLevelList()
Return the list of shippingServiceLevel list available based on the current shopping cart info.

Returns:
the list of shippingServiceLevel list available based on the current shopping cart info.

getSubtotal

java.math.BigDecimal getSubtotal()
Get the subtotal of all items in the cart.

Returns:
a BigDecimal object representing the subtotal

getSubtotalDiscount

java.math.BigDecimal getSubtotalDiscount()
Get the discount to the shopping cart subtotal.

Returns:
the amount discounted from the subtotal

getSubtotalDiscountMoney

Money getSubtotalDiscountMoney()
Get the amount discounted from the order subtotal.

Returns:
the order subtotal discount as a Money object

getSubtotalMoney

Money getSubtotalMoney()
Get the subtotal of all items in the cart.

Returns:
a Money object representing the subtotal

getTaxMap

java.util.Map getTaxMap()
Return the TaxCategory -> tax value (Money) map for this ShoppingCart.

Returns:
the TaxCategory -> tax value (Money) map.

getTotal

java.math.BigDecimal getTotal()
Get the sub total of all items in the cart after shipping, promotions, etc.

Returns:
a BigDecimal object representing the total

getTotalMoney

Money getTotalMoney()
Get the sub total of all items in the cart after shipping, promotions, etc.

Returns:
a Money object representing the total

getTotalWeight

java.math.BigDecimal getTotalWeight()
Get the totalWeight of items in ShoppingCart.

Returns:
totalWeight

getViewHistory

ViewHistory getViewHistory()
Get the View History of the user from the shopping cart.

Returns:
the ViewHistory

getWishListItems

java.util.List getWishListItems()
Get the wish list items in the shopping cart.

Returns:
the wish list items in the shopping cart

hasSubtotalDiscount

boolean hasSubtotalDiscount()
Returns true if an order subtotal discount has been applied.

Returns:
true if an order subtotal discount has been applied

init

void init()
Initializes the shopping cart. Call setElasticPath before initializing.


isEstimateMode

boolean isEstimateMode()
Get the indicator of whether in the estimate shipping and taxes mode.

Returns:
true when estimating shipping and taxes; otherwise, false.

isInclusiveTaxCalculationInUse

boolean isInclusiveTaxCalculationInUse()
Return true if the "inclusive" tax calculation method is in use; otherwise false. This is based on the shippingAddress.

Returns:
true if the "inclusive" tax calculation method is in use; otherwise false.

isPromotionCodeAccepted

boolean isPromotionCodeAccepted()
Indicates if the promotion code set by the user is valid.

Returns:
true if the promotion code is valid.

removeCartItem

void removeCartItem(long itemUid)
Remove an item from the cart.

Parameters:
itemUid - the uidPk of the CartItem to remove

removeWishListItem

void removeWishListItem(long itemUid)
Remove an item from the wish list.

Parameters:
itemUid - the uidPk of the CartItem to remove

requiresShipping

boolean requiresShipping()
Returns true if the cart contains items that must be shipped to the customer.

Returns:
true if the cart contains items that must be shipped to the customer.

ruleApplied

void ruleApplied(long ruleId)
Indicates that the given rule was applied by the promotion rule engine.

Parameters:
ruleId - the uidPk of the Rule

setBillingAddress

void setBillingAddress(Address address)
Set the preferred billing address.

Parameters:
address - the Address

setCartItems

void setCartItems(java.util.List cartItems)
Set the cart items in the shopping cart.

Parameters:
cartItems - the cart items in the shopping cart.

setCompletedOrder

void setCompletedOrder(Order order)
Set a reference to the completed order for the items previously checked out.

Parameters:
order - the completed order

setCurrency

void setCurrency(java.util.Currency currency)
Set the currency of the customer corresponding to the shopping cart.

Parameters:
currency - the Currency

setCustomerSession

void setCustomerSession(CustomerSession customerSession)
Set the CustomerSession. instance. Customer sessions track information about sessions where the customer may not be logged in.

Parameters:
customerSession - the CustomerSession instance

setCustomerSessionGuid

void setCustomerSessionGuid(java.lang.String guid)
Set the guid of the customer session that corresponds to this shopping cart.

Parameters:
guid - the guid to set.

setEstimateMode

void setEstimateMode(boolean estimateMode)
Set the indicator of whether in the estimate shipping and taxes mode.

Parameters:
estimateMode - true when estimating shipping and taxes; otherwise, false.

setIpAddress

void setIpAddress(java.lang.String ipAddress)
Set the users ip Address into the shopping cart.

Parameters:
ipAddress - the ipAddress of the user.

setLastCategory

void setLastCategory(Category category)
Sets the last category.

Parameters:
category - the category to set.

setLocale

void setLocale(java.util.Locale locale)
Set the locale of the customer corresponding to the shopping cart.

Parameters:
locale - the Locale

setPromotionCode

void setPromotionCode(java.lang.String promotionCode)
Set the promotion code entered by the user.

Parameters:
promotionCode - the promotion code

setPromotionCodeAccepted

void setPromotionCodeAccepted(boolean promotionCodeAccepted)
Set whether or not the promotion code entered by the user is valid.

Parameters:
promotionCodeAccepted - set to true if the promotion code is valid

setSelectedShippingServiceLevelUid

Money setSelectedShippingServiceLevelUid(long selectedSSLUid)
Set the selectedShippingServiceLevelUid and update the shippingCost correspondingly.

Parameters:
selectedSSLUid - - the selected ShippingServiceLevel uid.
Returns:
shippingCost

setShippingAddress

void setShippingAddress(Address address)
Set the preferred shipping address.

Parameters:
address - the Address

setShippingServiceLevelList

void setShippingServiceLevelList(java.util.List shippingServiceLevelList)
Set the list of shippingServiceLevel list available based on the current shopping cart info.

Parameters:
shippingServiceLevelList - the list of shippingServiceLevel list available based on the current shopping cart info.

setSubtotalDiscount

void setSubtotalDiscount(java.math.BigDecimal discountAmount)
Applies a discount to the shopping cart subtotal.

Parameters:
discountAmount - the amount to discount the subtotal by as a BigInteger

setTaxJurisdiction

void setTaxJurisdiction(TaxJurisdiction taxJurisdiction)
Set the most specific TaxJurisdiction based on the shippingAddress of this ShoppingCart.

Parameters:
taxJurisdiction - the most specific TaxJurisdiction

setWishListItems

void setWishListItems(java.util.List wishListItems)
Set the wish list items in the shopping cart.

Parameters:
wishListItems - the wish list items in the shopping cart.

updateCartItemByGuid

CartItem updateCartItemByGuid(java.lang.String skuGuid,
                              int quantity)
Updates an existing cart item in the shopping cart, found by the guid of its product SKU. Becaue the cart item id is not known, the SKU cannot be changed using this method. To change the SKU of an existing cart item, call updateCartItemById.

Parameters:
skuGuid - The GUID of the particular SKU in the cart item to be updated
quantity - the quantity of the given cart item to appear in the cart
Returns:
the updated CartItem

updateCartItemById

CartItem updateCartItemById(long cartItemId,
                            java.lang.String skuGuid,
                            int quantity)
Updates an existing cart item in the shopping cart.

Parameters:
cartItemId - the UID of the cart item to be updated. The suppliced UID must match a cart item in the cart.
skuGuid - The GUID of the particular SKU to be in the cart. If skuGuid is null or "", then the sku in the cart item will not be updated. If the skuGuid is specified, then the SKU in the cart item will be changed to the one matching the specified GUID. An exception will be thrown if the GUID does not match a SKU from the previous SKU's product (Changing the product is not an update operation).
quantity - the quantity of the given cart item to appear in the cart
Returns:
the updated CartItem