Interface LineItem
- All Superinterfaces:
Customizable<LineItem>
The representation of a Line Item in a Cart or in an Order.
Example to create an instance using the builder pattern
LineItem lineItem = LineItem.builder()
.id("{id}")
.productId("{productId}")
.name(nameBuilder -> nameBuilder)
.productType(productTypeBuilder -> productTypeBuilder)
.variant(variantBuilder -> variantBuilder)
.price(priceBuilder -> priceBuilder)
.quantity(0.3)
.totalPrice(totalPriceBuilder -> totalPriceBuilder)
.plusDiscountedPricePerQuantity(discountedPricePerQuantityBuilder -> discountedPricePerQuantityBuilder)
.plusTaxedPricePortions(taxedPricePortionsBuilder -> taxedPricePortionsBuilder)
.plusState(stateBuilder -> stateBuilder)
.plusPerMethodTaxRate(perMethodTaxRateBuilder -> perMethodTaxRateBuilder)
.priceMode(LineItemPriceMode.PLATFORM)
.lineItemMode(LineItemMode.STANDARD)
.build()
-
Method Summary
Modifier and TypeMethodDescriptionstatic LineItemBuilder
builder()
builder factory method for LineItemstatic LineItemBuilder
create builder for LineItem instancestatic LineItem
factory method to create a deep copy of LineItemDate and time (UTC) the Line Item was added to the Cart.@Valid CustomFields
Custom Fields of the Line Item.@NotNull @Valid List<DiscountedLineItemPriceForQuantity>
Discounted price of a single quantity of the Line Item.@Valid ChannelReference
Used to select a Product Price.@NotNull String
getId()
Unique identifier of the LineItem.Inventory mode specific to this Line Item only, and valid for the entirequantity
of the Line Item.getKey()
User-defined unique identifier of the LineItem.Date and time (UTC) the Line Item was last updated.@NotNull LineItemMode
Indicates how the Line Item is added to the Cart.@NotNull @Valid LocalizedString
getName()
Name of the Product.@NotNull @Valid List<MethodTaxRate>
Tax Rate per Shipping Method for a Cart withMultiple
ShippingMode.@NotNull @Valid Price
getPrice()
Price of a Line Item selected from the Product Variant according to the ProductpriceMode
.@NotNull LineItemPriceMode
Indicates how the Price for the Line Item is set.@NotNull String
id
of the Product the Line Item is based on.key
of the Product.@Valid LocalizedString
slug
of the current version of the Product.@NotNull @Valid ProductTypeReference
Product Type of the Product.@NotNull Long
Number of Line Items of the given Product Variant present in the Cart or Order.@Valid ItemShippingDetails
Container for Line Item-specific addresses.getState()
State of the Line Item in the Cart or the Order.@Valid ChannelReference
Identifies Inventory entries that are reserved.@Valid TaxedItemPrice
Automatically set aftertaxRate
is set.@NotNull @Valid List<MethodTaxedPrice>
Total taxed prices based on the quantity of Line Item assigned to each Shipping Method.@Valid TaxRate
For a Cart withPlatform
TaxMode, thetaxRate
of Line Items is set automatically once a shipping address is set.@NotNull @Valid CentPrecisionMoney
Total price of this Line Item equallingprice
multiplied byquantity
.@NotNull @Valid ProductVariant
Holds the data of the Product Variant added to the Cart.static LineItem
of()
factory methodstatic LineItem
factory method to create a shallow copy LineItemvoid
setAddedAt
(ZonedDateTime addedAt) Date and time (UTC) the Line Item was added to the Cart.void
setCustom
(CustomFields custom) Custom Fields of the Line Item.void
setDiscountedPricePerQuantity
(DiscountedLineItemPriceForQuantity... discountedPricePerQuantity) Discounted price of a single quantity of the Line Item.void
setDiscountedPricePerQuantity
(List<DiscountedLineItemPriceForQuantity> discountedPricePerQuantity) Discounted price of a single quantity of the Line Item.void
setDistributionChannel
(ChannelReference distributionChannel) Used to select a Product Price.void
Unique identifier of the LineItem.void
setInventoryMode
(InventoryMode inventoryMode) Inventory mode specific to this Line Item only, and valid for the entirequantity
of the Line Item.void
User-defined unique identifier of the LineItem.void
setLastModifiedAt
(ZonedDateTime lastModifiedAt) Date and time (UTC) the Line Item was last updated.void
setLineItemMode
(LineItemMode lineItemMode) Indicates how the Line Item is added to the Cart.void
setName
(LocalizedString name) Name of the Product.void
setPerMethodTaxRate
(MethodTaxRate... perMethodTaxRate) Tax Rate per Shipping Method for a Cart withMultiple
ShippingMode.void
setPerMethodTaxRate
(List<MethodTaxRate> perMethodTaxRate) Tax Rate per Shipping Method for a Cart withMultiple
ShippingMode.void
Price of a Line Item selected from the Product Variant according to the ProductpriceMode
.void
setPriceMode
(LineItemPriceMode priceMode) Indicates how the Price for the Line Item is set.void
setProductId
(String productId) id
of the Product the Line Item is based on.void
setProductKey
(String productKey) key
of the Product.void
setProductSlug
(LocalizedString productSlug) slug
of the current version of the Product.void
setProductType
(ProductTypeReference productType) Product Type of the Product.void
setQuantity
(Long quantity) Number of Line Items of the given Product Variant present in the Cart or Order.void
setShippingDetails
(ItemShippingDetails shippingDetails) Container for Line Item-specific addresses.void
State of the Line Item in the Cart or the Order.void
State of the Line Item in the Cart or the Order.void
setSupplyChannel
(ChannelReference supplyChannel) Identifies Inventory entries that are reserved.void
setTaxedPrice
(TaxedItemPrice taxedPrice) Automatically set aftertaxRate
is set.void
setTaxedPricePortions
(MethodTaxedPrice... taxedPricePortions) Total taxed prices based on the quantity of Line Item assigned to each Shipping Method.void
setTaxedPricePortions
(List<MethodTaxedPrice> taxedPricePortions) Total taxed prices based on the quantity of Line Item assigned to each Shipping Method.void
setTaxRate
(TaxRate taxRate) For a Cart withPlatform
TaxMode, thetaxRate
of Line Items is set automatically once a shipping address is set.void
setTotalPrice
(CentPrecisionMoney totalPrice) Total price of this Line Item equallingprice
multiplied byquantity
.void
setVariant
(ProductVariant variant) Holds the data of the Product Variant added to the Cart.static com.fasterxml.jackson.core.type.TypeReference<LineItem>
gives a TypeReference for usage with Jackson DataBinddefault <T> T
withLineItem
(Function<LineItem, T> helper) accessor map functionMethods inherited from interface com.commercetools.api.models.Customizable
unwrapCustomizable
-
Method Details
-
getId
Unique identifier of the LineItem.
- Returns:
- id
-
getKey
String getKey()User-defined unique identifier of the LineItem.
- Returns:
- key
-
getProductId
id
of the Product the Line Item is based on.- Returns:
- productId
-
getProductKey
String getProductKey()key
of the Product.This field is only present on:
- Line Items in a Cart when the
key
is available on that specific Product at the time the LineItem was created or updated on the Cart. - Line Items in an Order when the
key
is available on the specific Product at the time the Order was created from the Cart.
Present on resources created or updated after 3 December 2021.
- Returns:
- productKey
- Line Items in a Cart when the
-
getName
Name of the Product.
- Returns:
- name
-
getProductSlug
slug
of the current version of the Product. Updated automatically if theslug
changes. Empty if the Product has been deleted. TheproductSlug
field of LineItem is not expanded when using Reference Expansion.- Returns:
- productSlug
-
getProductType
Product Type of the Product.
- Returns:
- productType
-
getVariant
Holds the data of the Product Variant added to the Cart.
The data is saved at the time the Product Variant is added to the Cart and is not updated automatically when Product Variant data changes. Must be updated using the Recalculate update action.
- Returns:
- variant
-
getPrice
Price of a Line Item selected from the Product Variant according to the Product
priceMode
. If thepriceMode
isEmbedded
ProductPriceMode and thevariant
field hasn't been updated, the price may not correspond to a price invariant.prices
.- Returns:
- price
-
getQuantity
Number of Line Items of the given Product Variant present in the Cart or Order.
- Returns:
- quantity
-
getTotalPrice
Total price of this Line Item equalling
price
multiplied byquantity
. If the Line Item is discounted, the total price is thediscountedPricePerQuantity
multiplied byquantity
. Includes taxes if the TaxRateincludedInPrice
istrue
.- Returns:
- totalPrice
-
getDiscountedPricePerQuantity
@NotNull @Valid @NotNull @Valid List<DiscountedLineItemPriceForQuantity> getDiscountedPricePerQuantity()Discounted price of a single quantity of the Line Item.
- Returns:
- discountedPricePerQuantity
-
getTaxedPrice
Automatically set after
taxRate
is set.- Returns:
- taxedPrice
-
getTaxedPricePortions
Total taxed prices based on the quantity of Line Item assigned to each Shipping Method. Only applicable for Carts with
Multiple
ShippingMode. Automatically set afterperMethodTaxRate
is set.- Returns:
- taxedPricePortions
-
getState
State of the Line Item in the Cart or the Order.
- Returns:
- state
-
getTaxRate
- For a Cart with
Platform
TaxMode, thetaxRate
of Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address. - For a Cart with
External
TaxMode, thetaxRate
of Line Items can be set using ExternalTaxRateDraft.
- Returns:
- taxRate
- For a Cart with
-
getPerMethodTaxRate
Tax Rate per Shipping Method for a Cart with
Multiple
ShippingMode. For a Cart withPlatform
TaxMode it is automatically set after the Shipping Method is added. For a Cart withExternal
TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.- Returns:
- perMethodTaxRate
-
getSupplyChannel
Identifies Inventory entries that are reserved. The referenced Channel has the
InventorySupply
ChannelRoleEnum.- Returns:
- supplyChannel
-
getDistributionChannel
Used to select a Product Price. The referenced Channel has the
ProductDistribution
ChannelRoleEnum.- Returns:
- distributionChannel
-
getPriceMode
Indicates how the Price for the Line Item is set.
- Returns:
- priceMode
-
getLineItemMode
Indicates how the Line Item is added to the Cart.
- Returns:
- lineItemMode
-
getInventoryMode
InventoryMode getInventoryMode()Inventory mode specific to this Line Item only, and valid for the entire
quantity
of the Line Item. Only present if the inventory mode is different from theinventoryMode
specified on the Cart.- Returns:
- inventoryMode
-
getShippingDetails
Container for Line Item-specific addresses.
- Returns:
- shippingDetails
-
getCustom
Custom Fields of the Line Item.
- Specified by:
getCustom
in interfaceCustomizable<LineItem>
- Returns:
- custom
-
getAddedAt
ZonedDateTime getAddedAt()Date and time (UTC) the Line Item was added to the Cart.
- Returns:
- addedAt
-
getLastModifiedAt
ZonedDateTime getLastModifiedAt()Date and time (UTC) the Line Item was last updated.
- Returns:
- lastModifiedAt
-
setId
Unique identifier of the LineItem.
- Parameters:
id
- value to be set
-
setKey
User-defined unique identifier of the LineItem.
- Parameters:
key
- value to be set
-
setProductId
id
of the Product the Line Item is based on.- Parameters:
productId
- value to be set
-
setProductKey
key
of the Product.This field is only present on:
- Line Items in a Cart when the
key
is available on that specific Product at the time the LineItem was created or updated on the Cart. - Line Items in an Order when the
key
is available on the specific Product at the time the Order was created from the Cart.
Present on resources created or updated after 3 December 2021.
- Parameters:
productKey
- value to be set
- Line Items in a Cart when the
-
setName
Name of the Product.
- Parameters:
name
- value to be set
-
setProductSlug
slug
of the current version of the Product. Updated automatically if theslug
changes. Empty if the Product has been deleted. TheproductSlug
field of LineItem is not expanded when using Reference Expansion.- Parameters:
productSlug
- value to be set
-
setProductType
Product Type of the Product.
- Parameters:
productType
- value to be set
-
setVariant
Holds the data of the Product Variant added to the Cart.
The data is saved at the time the Product Variant is added to the Cart and is not updated automatically when Product Variant data changes. Must be updated using the Recalculate update action.
- Parameters:
variant
- value to be set
-
setPrice
Price of a Line Item selected from the Product Variant according to the Product
priceMode
. If thepriceMode
isEmbedded
ProductPriceMode and thevariant
field hasn't been updated, the price may not correspond to a price invariant.prices
.- Parameters:
price
- value to be set
-
setQuantity
Number of Line Items of the given Product Variant present in the Cart or Order.
- Parameters:
quantity
- value to be set
-
setTotalPrice
Total price of this Line Item equalling
price
multiplied byquantity
. If the Line Item is discounted, the total price is thediscountedPricePerQuantity
multiplied byquantity
. Includes taxes if the TaxRateincludedInPrice
istrue
.- Parameters:
totalPrice
- value to be set
-
setDiscountedPricePerQuantity
void setDiscountedPricePerQuantity(DiscountedLineItemPriceForQuantity... discountedPricePerQuantity) Discounted price of a single quantity of the Line Item.
- Parameters:
discountedPricePerQuantity
- values to be set
-
setDiscountedPricePerQuantity
void setDiscountedPricePerQuantity(List<DiscountedLineItemPriceForQuantity> discountedPricePerQuantity) Discounted price of a single quantity of the Line Item.
- Parameters:
discountedPricePerQuantity
- values to be set
-
setTaxedPrice
Automatically set after
taxRate
is set.- Parameters:
taxedPrice
- value to be set
-
setTaxedPricePortions
Total taxed prices based on the quantity of Line Item assigned to each Shipping Method. Only applicable for Carts with
Multiple
ShippingMode. Automatically set afterperMethodTaxRate
is set.- Parameters:
taxedPricePortions
- values to be set
-
setTaxedPricePortions
Total taxed prices based on the quantity of Line Item assigned to each Shipping Method. Only applicable for Carts with
Multiple
ShippingMode. Automatically set afterperMethodTaxRate
is set.- Parameters:
taxedPricePortions
- values to be set
-
setState
State of the Line Item in the Cart or the Order.
- Parameters:
state
- values to be set
-
setState
State of the Line Item in the Cart or the Order.
- Parameters:
state
- values to be set
-
setTaxRate
- For a Cart with
Platform
TaxMode, thetaxRate
of Line Items is set automatically once a shipping address is set. The rate is based on the TaxCategory that applies for the shipping address. - For a Cart with
External
TaxMode, thetaxRate
of Line Items can be set using ExternalTaxRateDraft.
- Parameters:
taxRate
- value to be set
- For a Cart with
-
setPerMethodTaxRate
Tax Rate per Shipping Method for a Cart with
Multiple
ShippingMode. For a Cart withPlatform
TaxMode it is automatically set after the Shipping Method is added. For a Cart withExternal
TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.- Parameters:
perMethodTaxRate
- values to be set
-
setPerMethodTaxRate
Tax Rate per Shipping Method for a Cart with
Multiple
ShippingMode. For a Cart withPlatform
TaxMode it is automatically set after the Shipping Method is added. For a Cart withExternal
TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.- Parameters:
perMethodTaxRate
- values to be set
-
setSupplyChannel
Identifies Inventory entries that are reserved. The referenced Channel has the
InventorySupply
ChannelRoleEnum.- Parameters:
supplyChannel
- value to be set
-
setDistributionChannel
Used to select a Product Price. The referenced Channel has the
ProductDistribution
ChannelRoleEnum.- Parameters:
distributionChannel
- value to be set
-
setPriceMode
Indicates how the Price for the Line Item is set.
- Parameters:
priceMode
- value to be set
-
setLineItemMode
Indicates how the Line Item is added to the Cart.
- Parameters:
lineItemMode
- value to be set
-
setInventoryMode
Inventory mode specific to this Line Item only, and valid for the entire
quantity
of the Line Item. Only present if the inventory mode is different from theinventoryMode
specified on the Cart.- Parameters:
inventoryMode
- value to be set
-
setShippingDetails
Container for Line Item-specific addresses.
- Parameters:
shippingDetails
- value to be set
-
setCustom
Custom Fields of the Line Item.
- Specified by:
setCustom
in interfaceCustomizable<LineItem>
- Parameters:
custom
- value to be set
-
setAddedAt
Date and time (UTC) the Line Item was added to the Cart.
- Parameters:
addedAt
- value to be set
-
setLastModifiedAt
Date and time (UTC) the Line Item was last updated.
- Parameters:
lastModifiedAt
- value to be set
-
of
factory method- Returns:
- instance of LineItem
-
of
factory method to create a shallow copy LineItem- Parameters:
template
- instance to be copied- Returns:
- copy instance
-
deepCopy
factory method to create a deep copy of LineItem- Parameters:
template
- instance to be copied- Returns:
- copy instance
-
builder
builder factory method for LineItem- Returns:
- builder
-
builder
create builder for LineItem instance- Parameters:
template
- instance with prefilled values for the builder- Returns:
- builder
-
withLineItem
accessor map function- Type Parameters:
T
- mapped type- Parameters:
helper
- function to map the object- Returns:
- mapped value
-
typeReference
gives a TypeReference for usage with Jackson DataBind- Returns:
- TypeReference
-