info.magnolia.module.shop.beans
Class ShoppingCartItem
java.lang.Object
ch.fastforward.magnolia.ocm.beans.OCMBean
info.magnolia.module.shop.beans.ShoppingCartItem
- All Implemented Interfaces:
- Serializable
public class ShoppingCartItem
- extends ch.fastforward.magnolia.ocm.beans.OCMBean
- implements Serializable
Default shopping cart item bean containing all the product info. The item
also calculates the tax and discount prices.
NOTE: If you do the math in Java using doubles (or floats as a matter of
fact) you'll end up with something like 126.8999999999999 instead of 126.9.
According to this article
(http://java.sun.com/mailers/techtips/corejava/2007/tt0707.html#2) Sun
suggests to use BigDescimal objects. Since we need to store Double objects in
the repository, this leaves us with a bit of a conversion mess... and when
converting from double/float to BigDecimal apparently the only save way to go
is via a String (i.e. new BigDecimal("126.9")!
- Author:
- will
- See Also:
- Serialized Form
Constructor Summary |
ShoppingCartItem(DefaultShoppingCartImpl cart,
javax.jcr.Node product,
int quantity,
javax.jcr.Node productPrice)
|
ShoppingCartItem(DefaultShoppingCartImpl cart,
javax.jcr.Node product,
int quantity,
javax.jcr.Node productPrice,
Map<String,CartItemOption> options)
|
ShoppingCartItem(DefaultShoppingCartImpl cart,
String productUUID,
int quantity,
double unitPrice)
|
ShoppingCartItem(DefaultShoppingCartImpl cart,
String productUUID,
int quantity,
double unitPrice,
Map<String,CartItemOption> options)
|
Methods inherited from class ch.fastforward.magnolia.ocm.beans.OCMBean |
getName, getParentPath, getPath, getUuid, setName, setParentPath, setPath, setUuid |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ShoppingCartItem
public ShoppingCartItem(DefaultShoppingCartImpl cart,
javax.jcr.Node product,
int quantity,
javax.jcr.Node productPrice,
Map<String,CartItemOption> options)
ShoppingCartItem
public ShoppingCartItem(DefaultShoppingCartImpl cart,
javax.jcr.Node product,
int quantity,
javax.jcr.Node productPrice)
ShoppingCartItem
public ShoppingCartItem(DefaultShoppingCartImpl cart,
String productUUID,
int quantity,
double unitPrice,
Map<String,CartItemOption> options)
ShoppingCartItem
public ShoppingCartItem(DefaultShoppingCartImpl cart,
String productUUID,
int quantity,
double unitPrice)
getProduct
public javax.jcr.Node getProduct()
setProduct
public void setProduct(javax.jcr.Node product)
getQuantity
public int getQuantity()
setQuantity
public void setQuantity(int quantity)
getUnitPrice
public double getUnitPrice()
getUnitPriceExclTax
public double getUnitPriceExclTax()
- For shops with prices inclusive tax which need to display the price
exclusive tax too.
- Returns:
- unit price minus tax for prices incl. tax or unit price for prices excl. tax.
setUnitPrice
public void setUnitPrice(double unitPrice)
setProductPrice
public void setProductPrice(javax.jcr.Node productPrice)
throws javax.jcr.ValueFormatException,
javax.jcr.RepositoryException
- Throws:
javax.jcr.ValueFormatException
javax.jcr.RepositoryException
getProductNumber
public String getProductNumber()
setProductNumber
public void setProductNumber(String productNumber)
- Parameters:
productNumber
- the productNumber to set
getProductUUID
public String getProductUUID()
getShoppingCartUUID
public String getShoppingCartUUID()
setShoppingCartUUID
public void setShoppingCartUUID(String shoppingCartUUID)
getCart
public DefaultShoppingCartImpl getCart()
setCart
public void setCart(DefaultShoppingCartImpl cart)
getProductTitle
public String getProductTitle()
setProductTitle
public void setProductTitle(String productTitle)
getProductSubTitle
public String getProductSubTitle()
setProductSubTitle
public void setProductSubTitle(String productSubTitle)
getProductDescription
public String getProductDescription()
setProductDescription
public void setProductDescription(String productDescription)
getItemTotal
public double getItemTotal()
getItemTotalBigDecimal
public BigDecimal getItemTotalBigDecimal()
getItemTaxBigDecimal
public BigDecimal getItemTaxBigDecimal()
getItemTax
public double getItemTax()
getItemTotalExclTaxBigDecimal
public BigDecimal getItemTotalExclTaxBigDecimal()
getItemTotalExclTax
public double getItemTotalExclTax()
getItemTotalInclTaxBigDecimal
public BigDecimal getItemTotalInclTaxBigDecimal()
getItemTotalInclTax
public double getItemTotalInclTax()
getItemDiscountRate
public BigDecimal getItemDiscountRate()
- Returns:
- the itemDiscountRate
setItemDiscountRate
public void setItemDiscountRate(BigDecimal itemDiscountRate)
- Parameters:
itemDiscountRate
- the itemDiscountRate to set
getItemTaxRate
public BigDecimal getItemTaxRate()
- Returns:
- the itemTaxRate
setItemTaxRate
public void setItemTaxRate(BigDecimal itemTaxRate)
- Parameters:
itemTaxRate
- the itemTaxRate to set
getOptions
public Map<String,CartItemOption> getOptions()
- Returns:
- the options
setOptions
public void setOptions(Map<String,CartItemOption> options)
- Parameters:
options
- the options to set
isOptionsMatching
public boolean isOptionsMatching(Map<String,CartItemOption> options)
getUnitWeight
public BigDecimal getUnitWeight()
- Returns:
- the unitWeight
setUnitWeight
public void setUnitWeight(BigDecimal unitWeight)
- Parameters:
unitWeight
- the unitWeight to set
getItemWeight
public BigDecimal getItemWeight()
- Returns:
- the total weight of this cart item or null if no weight was
specified
getUnitHeight
public BigDecimal getUnitHeight()
- Returns:
- the unitHeight
setUnitHeight
public void setUnitHeight(BigDecimal unitHeight)
- Parameters:
unitHeight
- the unitHeight to set
getUnitWidth
public BigDecimal getUnitWidth()
- Returns:
- the unitWidth
setUnitWidth
public void setUnitWidth(BigDecimal unitWidth)
- Parameters:
unitWidth
- the unitWidth to set
getUnitDepth
public BigDecimal getUnitDepth()
- Returns:
- the unitDepth
setUnitDepth
public void setUnitDepth(BigDecimal unitDepth)
- Parameters:
unitDepth
- the unitDepth to set
Copyright © 2014 Magnolia International Ltd.. All Rights Reserved.