@ProviderType public class PriceInfo extends ValueMapDecorator
PriceInfo
provides information about prices for products, cart entries, and orders.
A product, cart entry, or order can have many prices associated with it. Each price is identified by a list of string classifiers. For instance, a product might have the following prices:
A PriceFilter
is normally used when fetching prices.
Price searches can return a list (generally getPriceInfo()
) of all prices matching the
filter, or can return only the first (generally getPrice()
). Because of the second
form, more common (or default) price infos should be stored in front of less common (more specific)
price infos.
For instance, if a product had the following prices:
The first price would be returned from getPrice(new PriceFilter("TAX"))
, while the
second would be returned from getPrice(new PriceFilter("TAX", "CALIFORNIA"))
.
In general, the set of price classifiers used by an e-commerce site are implementation-dependent. However, the out-of-the-box commerce components do make a few assumptions about the existence of the following classifiers:
A PriceInfo
also supports the retrieval of a formatted string for displaying
the price, and a minimum quantity at which the price is valid.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MIN_QUANTITY |
Constructor and Description |
---|
PriceInfo(java.math.BigDecimal amount,
java.util.Currency currency)
Deprecated.
since 5.6.200; use
PriceInfo(java.math.BigDecimal, java.util.Locale) instead. |
PriceInfo(java.math.BigDecimal amount,
java.util.Locale locale)
Create price info with a minimum quantity of one, and the default currency for the given locale.
|
PriceInfo(java.math.BigDecimal amount,
java.util.Locale locale,
java.util.Currency currency)
Create price info with a minimum quantity of one, and the given currency and locale.
|
Modifier and Type | Method and Description |
---|---|
java.math.BigDecimal |
getAmount()
Get the price's value.
|
java.util.Currency |
getCurrency()
Get the currency.
|
java.lang.String |
getFormattedString()
Get the formatted string.
|
java.util.Locale |
getLocale()
Get the locale.
|
long |
getQuantity()
Convenience method for retrieving the minimum quantity property.
|
java.lang.String |
toString()
Override the standard toString method to return the formatted string.
|
public static final java.lang.String MIN_QUANTITY
@Deprecated public PriceInfo(java.math.BigDecimal amount, java.util.Currency currency)
PriceInfo(java.math.BigDecimal, java.util.Locale)
instead.amount
- The actual price value.currency
- The currency.public PriceInfo(java.math.BigDecimal amount, java.util.Locale locale)
amount
- The actual price value.locale
- The locale.public PriceInfo(java.math.BigDecimal amount, java.util.Locale locale, java.util.Currency currency)
amount
- The actual price value.locale
- The locale.public java.math.BigDecimal getAmount()
public long getQuantity()
public java.util.Locale getLocale()
public java.util.Currency getCurrency()
public java.lang.String getFormattedString()
public java.lang.String toString()
toString
in class ValueMapDecorator
Copyright © 2010 - 2020 Adobe. All Rights Reserved