public class DefaultJcrCartEntry extends java.lang.Object implements CommerceSession.CartEntry
CommerceSession.CartEntry
used by
AbstractJcrCommerceSession
.
Implementations requiring customization should extend this class and override
AbstractJcrCommerceService.newCartEntryImpl(int, com.adobe.cq.commerce.api.Product, int)
to return said extension.Constructor and Description |
---|
DefaultJcrCartEntry(int index,
Product product,
int quantity) |
Modifier and Type | Method and Description |
---|---|
int |
getEntryIndex() |
java.lang.String |
getPreTaxPrice()
Deprecated.
|
java.lang.String |
getPrice(Predicate filter)
Shortcut for getting a formatted string of the first matching price.
|
java.util.List<PriceInfo> |
getPriceInfo(Predicate filter)
Get a list of detailed price info objects for a cart entry filtered by the provided
predicate (usually a
PriceFilter ). |
Product |
getProduct() |
ValueMap |
getProperties()
Returns the properties of this cart entry or an empty map if there are no properties.
|
<T> T |
getProperty(java.lang.String name,
java.lang.Class<T> type)
Get a cart entry property with the given type.
|
int |
getQuantity() |
java.lang.String |
getTax()
Deprecated.
|
java.lang.String |
getTotalPrice()
Deprecated.
|
java.lang.String |
getUnitPrice()
Deprecated.
|
void |
setEntryIndex(int index) |
void |
setPrice(PriceInfo priceInfo,
java.lang.String... types)
A helper routine which updates the cart entry prices with a new
PriceInfo . |
void |
setQuantity(int quantity) |
public DefaultJcrCartEntry(int index, Product product, int quantity)
public int getEntryIndex()
getEntryIndex
in interface CommerceSession.CartEntry
public void setEntryIndex(int index)
public Product getProduct() throws CommerceException
getProduct
in interface CommerceSession.CartEntry
Product
for this entryCommerceException
public int getQuantity()
getQuantity
in interface CommerceSession.CartEntry
public void setQuantity(int quantity)
public java.util.List<PriceInfo> getPriceInfo(Predicate filter) throws CommerceException
CommerceSession.CartEntry
Get a list of detailed price info objects for a cart entry filtered by the provided
predicate (usually a PriceFilter
).
Current components expect price infos with (at least) the following classifiers, in this order:
Example: to get the unit price of a cart entry, you could use the following statement:
cartEntry.getPriceInfo(new PriceFilter("UNIT"));
getPriceInfo
in interface CommerceSession.CartEntry
filter
- An optional predicate used for filtering the PriceInfo
s.
Pass null
to fetch all PriceInfo
s.CommerceException
PriceFilter
public java.lang.String getPrice(Predicate filter) throws CommerceException
CommerceSession.CartEntry
getPrice
in interface CommerceSession.CartEntry
filter
- An optional predicate used for filtering the PriceInfo
s.CommerceException
CommerceSession.CartEntry.getPriceInfo(Predicate)
public void setPrice(PriceInfo priceInfo, java.lang.String... types)
PriceInfo
. If all
the priceInfo's types match an existing entry, the entry will be updated.
Note: automatically add the priceInfo's currencyCode as an additional tag to ease filtering on currency.
priceInfo
- A PriceInfo
containing the amount and currency.types
- Classifiers indicating the usage of the PriceInfo (ie: "UNIT", "PRE_TAX").public <T> T getProperty(java.lang.String name, java.lang.Class<T> type)
CommerceSession.CartEntry
getProperty
in interface CommerceSession.CartEntry
name
- The property's nametype
- The property's typenull
if it doesn't exist
or can not be converted to the given type.public ValueMap getProperties()
@Deprecated public java.lang.String getUnitPrice()
getUnitPrice
in interface CommerceSession.CartEntry
@Deprecated public java.lang.String getPreTaxPrice()
getPreTaxPrice
in interface CommerceSession.CartEntry
@Deprecated public java.lang.String getTax()
getTax
in interface CommerceSession.CartEntry
@Deprecated public java.lang.String getTotalPrice()
getTotalPrice
in interface CommerceSession.CartEntry
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"