Represents the priced line items of a shopping cart, combining physical items the user added with virtual items that checkout rules added automatically. Physical cart items are those the user has explicitly added to the cart. Virtual items are added by checkout rules, such as a voucher line item once a valid voucher code has been entered, or a promotional item such as a free gift with purchase. Virtual items cannot be explicitly removed or have their quantity changed by the user. Also totals the cart, accounting for freight, tax and any loyalty points being redeemed against the order.


Properties

PropertyReturnsDescription
cartCartThe underlying cart entity this instance wraps.
cartIdlongThe database identifier of the underlying cart.
freightCostBigDecimalThe calculated freight cost for this cart's shipping provider, cached after the first lookup.
itemsList<CheckoutLineItem>The full list of line items in the cart, including both physical items and virtual items added by checkout rules.
numItemsintThe number of line items in the cart, including both physical and virtual items.
recurringCostBigDecimalThe combined final cost of the cart's recurring (subscription) line items.
recurringItemsList<CheckoutLineItem>The line items in the cart whose product is a repeating (subscription) product.
shippingProviderShippingProviderThe shipping provider available for this cart, resolved from the cart's chosen shipping provider and cached after the first lookup.
subTotalBigDecimalThe total value of all cart items excluding tax, but including credits from vouchers and promotional items.
totalCostBigDecimalThe total cost of the cart, including freight and tax, with any loyalty points being redeemed deducted.
totalTaxBigDecimalThe total tax across all line items in the cart.

Methods

getNumItems() · getCartId() · getTotalCost() · totalCost(StringBuilder sb) · totalCostNarrative(Narrative narrative) · getTotalTax() · getSubTotal() · getShippingProvider() · getFreightCost() · getItems() · getCart() · containsCategory(String catCode) · containsProduct(String prodCode) · containsProductSku(String skuCode) · containsVoucher() · containsGift() · getRecurringItems() · getRecurringCost()

getNumItems()

Returns: int

The number of line items in the cart, including both physical and virtual items.

getCartId()

Returns: long

The database identifier of the underlying cart.

getTotalCost()

Returns: BigDecimal

The total cost of the cart, including freight and tax, with any loyalty points being redeemed deducted.

totalCost(StringBuilder sb)

Returns: BigDecimal

Calculates the total cost of the cart, as with getTotalCost, and appends a line-by-line explanation of how the total was derived to the given buffer. Walks every line item so is more expensive than getTotalCost.

ParameterDescription
sba buffer to append the narrative lines to, or null to skip building a narrative

totalCostNarrative(Narrative narrative)

Returns: BigDecimal

Calculates the total cost of the cart's items plus freight, less any loyalty points applied, appending a line-by-line explanation to the given narrative as it goes. Caps the total at zero, and reduces the number of points applied to the cart if the points on hand exceed the cost.

ParameterDescription
narrativecollects a human-readable explanation of the calculation, or null to skip it

getTotalTax()

Returns: BigDecimal

The total tax across all line items in the cart.

getSubTotal()

Returns: BigDecimal

The total value of all cart items excluding tax, but including credits from vouchers and promotional items.

getShippingProvider()

Returns: ShippingProvider

The shipping provider available for this cart, resolved from the cart's chosen shipping provider and cached after the first lookup.

getFreightCost()

Returns: BigDecimal

The calculated freight cost for this cart's shipping provider, cached after the first lookup.

getItems()

Returns: List<CheckoutLineItem>

The full list of line items in the cart, including both physical items and virtual items added by checkout rules.

getCart()

Returns: Cart

The underlying cart entity this instance wraps.

containsCategory(String catCode)

Returns: boolean

Checks whether any product in the cart belongs to the given category.

ParameterDescription
catCodethe category code to look for

containsProduct(String prodCode)

Returns: boolean

Checks whether the cart contains a line item for the given product.

ParameterDescription
prodCodethe product's name to look for

containsProductSku(String skuCode)

Returns: boolean

Checks whether the cart contains a line item for the given SKU.

ParameterDescription
skuCodethe SKU's name to look for

containsVoucher()

Returns: boolean

Checks whether the cart contains a voucher line item.

containsGift()

Returns: boolean

Checks whether the cart contains a free gift line item added by a promotion.

getRecurringItems()

Returns: List<CheckoutLineItem>

The line items in the cart whose product is a repeating (subscription) product.

getRecurringCost()

Returns: BigDecimal

The combined final cost of the cart's recurring (subscription) line items.

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