|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.elasticpath.domain.impl.AbstractEpDomainImpl
com.elasticpath.domain.impl.AbstractPersistenceImpl
com.elasticpath.domain.impl.AbstractEntityImpl
com.elasticpath.domain.shoppingcart.impl.ShoppingCartImpl
public class ShoppingCartImpl
The default implementation of ShoppingCart.
Note: The guid of a shopping cart is actually the guid of the customer session it belongs to.
| Field Summary | |
|---|---|
static long |
serialVersionUID
Serial version id. |
| Constructor Summary | |
|---|---|
ShoppingCartImpl()
Default Constructor. |
|
| 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 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 CatalogViewResultHistory instance stored. |
ShippingServiceLevel |
getSelectedShippingServiceLevel()
Get the selectedShippingServiceLevel. |
Address |
getShippingAddress()
Get the 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 wishList 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 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 selectedShippingServiceLevelUid)
Set the selectedShippingServiceLevelUid and update the shippingCost correspondingly. |
void |
setShippingAddress(Address address)
Set the 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 wishList 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 class com.elasticpath.domain.impl.AbstractEntityImpl |
|---|
convertAttributeGroupAttributes, getGuid, setDefaultValues, setGuid |
| Methods inherited from class com.elasticpath.domain.impl.AbstractPersistenceImpl |
|---|
executeBeforePersistAction, getUidPk, isPersistent, setUidPk |
| Methods inherited from class com.elasticpath.domain.impl.AbstractEpDomainImpl |
|---|
getElasticPath, setElasticPath |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 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 |
| Field Detail |
|---|
public static final long serialVersionUID
| Constructor Detail |
|---|
public ShoppingCartImpl()
| Method Detail |
|---|
public CartItem addAssociatedCartItem(ProductAssociation productAssociation,
CartItem parentCartItem)
ProductAssociation.
addAssociatedCartItem in interface ShoppingCartproductAssociation - the ProductAssociation referencing the item to be addedparentCartItem - the CartItem containing the product that is the source of the ProductAssociation
CartItem containing the target of the ProductAssociationpublic CartItem addCartItem(CartItem cartItem)
addCartItem in interface ShoppingCartcartItem - the CartItem to add
public CartItem addCartItem(ProductSku productSku,
int quantity)
addCartItem in interface ShoppingCartproductSku - the SKU to be added to the cartquantity - the quantity of the SKU to be added
CartItem representing the item in the cartpublic CartItem addWishListItem(ProductSku productSku)
addWishListItem in interface ShoppingCartproductSku - the SKU to be added to the wishlist *
CartItem representing the item in the wishlistpublic boolean allowCheckout()
allowCheckout in interface ShoppingCartpublic void calculateShoppingCartTaxAndBeforeTaxPrices()
calculateShoppingCartTaxAndBeforeTaxPrices in interface ShoppingCartpublic void clearEstimates()
clearEstimates in interface ShoppingCartpublic void clearItems()
clearItems in interface ShoppingCartpublic void clearSelectedShippingServiceLevel()
ShippingServiceLevel to null.
clearSelectedShippingServiceLevel in interface ShoppingCartpublic void fireRules()
fireRules in interface ShoppingCartpublic java.util.Set getAppliedRules()
getAppliedRules in interface ShoppingCartLong Rule UidPkspublic Money getBeforeTaxShippingCost()
getBeforeTaxShippingCost in interface ShoppingCartpublic Money getBeforeTaxSubTotal()
getBeforeTaxSubTotal in interface ShoppingCartpublic Money getBeforeTaxTotal()
getBeforeTaxTotal in interface ShoppingCartpublic Address getBillingAddress()
getBillingAddress in interface ShoppingCartpublic CatalogViewResultHistory getBrowsingResultHistory()
getBrowsingResultHistory in interface ShoppingCartpublic CartItem getCartItem(java.lang.String skuGuid)
getCartItem in interface ShoppingCartskuGuid - the GUID of the SKU in the cart item to be retrieved.
CartItem or null if not foundpublic CartItem getCartItemById(long cartItemId)
getCartItemById in interface ShoppingCartcartItemId - the cart item id
public java.util.List getCartItems()
getCartItems in interface ShoppingCartpublic java.util.List getCartProducts()
getCartProducts in interface ShoppingCartpublic CatalogViewResultHistory getCatalogViewResultHistory()
null
getCatalogViewResultHistory in interface ShoppingCartpublic Order getCompletedOrder()
getCompletedOrder in interface ShoppingCartpublic java.util.Currency getCurrency()
getCurrency in interface ShoppingCartCurrencypublic CustomerSession getCustomerSession()
CustomerSession. instance. Customer sessions track information about sessions where the customer may not be logged
in.
getCustomerSession in interface ShoppingCartCustomerSession instancepublic java.lang.String getCustomerSessionGuid()
getCustomerSessionGuid in interface ShoppingCartpublic java.lang.String getIpAddress()
getIpAddress in interface ShoppingCartpublic Category getLastCategory()
getLastCategory in interface ShoppingCartpublic java.util.Locale getLocale()
getLocale in interface ShoppingCartLocalepublic java.util.Map getLocalizedTaxMap()
Money) map for this ShoppingCart.
getLocalizedTaxMap in interface ShoppingCartMoney) map.public int getNumItems()
getNumItems in interface ShoppingCart
public java.util.List getProductAssociationsByType(int associationType,
int maxAssociations,
boolean filter)
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 targeted product. Note that this method expects only a small number
of associations
getProductAssociationsByType in interface ShoppingCartassociationType - the type of the ProductAssociations to be returned. Use a constant defined in the
ProductAssociation interfacemaxAssociations - the maximum number of associations to return.filter - when true will filter the results to remove any ProductAssociations allready in the shopping cart.
ProductAssociations, ordered by number of sales.public java.lang.String getPromotionCode()
getPromotionCode in interface ShoppingCartpublic java.util.List getRemovedCartItems()
getRemovedCartItems in interface ShoppingCartpublic CatalogViewResultHistory getSearchResultHistory()
CatalogViewResultHistory instance stored. If none is stored, a new one will be created and returned.
getSearchResultHistory in interface ShoppingCartCatalogViewResultHistory instance storedpublic ShippingServiceLevel getSelectedShippingServiceLevel()
getSelectedShippingServiceLevel in interface ShoppingCartpublic Address getShippingAddress()
getShippingAddress in interface ShoppingCartpublic Money getShippingCost()
ShoppingCart.
getShippingCost in interface ShoppingCartShoppingCartpublic java.util.List getShippingServiceLevelList()
getShippingServiceLevelList in interface ShoppingCartpublic java.math.BigDecimal getSubtotal()
getSubtotal in interface ShoppingCartBigDecimal object representing the subtotalpublic java.math.BigDecimal getSubtotalDiscount()
getSubtotalDiscount in interface ShoppingCartpublic Money getSubtotalDiscountMoney()
getSubtotalDiscountMoney in interface ShoppingCartMoney objectpublic Money getSubtotalMoney()
getSubtotalMoney in interface ShoppingCartMoney object representing the subtotalpublic java.util.Map getTaxMap()
TaxCategory -> tax value (Money) map for this ShoppingCart.
getTaxMap in interface ShoppingCartTaxCategory -> tax value (Money) map.public java.math.BigDecimal getTotal()
getTotal in interface ShoppingCartBigDecimal object representing the totalpublic Money getTotalMoney()
getTotalMoney in interface ShoppingCartMoney object representing the totalpublic java.math.BigDecimal getTotalWeight()
ShoppingCart.
getTotalWeight in interface ShoppingCartpublic ViewHistory getViewHistory()
getViewHistory in interface ShoppingCartpublic java.util.List getWishListItems()
getWishListItems in interface ShoppingCartpublic boolean hasSubtotalDiscount()
hasSubtotalDiscount in interface ShoppingCartpublic void init()
init in interface ShoppingCartpublic boolean isEstimateMode()
isEstimateMode in interface ShoppingCartpublic boolean isInclusiveTaxCalculationInUse()
isInclusiveTaxCalculationInUse in interface ShoppingCartpublic boolean isPromotionCodeAccepted()
isPromotionCodeAccepted in interface ShoppingCartpublic void removeCartItem(long itemUid)
removeCartItem in interface ShoppingCartitemUid - the uidPk of the CartItem to removepublic void removeWishListItem(long itemUid)
removeWishListItem in interface ShoppingCartitemUid - the uidPk of the CartItem to removepublic boolean requiresShipping()
requiresShipping in interface ShoppingCartpublic void ruleApplied(long ruleId)
ruleApplied in interface ShoppingCartruleId - the uidPk of the Rulepublic void setBillingAddress(Address address)
setBillingAddress in interface ShoppingCartaddress - the Addresspublic void setCartItems(java.util.List cartItems)
setCartItems in interface ShoppingCartcartItems - the cart items in the shopping cart.public void setCompletedOrder(Order order)
setCompletedOrder in interface ShoppingCartorder - the completed orderpublic void setCurrency(java.util.Currency currency)
setCurrency in interface ShoppingCartcurrency - the Currencypublic void setCustomerSession(CustomerSession customerSession)
CustomerSession. instance. Customer sessions track information about sessions where the customer may not be logged in.
setCustomerSession in interface ShoppingCartcustomerSession - the CustomerSession instancepublic void setCustomerSessionGuid(java.lang.String guid)
CustomerSession instead.
setCustomerSessionGuid in interface ShoppingCartguid - the guid to set.public void setEstimateMode(boolean estimateMode)
setEstimateMode in interface ShoppingCartestimateMode - true when estimating shipping and taxes; otherwise, false.public void setIpAddress(java.lang.String ipAddress)
setIpAddress in interface ShoppingCartipAddress - the ipAddress of the user.public void setLastCategory(Category category)
setLastCategory in interface ShoppingCartcategory - the category to set.public void setLocale(java.util.Locale locale)
setLocale in interface ShoppingCartlocale - the Localepublic void setPromotionCode(java.lang.String promotionCode)
setPromotionCode in interface ShoppingCartpromotionCode - the promotion codepublic void setPromotionCodeAccepted(boolean promotionCodeAccepted)
setPromotionCodeAccepted in interface ShoppingCartpromotionCodeAccepted - set to true if the promotion code is valid
public Money setSelectedShippingServiceLevelUid(long selectedShippingServiceLevelUid)
throws EpDomainException
setSelectedShippingServiceLevelUid in interface ShoppingCartselectedShippingServiceLevelUid - - the selected ShippingServiceLevel uid.
EpDomainException - - if something goes wrong.public void setShippingAddress(Address address)
setShippingAddress in interface ShoppingCartaddress - the Addresspublic void setShippingServiceLevelList(java.util.List shippingServiceLevelList)
setShippingServiceLevelList in interface ShoppingCartshippingServiceLevelList - the list of shippingServiceLevel list available based on the current shopping cart info.public void setSubtotalDiscount(java.math.BigDecimal discountAmount)
setSubtotalDiscount in interface ShoppingCartdiscountAmount - the amount to discount the subtotal by as a BigIntegerpublic void setTaxJurisdiction(TaxJurisdiction taxJurisdiction)
TaxJurisdiction based on the shippingAddress of this ShoppingCart.
setTaxJurisdiction in interface ShoppingCarttaxJurisdiction - the most specific TaxJurisdictionpublic void setWishListItems(java.util.List wishListItems)
setWishListItems in interface ShoppingCartwishListItems - the wishList items in the shopping cart.
public CartItem updateCartItemByGuid(java.lang.String skuGuid,
int quantity)
updateCartItemByGuid in interface ShoppingCartskuGuid - The GUID of the particular SKU in the cart item to be updatedquantity - the quantity of the given cart item to appear in the cart
CartItem
public CartItem updateCartItemById(long cartItemId,
java.lang.String skuGuid,
int quantity)
updateCartItemById in interface ShoppingCartcartItemId - 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
CartItem
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||