Interface OrderItem
- All Superinterfaces:
Cloneable,org.broadleafcommerce.common.copy.MultiTenantCloneable<OrderItem>,Serializable
- All Known Subinterfaces:
BundleOrderItem,DiscreteOrderItem,DynamicPriceDiscreteOrderItem,GiftWrapOrderItem
- All Known Implementing Classes:
BundleOrderItemImpl,DiscreteOrderItemImpl,DynamicPriceDiscreteOrderItemImpl,GiftWrapOrderItemImpl,OrderItemImpl
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddCandidateItemOffer(CandidateItemOffer candidateItemOffer) Used by the promotion engine to add offers that might apply to this orderItem.voidUsed to set the final price of the item and corresponding details.clone()voidCalled by the pricing engine after prices have been computed.org.broadleafcommerce.common.money.MoneyDeprecated.org.broadleafcommerce.common.audit.Auditableorg.broadleafcommerce.common.money.MoneyReturns the average unit item adjustments.org.broadleafcommerce.common.money.MoneyReturns the average unit display price for the item.org.broadleafcommerce.common.money.MoneyReturns the total for future credit item level adjustments.org.broadleafcommerce.common.money.MoneygetFutureCreditTotalAdjustmentValue(boolean includeChildren) Returns the total for future credit item level adjustments.getId()The unique identifier of this OrderItembooleanReturns true if this item received a discount.booleanDefault implementation usesgetSalePrice()<getRetailPrice()getName()Generally copied from the Sku.getName()getOrder()Reference back to the containing order.Deprecated.A list of arbitrary attributes added to this item.Collection of priceDetails for this orderItem.If any quantity of this item was used to qualify for an offer, then this returned list will indicate the offer and the relevant quantity.org.broadleafcommerce.common.money.MoneygetPrice()Deprecated.Delegates togetAveragePrice()org.broadleafcommerce.common.money.MoneygetPriceBeforeAdjustments(boolean allowSalesPrice) Returns the unit price of this item.org.broadleafcommerce.common.money.MoneygetPriceBeforeAdjustments(boolean allowSalesPrice, boolean includeChildren) Returns a list of all prorated adjustments for this order item.intThe quantity of thisOrderItem.org.broadleafcommerce.common.money.MoneyThe retail price of the item that was added to theOrderat the time that this was added.org.broadleafcommerce.common.money.MoneyReturns the salePrice for this item.org.broadleafcommerce.common.money.MoneyDeprecated.If the item is taxable, returnsgetAveragePrice()org.broadleafcommerce.common.money.MoneyReturns the total for all item level adjustments.org.broadleafcommerce.common.money.MoneygetTotalAdjustmentValue(boolean includeChildren) Returns the total for all item level adjustments.org.broadleafcommerce.common.money.MoneyReturns the total price to be paid for this order item including item-level adjustments.org.broadleafcommerce.common.money.MoneygetTotalPrice(boolean includeChildren) Returns the total price to be paid for this order item including item-level adjustments.org.broadleafcommerce.common.money.MoneygetTotalPriceBeforeAdjustments(boolean allowSalesPrice) Returns the total price to be paid before adjustments.booleanisAParentOf(OrderItem candidateChild) booleanbooleanIf true, this item can be discounted..booleanisInCategory(String categoryName) booleanReturns true if the retail price was manually set.booleanReturns true if the sale price was manually set.booleanReturns a boolean indicating whether this sku is active.Returns whether or not this item is taxable.intRemoves all adjustment for this order item and reset the adjustment price.voidRemoves all candidate offers.voidsetAuditable(org.broadleafcommerce.common.audit.Auditable auditable) Sets the Auditable date object - typially set by Hibernate through the AuditableListenervoidsetCandidateItemOffers(List<CandidateItemOffer> candidateItemOffers) voidsetCartMessages(List<String> cartMessages) Sets the list of messages that should be displayed in the cartvoidsetCategory(Category category) voidsetChildOrderItems(List<OrderItem> childOrderItems) Sets the list of orderitems that are dependent on this order itemvoidsetDiscountingAllowed(boolean discountingAllowed) Turns off discount processing for this line item.voidsetGiftWrapOrderItem(GiftWrapOrderItem giftWrapOrderItem) voidsetHasValidationError(Boolean hasValidationError) Sets whether or not this order item has an error associated with itvoidSets the unique id of the OrderItem.voidSets the name of this order item.voidSets the order for this orderItem.voidsetOrderItemAdjustments(List<OrderItemAdjustment> orderItemAdjustments) Deprecated.Item level adjustments are now stored at the OrderItemPriceDetail level instead to prevent unnecessary item splitting of OrderItems when evaluating promotions in the pricing engine.voidsetOrderItemAttributes(Map<String, OrderItemAttribute> orderItemAttributes) Sets the map of order item attributes.voidsetOrderItemPriceDetails(List<OrderItemPriceDetail> orderItemPriceDetails) Returns the list of orderItem price details.voidsetOrderItemQualifiers(List<OrderItemQualifier> orderItemQualifiers) Sets the list of OrderItemQualifiersvoidsetOrderItemType(OrderItemType orderItemType) voidsetParentOrderItem(OrderItem parentOrderItem) Sets the parent order item for this order itemvoidsetPersonalMessage(PersonalMessage personalMessage) voidsetPrice(org.broadleafcommerce.common.money.Money price) Calling this method is the same as calling the following:voidsetProratedOrderItemAdjustments(List<ProratedOrderItemAdjustment> proratedOrderItemAdjustments) Sets the list of prorated order item adjustments for this order item.voidsetQuantity(int quantity) Sets the quantity of this itemvoidsetRetailPrice(org.broadleafcommerce.common.money.Money retailPrice) Calling this method will manually set the retailPrice.voidsetRetailPriceOverride(boolean override) Indicates that the retail price was manually set.voidsetSalePrice(org.broadleafcommerce.common.money.Money salePrice) Calling this method will manually set the salePrice.voidsetSalePriceOverride(boolean override) Indicates that the sale price was manually set.voidsetTaxable(Boolean taxable) Sets whether or not this item is taxable.booleanUsed to reset the base price of the item that the pricing engine uses.Methods inherited from interface org.broadleafcommerce.common.copy.MultiTenantCloneable
createOrRetrieveCopyInstance
-
Method Details
-
getId
Long getId()The unique identifier of this OrderItem- Returns:
-
setId
Sets the unique id of the OrderItem. Typically left null for new items and Broadleaf will set using the next sequence number.- Parameters:
id-
-
getOrder
Order getOrder()Reference back to the containing order.- Returns:
-
setOrder
Sets the order for this orderItem.- Parameters:
order-
-
getRetailPrice
org.broadleafcommerce.common.money.Money getRetailPrice()The retail price of the item that was added to theOrderat the time that this was added. This is preferable to use as opposed to checking the price of the item that was added from the catalog domain (like inDiscreteOrderItem, usingDiscreteOrderItem.getSku()'s retail price) since the price in the catalog domain could have changed since the item was added to theOrder.- Returns:
-
setRetailPrice
void setRetailPrice(org.broadleafcommerce.common.money.Money retailPrice) Calling this method will manually set the retailPrice. To avoid the pricing engine resetting this price, you should also make a call to {@link #setRetailPriceOverride(true)}Consider also calling
setDiscountingAllowed(boolean)with a value of false to restrict discounts after manually setting the retail price.- Parameters:
retailPrice-
-
isRetailPriceOverride
boolean isRetailPriceOverride()Returns true if the retail price was manually set. If the retail price is manually set, calls to updatePrices() will not do anything.- Returns:
-
setRetailPriceOverride
void setRetailPriceOverride(boolean override) Indicates that the retail price was manually set. A typical usage might be for a CSR who has override privileges to control setting the price. This will automatically be set by callingsetRetailPrice(Money) -
getSalePrice
org.broadleafcommerce.common.money.Money getSalePrice()Returns the salePrice for this item. Note this method will return the lower of the retailPrice or salePrice. It will return the retailPrice instead of null.For SKU based pricing, a call to
updateSaleAndRetailPrices()will ensure that the retailPrice being used is current.- Returns:
-
setSalePrice
void setSalePrice(org.broadleafcommerce.common.money.Money salePrice) Calling this method will manually set the salePrice. It will also make a call to {@link #setSalePriceSetManually(true)}To avoid the pricing engine resetting this price, you should also make a call to {@link #setSalePriceOverride(true)}
Typically for
DiscreteOrderItems, the prices will be set with a call toupdateSaleAndRetailPrices()which will use the Broadleaf dynamic pricing engine or the values directly tied to the SKU.- Parameters:
salePrice-
-
isSalePriceOverride
boolean isSalePriceOverride()Returns true if the sale price was manually set. If the retail price is manually set, calls to updatePrices() will not do anything.- Returns:
-
setSalePriceOverride
void setSalePriceOverride(boolean override) Indicates that the sale price was manually set. A typical usage might be for a CSR who has override privileges to control setting the price.Consider also calling
setDiscountingAllowed(boolean)with a value of false to restrict discounts after manually setting the retail price.If the salePrice is not lower than the retailPrice, the system will return the retailPrice when a call to
getSalePrice()is made. -
getProratedOrderItemAdjustments
List<ProratedOrderItemAdjustment> getProratedOrderItemAdjustments()Returns a list of all prorated adjustments for this order item.- Returns:
-
setProratedOrderItemAdjustments
void setProratedOrderItemAdjustments(List<ProratedOrderItemAdjustment> proratedOrderItemAdjustments) Sets the list of prorated order item adjustments for this order item.- Parameters:
proratedOrderItemAdjustments-
-
getAdjustmentValue
Deprecated.Delegates togetAverageAdjustmentValue()instead but this method is of little or no value in most practical applications unless only simple promotions are being used.- Returns:
-
getPrice
Deprecated.Delegates togetAveragePrice()- Returns:
-
setPrice
void setPrice(org.broadleafcommerce.common.money.Money price) Calling this method is the same as calling the following:setRetailPrice(Money)setSalePrice(Money){@link #setRetailPriceOverride(true)} {@link #setSalePriceOverride(true)} {@link #setDiscountingAllowed(false)}This has the effect of setting the price in a way that no discounts or adjustments can be made.
- Parameters:
price-
-
getQuantity
int getQuantity()The quantity of thisOrderItem.- Returns:
-
setQuantity
void setQuantity(int quantity) Sets the quantity of this item -
getOrderItemPriceDetails
List<OrderItemPriceDetail> getOrderItemPriceDetails()Collection of priceDetails for this orderItem.Without discounts, an orderItem would have exactly 1 ItemPriceDetail. When orderItem discounting or tax-calculations result in an orderItem having multiple prices like in a buy-one-get-one free example, the orderItem will get an additional ItemPriceDetail.
Generally, an OrderItem will have 1 ItemPriceDetail record for each uniquely priced version of the item.
-
setOrderItemPriceDetails
Returns the list of orderItem price details.- Parameters:
orderItemPriceDetails-
-
getCategory
Category getCategory() -
setCategory
-
getCandidateItemOffers
List<CandidateItemOffer> getCandidateItemOffers() -
setCandidateItemOffers
-
getOrderItemAdjustments
Deprecated.Returns item level adjustment for versions of Broadleaf Commerce prior to 2.3.0 which replaced this concept with OrderItemPriceDetail adjustments.- Returns:
- a List of OrderItemAdjustment
-
setOrderItemAdjustments
Deprecated.Item level adjustments are now stored at the OrderItemPriceDetail level instead to prevent unnecessary item splitting of OrderItems when evaluating promotions in the pricing engine. -
getOrderItemQualifiers
List<OrderItemQualifier> getOrderItemQualifiers()If any quantity of this item was used to qualify for an offer, then this returned list will indicate the offer and the relevant quantity.As an example, a BuyOneGetOneFree offer would have 1 qualifier and 1 adjustment.
- Returns:
- a List of OrderItemAdjustment
-
setOrderItemQualifiers
Sets the list of OrderItemQualifiers -
getPersonalMessage
PersonalMessage getPersonalMessage() -
setPersonalMessage
-
isInCategory
-
getGiftWrapOrderItem
GiftWrapOrderItem getGiftWrapOrderItem() -
setGiftWrapOrderItem
-
getOrderItemType
OrderItemType getOrderItemType() -
setOrderItemType
-
getTaxablePrice
Deprecated.If the item is taxable, returnsgetAveragePrice()It is recommended instead that tax calculation engines use the
#getTotalTaxableAmount()which provides the taxable total for all quantities of this item. This method suffers from penny rounding errors in some situations.- Returns:
-
getIsOnSale
boolean getIsOnSale()Default implementation usesgetSalePrice()<getRetailPrice()- Returns:
-
isDiscountingAllowed
boolean isDiscountingAllowed()If true, this item can be discounted.. -
setDiscountingAllowed
void setDiscountingAllowed(boolean discountingAllowed) Turns off discount processing for this line item.- Parameters:
discountingAllowed-
-
getIsDiscounted
boolean getIsDiscounted()Returns true if this item received a discount.- Returns:
-
getName
String getName()Generally copied from the Sku.getName()- Returns:
-
setName
Sets the name of this order item.- Parameters:
name-
-
updateSaleAndRetailPrices
boolean updateSaleAndRetailPrices()Used to reset the base price of the item that the pricing engine uses.Generally, this will update the retailPrice and salePrice based on the corresponding value in the SKU.
If the retail or sale price was manually set, this method will not change those prices.
For non-manually set prices, prices can change based on system activities such as locale changes and customer authentication, this method is used to ensure that all cart items reflect the current base price before executing other pricing / adjustment operations.
Other known scenarios that can effect the base prices include the automatic bundling or loading a stale cart from the database.
See notes in subclasses for specific behavior of this method.
- Returns:
- true if the base prices changed as a result of this call
-
finalizePrice
void finalizePrice()Called by the pricing engine after prices have been computed. Allows the system to set the averagePrice that is stored for the item. -
clone
OrderItem clone() -
assignFinalPrice
void assignFinalPrice()Used to set the final price of the item and corresponding details. -
getPriceBeforeAdjustments
org.broadleafcommerce.common.money.Money getPriceBeforeAdjustments(boolean allowSalesPrice) Returns the unit price of this item. If the parameter allowSalesPrice is true, will return the sale price if one exists.Note that retail and sale prices are initialized for an
OrderItemduring the first execution of any method that depends on the sale or retail price including this one.- Parameters:
allowSalesPrice-- Returns:
- See Also:
-
getPriceBeforeAdjustments
org.broadleafcommerce.common.money.Money getPriceBeforeAdjustments(boolean allowSalesPrice, boolean includeChildren) -
addCandidateItemOffer
Used by the promotion engine to add offers that might apply to this orderItem.- Parameters:
candidateItemOffer-
-
removeAllCandidateItemOffers
void removeAllCandidateItemOffers()Removes all candidate offers. Used by the promotion engine which subsequently adds the candidate offers that might apply back to this item. -
removeAllAdjustments
int removeAllAdjustments()Removes all adjustment for this order item and reset the adjustment price. -
getOrderItemAttributes
Map<String,OrderItemAttribute> getOrderItemAttributes()A list of arbitrary attributes added to this item. -
setOrderItemAttributes
Sets the map of order item attributes.- Parameters:
orderItemAttributes-
-
getAveragePrice
org.broadleafcommerce.common.money.Money getAveragePrice()Returns the average unit display price for the item.Some implementations may choose to show this on a view cart screen. Due to fractional discounts, it the display could represent a unit price that is off.
For example, if this OrderItem had 3 items at $1 each and also received a $1 discount. The net effect under the default rounding scenario would be an average price of $0.666666
Most systems would represent this as $0.67 as the discounted unit price; however, this amount times 3 ($2.01) would not equal the getTotalPrice() which would be $2.00. For this reason, it is not recommended that implementations utilize this field. Instead, they may choose not to show the unit price or show multiple prices by looping through the OrderItemPriceDetails.
- Returns:
-
getAverageAdjustmentValue
org.broadleafcommerce.common.money.Money getAverageAdjustmentValue()Returns the average unit item adjustments.For example, if this item has a quantity of 2 at a base-price of $10 and a 10% discount applies to both then this method would return $1.
Some implementations may choose to show this on a view cart screen. Due to fractional discounts, the display could represent a unit adjustment value that is off due to rounding. See
getAveragePrice()for an example of this.Implementations wishing to show unit prices may choose instead to show the individual OrderItemPriceDetails instead of this value to avoid the rounding problem. This would result in multiple cart item display rows for each OrderItem.
Alternatively, the cart display should use
getTotalAdjustmentValue().- Returns:
-
getTotalAdjustmentValue
org.broadleafcommerce.common.money.Money getTotalAdjustmentValue()Returns the total for all item level adjustments.For example, if the item has a 2 items priced at $10 a piece and a 10% discount applies to both quantities. This method would return $2.
- Returns:
-
getTotalAdjustmentValue
org.broadleafcommerce.common.money.Money getTotalAdjustmentValue(boolean includeChildren) Returns the total for all item level adjustments.- Parameters:
includeChildren-- Returns:
-
getFutureCreditTotalAdjustmentValue
org.broadleafcommerce.common.money.Money getFutureCreditTotalAdjustmentValue()Returns the total for future credit item level adjustments.For example, if the item has a 2 items priced at $10 a piece and a 10% discount applies to both quantities. This method would return $2.
See
Offer.getAdjustmentType()for more info on future credit- Returns:
-
getFutureCreditTotalAdjustmentValue
org.broadleafcommerce.common.money.Money getFutureCreditTotalAdjustmentValue(boolean includeChildren) Returns the total for future credit item level adjustments.See
Offer.getAdjustmentType()for more info on future credit- Parameters:
includeChildren-- Returns:
-
getTotalPrice
org.broadleafcommerce.common.money.Money getTotalPrice()Returns the total price to be paid for this order item including item-level adjustments.It does not include the effect of order level adjustments. Calculated by looping through the orderItemPriceDetails
- Returns:
-
getTotalPrice
org.broadleafcommerce.common.money.Money getTotalPrice(boolean includeChildren) Returns the total price to be paid for this order item including item-level adjustments.- Parameters:
includeChildren-- Returns:
-
isTaxable
Boolean isTaxable()Returns whether or not this item is taxable. If this flag is not set, it returns true by default- Returns:
- the taxable flag. If null, returns true
-
setTaxable
Sets whether or not this item is taxable. Generally, this has been copied from the setting of the relevant SKU at the time it was added.- Parameters:
taxable-
-
getTotalPriceBeforeAdjustments
org.broadleafcommerce.common.money.Money getTotalPriceBeforeAdjustments(boolean allowSalesPrice) Returns the total price to be paid before adjustments.- Returns:
-
isSkuActive
boolean isSkuActive()Returns a boolean indicating whether this sku is active. This is used to determine whether a user the sku can add the sku to their cart. -
getChildOrderItems
- Returns:
- the list of orderitems that are dependent on this order item
-
setChildOrderItems
Sets the list of orderitems that are dependent on this order item- Parameters:
childOrderItems-
-
getParentOrderItem
OrderItem getParentOrderItem()- Returns:
- the parent order item for this item (potentially null)
-
setParentOrderItem
Sets the parent order item for this order item- Parameters:
parentOrderItem-
-
getHasValidationError
Boolean getHasValidationError()- Returns:
- whether or not this order item has an error
-
setHasValidationError
Sets whether or not this order item has an error associated with it- Parameters:
hasValidationError-
-
isAParentOf
- Parameters:
candidateChild-- Returns:
- true if the candidateChild is a child of the hierarchy starting from this OrderItem
-
isChildOrderItem
boolean isChildOrderItem()- Returns:
- true if the OrderItem has a parent
-
getCartMessages
- Returns:
- the list of messages that should be displayed in the cart
-
setCartMessages
Sets the list of messages that should be displayed in the cart- Parameters:
cartMessages-
-
getAuditable
org.broadleafcommerce.common.audit.Auditable getAuditable()- Returns:
- the Auditable date for this record
-
setAuditable
void setAuditable(org.broadleafcommerce.common.audit.Auditable auditable) Sets the Auditable date object - typially set by Hibernate through the AuditableListener- Parameters:
auditable-
-
getAverageAdjustmentValue()instead but this method is of little or no value in most practical applications unless only simple promotions are being used.