|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.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 ProductAssociation s 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 ShoppingCart
productAssociation
- 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 ProductAssociation
public CartItem addCartItem(CartItem cartItem)
addCartItem
in interface ShoppingCart
cartItem
- the CartItem
to add
public CartItem addCartItem(ProductSku productSku, int quantity)
addCartItem
in interface ShoppingCart
productSku
- 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 ShoppingCart
productSku
- the SKU to be added to the wishlist *
CartItem
representing the item in the wishlistpublic boolean allowCheckout()
allowCheckout
in interface ShoppingCart
public void calculateShoppingCartTaxAndBeforeTaxPrices()
calculateShoppingCartTaxAndBeforeTaxPrices
in interface ShoppingCart
public void clearEstimates()
clearEstimates
in interface ShoppingCart
public void clearItems()
clearItems
in interface ShoppingCart
public void clearSelectedShippingServiceLevel()
ShippingServiceLevel
to null.
clearSelectedShippingServiceLevel
in interface ShoppingCart
public void fireRules()
fireRules
in interface ShoppingCart
public java.util.Set getAppliedRules()
getAppliedRules
in interface ShoppingCart
Long
Rule UidPkspublic Money getBeforeTaxShippingCost()
getBeforeTaxShippingCost
in interface ShoppingCart
public Money getBeforeTaxSubTotal()
getBeforeTaxSubTotal
in interface ShoppingCart
public Money getBeforeTaxTotal()
getBeforeTaxTotal
in interface ShoppingCart
public Address getBillingAddress()
getBillingAddress
in interface ShoppingCart
public CatalogViewResultHistory getBrowsingResultHistory()
getBrowsingResultHistory
in interface ShoppingCart
public CartItem getCartItem(java.lang.String skuGuid)
getCartItem
in interface ShoppingCart
skuGuid
- 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 ShoppingCart
cartItemId
- the cart item id
public java.util.List getCartItems()
getCartItems
in interface ShoppingCart
public java.util.List getCartProducts()
getCartProducts
in interface ShoppingCart
public CatalogViewResultHistory getCatalogViewResultHistory()
null
getCatalogViewResultHistory
in interface ShoppingCart
public Order getCompletedOrder()
getCompletedOrder
in interface ShoppingCart
public java.util.Currency getCurrency()
getCurrency
in interface ShoppingCart
Currency
public CustomerSession getCustomerSession()
CustomerSession
. instance. Customer sessions track information about sessions where the customer may not be logged
in.
getCustomerSession
in interface ShoppingCart
CustomerSession
instancepublic java.lang.String getCustomerSessionGuid()
getCustomerSessionGuid
in interface ShoppingCart
public java.lang.String getIpAddress()
getIpAddress
in interface ShoppingCart
public Category getLastCategory()
getLastCategory
in interface ShoppingCart
public java.util.Locale getLocale()
getLocale
in interface ShoppingCart
Locale
public java.util.Map getLocalizedTaxMap()
Money
) map for this ShoppingCart
.
getLocalizedTaxMap
in interface ShoppingCart
Money
) map.public int getNumItems()
getNumItems
in interface ShoppingCart
public java.util.List getProductAssociationsByType(int associationType, int maxAssociations, boolean filter)
ProductAssociation
s 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 ShoppingCart
associationType
- the type of the ProductAssociation
s 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.
ProductAssociation
s, ordered by number of sales.public java.lang.String getPromotionCode()
getPromotionCode
in interface ShoppingCart
public java.util.List getRemovedCartItems()
getRemovedCartItems
in interface ShoppingCart
public CatalogViewResultHistory getSearchResultHistory()
CatalogViewResultHistory
instance stored. If none is stored, a new one will be created and returned.
getSearchResultHistory
in interface ShoppingCart
CatalogViewResultHistory
instance storedpublic ShippingServiceLevel getSelectedShippingServiceLevel()
getSelectedShippingServiceLevel
in interface ShoppingCart
public Address getShippingAddress()
getShippingAddress
in interface ShoppingCart
public Money getShippingCost()
ShoppingCart
.
getShippingCost
in interface ShoppingCart
ShoppingCart
public java.util.List getShippingServiceLevelList()
getShippingServiceLevelList
in interface ShoppingCart
public java.math.BigDecimal getSubtotal()
getSubtotal
in interface ShoppingCart
BigDecimal
object representing the subtotalpublic java.math.BigDecimal getSubtotalDiscount()
getSubtotalDiscount
in interface ShoppingCart
public Money getSubtotalDiscountMoney()
getSubtotalDiscountMoney
in interface ShoppingCart
Money
objectpublic Money getSubtotalMoney()
getSubtotalMoney
in interface ShoppingCart
Money
object representing the subtotalpublic java.util.Map getTaxMap()
TaxCategory
-> tax value (Money
) map for this ShoppingCart
.
getTaxMap
in interface ShoppingCart
TaxCategory
-> tax value (Money
) map.public java.math.BigDecimal getTotal()
getTotal
in interface ShoppingCart
BigDecimal
object representing the totalpublic Money getTotalMoney()
getTotalMoney
in interface ShoppingCart
Money
object representing the totalpublic java.math.BigDecimal getTotalWeight()
ShoppingCart
.
getTotalWeight
in interface ShoppingCart
public ViewHistory getViewHistory()
getViewHistory
in interface ShoppingCart
public java.util.List getWishListItems()
getWishListItems
in interface ShoppingCart
public boolean hasSubtotalDiscount()
hasSubtotalDiscount
in interface ShoppingCart
public void init()
init
in interface ShoppingCart
public boolean isEstimateMode()
isEstimateMode
in interface ShoppingCart
public boolean isInclusiveTaxCalculationInUse()
isInclusiveTaxCalculationInUse
in interface ShoppingCart
public boolean isPromotionCodeAccepted()
isPromotionCodeAccepted
in interface ShoppingCart
public void removeCartItem(long itemUid)
removeCartItem
in interface ShoppingCart
itemUid
- the uidPk of the CartItem
to removepublic void removeWishListItem(long itemUid)
removeWishListItem
in interface ShoppingCart
itemUid
- the uidPk of the CartItem
to removepublic boolean requiresShipping()
requiresShipping
in interface ShoppingCart
public void ruleApplied(long ruleId)
ruleApplied
in interface ShoppingCart
ruleId
- the uidPk of the Rule
public void setBillingAddress(Address address)
setBillingAddress
in interface ShoppingCart
address
- the Address
public void setCartItems(java.util.List cartItems)
setCartItems
in interface ShoppingCart
cartItems
- the cart items in the shopping cart.public void setCompletedOrder(Order order)
setCompletedOrder
in interface ShoppingCart
order
- the completed orderpublic void setCurrency(java.util.Currency currency)
setCurrency
in interface ShoppingCart
currency
- the Currency
public void setCustomerSession(CustomerSession customerSession)
CustomerSession
. instance. Customer sessions track information about sessions where the customer may not be logged in.
setCustomerSession
in interface ShoppingCart
customerSession
- the CustomerSession
instancepublic void setCustomerSessionGuid(java.lang.String guid)
CustomerSession
instead.
setCustomerSessionGuid
in interface ShoppingCart
guid
- the guid to set.public void setEstimateMode(boolean estimateMode)
setEstimateMode
in interface ShoppingCart
estimateMode
- true when estimating shipping and taxes; otherwise, false.public void setIpAddress(java.lang.String ipAddress)
setIpAddress
in interface ShoppingCart
ipAddress
- the ipAddress of the user.public void setLastCategory(Category category)
setLastCategory
in interface ShoppingCart
category
- the category to set.public void setLocale(java.util.Locale locale)
setLocale
in interface ShoppingCart
locale
- the Locale
public void setPromotionCode(java.lang.String promotionCode)
setPromotionCode
in interface ShoppingCart
promotionCode
- the promotion codepublic void setPromotionCodeAccepted(boolean promotionCodeAccepted)
setPromotionCodeAccepted
in interface ShoppingCart
promotionCodeAccepted
- set to true if the promotion code is validpublic Money setSelectedShippingServiceLevelUid(long selectedShippingServiceLevelUid) throws EpDomainException
setSelectedShippingServiceLevelUid
in interface ShoppingCart
selectedShippingServiceLevelUid
- - the selected ShippingServiceLevel uid.
EpDomainException
- - if something goes wrong.public void setShippingAddress(Address address)
setShippingAddress
in interface ShoppingCart
address
- the Address
public void setShippingServiceLevelList(java.util.List shippingServiceLevelList)
setShippingServiceLevelList
in interface ShoppingCart
shippingServiceLevelList
- the list of shippingServiceLevel list available based on the current shopping cart info.public void setSubtotalDiscount(java.math.BigDecimal discountAmount)
setSubtotalDiscount
in interface ShoppingCart
discountAmount
- 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 ShoppingCart
taxJurisdiction
- the most specific TaxJurisdiction
public void setWishListItems(java.util.List wishListItems)
setWishListItems
in interface ShoppingCart
wishListItems
- the wishList items in the shopping cart.public CartItem updateCartItemByGuid(java.lang.String skuGuid, int quantity)
updateCartItemByGuid
in interface ShoppingCart
skuGuid
- 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 ShoppingCart
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
CartItem
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |