com.elasticpath.domain.shoppingcart
Interface CartItem

All Superinterfaces:
EpDomain, Persistence, java.io.Serializable, ValueObject
All Known Subinterfaces:
CartItemBean
All Known Implementing Classes:
AbstractCartItemImpl, CartItemBeanImpl, ShoppingCartItemImpl, WishListItemImpl

public interface CartItem
extends ValueObject

A CartItem represents a quantity of SKUs in a shopping cart, saved cart, wish list, etc.


Method Summary
 void addDependentCartItem(CartItem dependentCartItem)
          Specify that another cart item depends on this cart item.
 void applyDiscount(java.math.BigDecimal amount)
          Adds a discount amount to this cart item.
 void clearDiscount()
          Removes previously applied CartItem discounts.
 java.math.BigDecimal getAmount(java.util.Currency currency)
          Get the total price of this shopping cart item.
 Money getAmountMoney(java.util.Currency currency)
          Get the amount as a Money object.
 java.util.Set getDependentCartItems()
          Get the set of dependent cart items.
 CartItem getParentCartItem()
          Get the parent cart item that this cart item is dependent on.
 ProductSku getProductSku()
          Get the product SKU corresponding to this item in a cart.
 int getQuantity()
          Get the quantity of this item.
 java.lang.String getType()
          Get the type of action, i.e.
 boolean hasDependentCartItem(java.lang.String skuCode)
          Returns true if this CartItem has another cart items that depend on it which matches the supplied skuCode.
 boolean hasDependentCartItems()
          Returns true if this CartItem has other cart items that depend on it such that the dependent items cannot exist in the cart on their own.
 boolean hasSufficientInventory()
          Returns true if there is sufficent stock to sell this cart item (in the quantity set in the CartItem).
 boolean isDependent()
          Returns true if this CartItem depends on another cart item such that it can't exist in the cart on its own.
 void setDependentCartItems(java.util.Set dependentCartItems)
          Set the set of dependent cart items.
 void setParentCartItem(CartItem parentCartItem)
          Set the parent cart item that this cart item is dependent on.
 void setProductSku(ProductSku productSku)
          Set the product SKU corresponding to this item in a cart.
 void setQuantity(int quantity)
          Set the quantity of this item.
 void setType(java.lang.String type)
          Set the type of action.
 
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

addDependentCartItem

void addDependentCartItem(CartItem dependentCartItem)
Specify that another cart item depends on this cart item.

Parameters:
dependentCartItem - the other, dependent cart item

applyDiscount

void applyDiscount(java.math.BigDecimal amount)
Adds a discount amount to this cart item. This will be subtracted from the amount of the CartItem and each invocation adds to the discount.

Parameters:
amount - the amount to discount

clearDiscount

void clearDiscount()
Removes previously applied CartItem discounts.


getAmount

java.math.BigDecimal getAmount(java.util.Currency currency)
Get the total price of this shopping cart item. The total price is the price * quantity. The sale price is used in the calculation.

Parameters:
currency - the currency of the total price to be returned
Returns:
a BigDecimal object representing the total price

getAmountMoney

Money getAmountMoney(java.util.Currency currency)
Get the amount as a Money object.

Parameters:
currency - the currency of the total price to be returned
Returns:
a Money object representing the total price

getDependentCartItems

java.util.Set getDependentCartItems()
Get the set of dependent cart items.

Returns:
the set of dependent cart items.

getParentCartItem

CartItem getParentCartItem()
Get the parent cart item that this cart item is dependent on. Returns null if this cart item does not depend on another.

Returns:
the parent cart item or null if there is no parent.

getProductSku

ProductSku getProductSku()
Get the product SKU corresponding to this item in a cart. This is the hibernate tag for one-to-one relationships that don't join on the primary key:

Returns:
a ProductSKU

getQuantity

int getQuantity()
Get the quantity of this item.

Returns:
the quantity

getType

java.lang.String getType()
Get the type of action, i.e. cartItem, wishListItem etc. Make sure it matches the bean id in spring configuration for the implementation of an action.

Returns:
the action type

hasDependentCartItem

boolean hasDependentCartItem(java.lang.String skuCode)
Returns true if this CartItem has another cart items that depend on it which matches the supplied skuCode.

Parameters:
skuCode - The GUID of the particular dependant SKU to be in the cart.
Returns:
true if this CartItem has a depenant item that matches the supplied skuCode

hasDependentCartItems

boolean hasDependentCartItems()
Returns true if this CartItem has other cart items that depend on it such that the dependent items cannot exist in the cart on their own.

Returns:
true if this CartItem has other cart items that depend on it.

hasSufficientInventory

boolean hasSufficientInventory()
Returns true if there is sufficent stock to sell this cart item (in the quantity set in the CartItem).

Returns:
true if there is sufficient stock

isDependent

boolean isDependent()
Returns true if this CartItem depends on another cart item such that it can't exist in the cart on its own.

Returns:
true if this CartItem depends on another cart item.

setDependentCartItems

void setDependentCartItems(java.util.Set dependentCartItems)
Set the set of dependent cart items.

Parameters:
dependentCartItems - the set of dependent cart items.

setParentCartItem

void setParentCartItem(CartItem parentCartItem)
Set the parent cart item that this cart item is dependent on.

Parameters:
parentCartItem - the parent cart item.

setProductSku

void setProductSku(ProductSku productSku)
Set the product SKU corresponding to this item in a cart.

Parameters:
productSku - the ProductSKU

setQuantity

void setQuantity(int quantity)
Set the quantity of this item.

Parameters:
quantity - the quantity

setType

void setType(java.lang.String type)
Set the type of action.

Parameters:
type - the type of action