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

PropertyReturnsDescription
adminOrgOrganisationThe organisation that owns this order, typically the store or rewards program operator.
attachmentsList<OrderAttachment>The files attached to this line item, such as inline images or downloadable attachments. May be null if none have been added.
auditOrgOrganisationThe organisation this order is audited against, used by the audit subsystem to attribute change history.
cartCartThe shopping cart this line item belongs to. May be null for orders created directly, without going through a cart.
currencyIdStringThe identifier of the currency this order's amounts are recorded in, used as a lookup reference to a Currency.
discountBigDecimalThe 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.
ecommerceStoreECommerceStoreThe e-commerce store this order was placed through. May be null for orders not associated with a store, such as some rewards redemptions.
effectiveUnitCostBigDecimalThe effective cost per unit, using the unitCost field if it is set. Otherwise this is derived by dividing the total cost by the quantity.
grandTotalBigDecimalThe 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.
grandTotalIncTaxBigDecimalThe grand total for this line item with tax added.
idlongThe database identifier of this order line item.
itemDescriptionStringA free-text description of the item ordered, copied from the product at the time of ordering. May be null.
itemHrefStringThe href of the item that was ordered, such as a product page path. May be null.
lastStatusProductOrderStatusFinds the most recent status recorded for this order, querying the database for the latest status by date.
modifiedDateDateThe date and time this order line item was last modified.
orderedDateDateThe date and time the order was placed.
orderedForOrgOrganisationThe organisation that was in context for the ordering user when the order was placed, for example the branch or team they belong to.
orderStatusesList<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.
productProductThe product that was ordered.
productOrderOptionsList<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.
productSkuProductSkuThe specific stock keeping unit variant of the product that was ordered. May be null if the product does not use SKU variants.
profileProfileThe profile of the person who placed this order.
promotionalBooleanWhether 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.
quantityBigDecimalThe number of units of the product ordered. May be null if a quantity was not applicable to this order.
salesDataRecordSalesDataRecordThe 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.
taxBigDecimalThe amount of tax charged on this line item, as a currency amount rather than a rate.
totalCostBigDecimalThe total cost of this line item, excluding tax, as conventionally recorded on the order.
unitCostBigDecimalThe 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.
voucherVoucherThe voucher associated with this line item, when the item represents a voucher redemption rather than a product purchase. May be null.
websiteWebsiteThe 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.

ParameterDescription
adminOrgthe 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.

ParameterDescription
quantitythe 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.

ParameterDescription
unitCostthe 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.

ParameterDescription
discountthe 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.

ParameterDescription
taxthe 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.

ParameterDescription
totalCostthe 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.

ParameterDescription
currencyIdthe 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.

ParameterDescription
itemDescriptionthe 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.

ParameterDescription
websitethe 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.

ParameterDescription
itemHrefthe 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.

ParameterDescription
productOrderOptionsthe 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.

ParameterDescription
productSkuthe 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.

ParameterDescription
attachmentsthe 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.

ParameterDescription
eCommerceStorethe 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.

ParameterDescription
profilethe ordering profile

getProduct()

Returns: Product

The product that was ordered.

setProduct(Product product)

Returns: void

Sets the product that was ordered.

ParameterDescription
productthe 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.

ParameterDescription
orderedForOrgthe 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.

ParameterDescription
orderedDatethe 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.

ParameterDescription
modifiedDatethe 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.

ParameterDescription
cartthe 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.

ParameterDescription
voucherthe 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.

ParameterDescription
salesDataRecordthe 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.

ParameterDescription
promotionaltrue 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.

ParameterDescription
keythe answer key to add or update
valuethe 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.

ParameterDescription
keythe 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.

To get full access to the Kademi Hub existing customers can login here, or new customers can register here.