Represents a single line item within a customer's order or shopping cart, recording the product purchased, its quantity and cost breakdown. Orders progress through a lifecycle recorded as a history of ProductOrderStatus rows, from being added to a cart through to being ordered, shipped or cancelled. A ProductOrder may represent a normal product purchase, a promotional item added by a checkout rule, or a voucher redemption, and can be linked to a Cart, an ECommerceStore, a Website and a SalesDataRecord depending on how it was created.
Group: Database Entities
Implements: Serializable, Auditable
Properties
| Property | Returns | Description |
|---|---|---|
| adminOrg | Organisation | The organisation that owns this order, typically the store or rewards program operator. |
| attachments | List<OrderAttachment> | The files attached to this line item, such as inline images or downloadable attachments. May be null if none have been added. |
| auditOrg | Organisation | The organisation this order is audited against, used by the audit subsystem to attribute change history. |
| cart | Cart | The shopping cart this line item belongs to. May be null for orders created directly, without going through a cart. |
| currencyId | String | The identifier of the currency this order's amounts are recorded in, used as a lookup reference to a Currency. |
| discount | BigDecimal | The discount applied to this line item. This amount is added to the total, so it must be a negative value to act as a discount, which is counter-intuitive but is the existing convention. |
| ecommerceStore | ECommerceStore | The e-commerce store this order was placed through. May be null for orders not associated with a store, such as some rewards redemptions. |
| effectiveUnitCost | BigDecimal | The effective cost per unit, using the unitCost field if it is set. Otherwise this is derived by dividing the total cost by the quantity. |
| grandTotal | BigDecimal | The total cost, using the totalCost field if it has been set. Otherwise this is calculated by multiplying the unit cost by the quantity and adding the discount, which is expected to be negative. |
| grandTotalIncTax | BigDecimal | The grand total for this line item with tax added. |
| id | long | The database identifier of this order line item. |
| itemDescription | String | A free-text description of the item ordered, copied from the product at the time of ordering. May be null. |
| itemHref | String | The href of the item that was ordered, such as a product page path. May be null. |
| lastStatus | ProductOrderStatus | Finds the most recent status recorded for this order, querying the database for the latest status by date. |
| modifiedDate | Date | The date and time this order line item was last modified. |
| orderedDate | Date | The date and time the order was placed. |
| orderedForOrg | Organisation | The organisation that was in context for the ordering user when the order was placed, for example the branch or team they belong to. |
| orderStatuses | List<ProductOrderStatus> | Loads the full lifecycle status history of this order, ordered from oldest to newest. This queries the database on each call rather than returning a cached value. |
| product | Product | The product that was ordered. |
| productOrderOptions | List<ProductOrderOption> | The set of custom answer options captured for this line item, such as answers to product configuration questions. May be null if none have been recorded. |
| productSku | ProductSku | The specific stock keeping unit variant of the product that was ordered. May be null if the product does not use SKU variants. |
| profile | Profile | The profile of the person who placed this order. |
| promotional | Boolean | Whether this line item represents a promotional product added automatically by a checkout rule, such as "buy X, get one free". May be null if not explicitly set, which is treated as not promotional. |
| quantity | BigDecimal | The number of units of the product ordered. May be null if a quantity was not applicable to this order. |
| salesDataRecord | SalesDataRecord | The sales data record this line item is linked to, if it was created from imported or externally recorded sales data rather than a direct order. May be null. |
| tax | BigDecimal | The amount of tax charged on this line item, as a currency amount rather than a rate. |
| totalCost | BigDecimal | The total cost of this line item, excluding tax, as conventionally recorded on the order. |
| unitCost | BigDecimal | The cost of a single unit of the product, including any additional charges such as freight. May be null if not set, in which case the effective unit cost is derived from the total cost and quantity instead. |
| voucher | Voucher | The voucher associated with this line item, when the item represents a voucher redemption rather than a product purchase. May be null. |
| website | Website | The website through which the order was placed. May be null if the order was not placed through a website. |
Methods
getId() · getAdminOrg() · setAdminOrg(Organisation adminOrg) · getQuantity() · setQuantity(BigDecimal quantity) · getUnitCost() · setUnitCost(BigDecimal unitCost) · getDiscount() · setDiscount(BigDecimal discount) · getTax() · setTax(BigDecimal tax) · getTotalCost() · setTotalCost(BigDecimal totalCost) · getCurrencyId() · setCurrencyId(String currencyId) · getItemDescription() · setItemDescription(String itemDescription) · getWebsite() · setWebsite(Website website) · getItemHref() · setItemHref(String itemHref) · getProductOrderOptions() · setProductOrderOptions(List<ProductOrderOption> productOrderOptions) · getProductSku() · setProductSku(ProductSku productSku) · getAttachments() · setAttachments(List<OrderAttachment> attachments) · getEcommerceStore() · setEcommerceStore(ECommerceStore eCommerceStore) · getProfile() · setProfile(Profile profile) · getProduct() · setProduct(Product product) · getOrderedForOrg() · setOrderedForOrg(Organisation orderedForOrg) · getOrderedDate() · setOrderedDate(Date orderedDate) · getModifiedDate() · setModifiedDate(Date modifiedDate) · getCart() · setCart(Cart cart) · getVoucher() · setVoucher(Voucher voucher) · getSalesDataRecord() · setSalesDataRecord(SalesDataRecord salesDataRecord) · getPromotional() · setPromotional(Boolean promotional) · addOption(String key, String value) · option(String key) · totalCost() · findLastStatus() · getGrandTotal() · getEffectiveUnitCost() · getGrandTotalIncTax() · getOrderStatuses() · getAuditOrg() · getLastStatus()
getId()
Returns: long
The database identifier of this order line item.
getAdminOrg()
Returns: Organisation
The organisation that owns this order, typically the store or rewards program operator.
setAdminOrg(Organisation adminOrg)
Returns: void
Sets the organisation that owns this order.
| Parameter | Description |
|---|---|
adminOrg | the owning organisation |
getQuantity()
Returns: BigDecimal
The number of units of the product ordered. May be null if a quantity was not applicable to this order.
setQuantity(BigDecimal quantity)
Returns: void
Sets the number of units of the product ordered.
| Parameter | Description |
|---|---|
quantity | the ordered quantity |
getUnitCost()
Returns: BigDecimal
The cost of a single unit of the product, including any additional charges such as freight. May be null if not set, in which case the effective unit cost is derived from the total cost and quantity instead.
setUnitCost(BigDecimal unitCost)
Returns: void
Sets the cost of a single unit of the product.
| Parameter | Description |
|---|---|
unitCost | the unit cost |
getDiscount()
Returns: BigDecimal
The discount applied to this line item. This amount is added to the total, so it must be a negative value to act as a discount, which is counter-intuitive but is the existing convention.
setDiscount(BigDecimal discount)
Returns: void
Sets the discount applied to this line item. Must be negative to reduce the total.
| Parameter | Description |
|---|---|
discount | the discount amount |
getTax()
Returns: BigDecimal
The amount of tax charged on this line item, as a currency amount rather than a rate.
setTax(BigDecimal tax)
Returns: void
Sets the amount of tax charged on this line item.
| Parameter | Description |
|---|---|
tax | the tax amount |
getTotalCost()
Returns: BigDecimal
The total cost of this line item, excluding tax, as conventionally recorded on the order.
setTotalCost(BigDecimal totalCost)
Returns: void
Sets the total cost of this line item. Note that this is conventionally used as the total cost excluding tax; see the processCheckout method of DefaultCheckoutLineItem for how it is calculated during checkout.
| Parameter | Description |
|---|---|
totalCost | the total cost, excluding tax |
getCurrencyId()
Returns: String
The identifier of the currency this order's amounts are recorded in, used as a lookup reference to a Currency.
setCurrencyId(String currencyId)
Returns: void
Sets the identifier of the currency this order's amounts are recorded in.
| Parameter | Description |
|---|---|
currencyId | the currency identifier |
getItemDescription()
Returns: String
A free-text description of the item ordered, copied from the product at the time of ordering. May be null.
setItemDescription(String itemDescription)
Returns: void
Sets the free-text description of the item ordered.
| Parameter | Description |
|---|---|
itemDescription | the item description |
getWebsite()
Returns: Website
The website through which the order was placed. May be null if the order was not placed through a website.
setWebsite(Website website)
Returns: void
Sets the website through which the order was placed.
| Parameter | Description |
|---|---|
website | the website the order was placed through |
getItemHref()
Returns: String
The href of the item that was ordered, such as a product page path. May be null.
setItemHref(String itemHref)
Returns: void
Sets the href of the item that was ordered.
| Parameter | Description |
|---|---|
itemHref | the href of the ordered item |
getProductOrderOptions()
Returns: List<ProductOrderOption>
The set of custom answer options captured for this line item, such as answers to product configuration questions. May be null if none have been recorded.
setProductOrderOptions(List<ProductOrderOption> productOrderOptions)
Returns: void
Sets the custom answer options captured for this line item.
| Parameter | Description |
|---|---|
productOrderOptions | the product order options |
getProductSku()
Returns: ProductSku
The specific stock keeping unit variant of the product that was ordered. May be null if the product does not use SKU variants.
setProductSku(ProductSku productSku)
Returns: void
Sets the specific stock keeping unit variant of the product that was ordered.
| Parameter | Description |
|---|---|
productSku | the ordered product SKU |
getAttachments()
Returns: List<OrderAttachment>
The files attached to this line item, such as inline images or downloadable attachments. May be null if none have been added.
setAttachments(List<OrderAttachment> attachments)
Returns: void
Sets the files attached to this line item.
| Parameter | Description |
|---|---|
attachments | the attached files |
getEcommerceStore()
Returns: ECommerceStore
The e-commerce store this order was placed through. May be null for orders not associated with a store, such as some rewards redemptions.
setEcommerceStore(ECommerceStore eCommerceStore)
Returns: void
Sets the e-commerce store this order was placed through.
| Parameter | Description |
|---|---|
eCommerceStore | the e-commerce store |
getProfile()
Returns: Profile
The profile of the person who placed this order.
setProfile(Profile profile)
Returns: void
Sets the profile of the person who placed this order.
| Parameter | Description |
|---|---|
profile | the ordering profile |
getProduct()
Returns: Product
The product that was ordered.
setProduct(Product product)
Returns: void
Sets the product that was ordered.
| Parameter | Description |
|---|---|
product | the ordered product |
getOrderedForOrg()
Returns: Organisation
The organisation that was in context for the ordering user when the order was placed, for example the branch or team they belong to.
setOrderedForOrg(Organisation orderedForOrg)
Returns: void
Sets the organisation that was in context for the ordering user when the order was placed.
| Parameter | Description |
|---|---|
orderedForOrg | the ordering organisation |
getOrderedDate()
Returns: Date
The date and time the order was placed.
setOrderedDate(Date orderedDate)
Returns: void
Sets the date and time the order was placed.
| Parameter | Description |
|---|---|
orderedDate | the date the order was placed |
getModifiedDate()
Returns: Date
The date and time this order line item was last modified.
setModifiedDate(Date modifiedDate)
Returns: void
Sets the date and time this order line item was last modified.
| Parameter | Description |
|---|---|
modifiedDate | the last modified date |
getCart()
Returns: Cart
The shopping cart this line item belongs to. May be null for orders created directly, without going through a cart.
setCart(Cart cart)
Returns: void
Sets the shopping cart this line item belongs to.
| Parameter | Description |
|---|---|
cart | the owning cart |
getVoucher()
Returns: Voucher
The voucher associated with this line item, when the item represents a voucher redemption rather than a product purchase. May be null.
setVoucher(Voucher voucher)
Returns: void
Sets the voucher associated with this line item.
| Parameter | Description |
|---|---|
voucher | the associated voucher |
getSalesDataRecord()
Returns: SalesDataRecord
The sales data record this line item is linked to, if it was created from imported or externally recorded sales data rather than a direct order. May be null.
setSalesDataRecord(SalesDataRecord salesDataRecord)
Returns: void
Sets the sales data record this line item is linked to.
| Parameter | Description |
|---|---|
salesDataRecord | the linked sales data record |
getPromotional()
Returns: Boolean
Whether this line item represents a promotional product added automatically by a checkout rule, such as "buy X, get one free". May be null if not explicitly set, which is treated as not promotional.
setPromotional(Boolean promotional)
Returns: void
Sets whether this line item represents a promotional product added automatically by a checkout rule.
| Parameter | Description |
|---|---|
promotional | true if this is a promotional line item |
addOption(String key, String value)
Returns: ProductOrderOption
Adds or updates a custom answer option on this line item, keyed by the given answer key. If an option with a matching key already exists its answer is overwritten, otherwise a new option is created and added.
| Parameter | Description |
|---|---|
key | the answer key to add or update |
value | the answer value to record |
option(String key)
Returns: ProductOrderOption
Finds the custom answer option on this line item whose answer key ends with the given key.
| Parameter | Description |
|---|---|
key | the answer key to search for |
totalCost()
Returns: BigDecimal
Calculates the total cost of this line item as unit cost multiplied by quantity. This is a simple calculation and does not consider the totalCost, discount or tax fields.
findLastStatus()
Returns: ProductOrderStatus
Finds the most recent status recorded for this order, based on the loaded order status history.
getGrandTotal()
Returns: BigDecimal
The total cost, using the totalCost field if it has been set. Otherwise this is calculated by multiplying the unit cost by the quantity and adding the discount, which is expected to be negative.
getEffectiveUnitCost()
Returns: BigDecimal
The effective cost per unit, using the unitCost field if it is set. Otherwise this is derived by dividing the total cost by the quantity.
getGrandTotalIncTax()
Returns: BigDecimal
The grand total for this line item with tax added.
getOrderStatuses()
Returns: List<ProductOrderStatus>
Loads the full lifecycle status history of this order, ordered from oldest to newest. This queries the database on each call rather than returning a cached value.
getAuditOrg()
Returns: Organisation
The organisation this order is audited against, used by the audit subsystem to attribute change history.
getLastStatus()
Returns: ProductOrderStatus
Finds the most recent status recorded for this order, querying the database for the latest status by date.