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 LineItemBuilderbuilder()builder factory method for LineItemstatic LineItemBuildercreate builder for LineItem instancecopyDeep()static LineItemfactory method to create a deep copy of LineItemDate and time (UTC) the Line Item was added to the Cart.@Valid CustomFieldsCustom Fields of the Line Item.@NotNull @Valid List<DiscountedLineItemPriceForQuantity>Discounted price of a single quantity of the Line Item.@Valid ChannelReferenceUsed to select a Product Price.@NotNull StringgetId()Unique identifier of the LineItem.Inventory mode specific to this Line Item only, and valid for the entirequantityof the Line Item.getKey()User-defined unique identifier of the LineItem.Date and time (UTC) the Line Item was last updated.@NotNull LineItemModeIndicates how the Line Item is added to the Cart.@NotNull @Valid LocalizedStringgetName()Name of the Product.@NotNull @Valid List<MethodTaxRate>Tax Rate per Shipping Method for a Cart withMultipleShippingMode.@NotNull @Valid PricegetPrice()Price of a Line Item selected from the Product Variant according to the ProductpriceMode.@NotNull LineItemPriceModeIndicates how the Price for the Line Item is set.@NotNull Stringidof the Product the Line Item is based on.keyof the Product.@Valid LocalizedStringslugof the current version of the Product.@NotNull @Valid ProductTypeReferenceProduct Type of the Product.@NotNull Long@Valid LineItemRecurrenceInfoRecurring Order and frequency data.@Valid ItemShippingDetailsContainer for Line Item-specific addresses.getState()Tracks specific quantities of the Line Item within a given State.@Valid ChannelReferenceIdentifies Inventory entries that are reserved.@Valid TaxedItemPriceAutomatically set aftertaxRateis set.@NotNull @Valid List<MethodTaxedPrice>Total taxed prices based on the quantity of Line Item assigned to each Shipping Method.@Valid TaxRateFor a Cart withPlatformTaxMode, thetaxRateof Line Items is set automatically once a shipping address is set.@NotNull @Valid CentPrecisionMoneyTotal price of this Line Item equallingpricemultiplied byquantity.@NotNull @Valid ProductVariantHolds the data of the Product Variant added to the Cart.static LineItemof()factory methodstatic LineItemfactory method to create a shallow copy LineItemvoidsetAddedAt(ZonedDateTime addedAt) Date and time (UTC) the Line Item was added to the Cart.voidsetCustom(CustomFields custom) Custom Fields of the Line Item.voidsetDiscountedPricePerQuantity(DiscountedLineItemPriceForQuantity... discountedPricePerQuantity) Discounted price of a single quantity of the Line Item.voidsetDiscountedPricePerQuantity(List<DiscountedLineItemPriceForQuantity> discountedPricePerQuantity) Discounted price of a single quantity of the Line Item.voidsetDistributionChannel(ChannelReference distributionChannel) Used to select a Product Price.voidUnique identifier of the LineItem.voidsetInventoryMode(InventoryMode inventoryMode) Inventory mode specific to this Line Item only, and valid for the entirequantityof the Line Item.voidUser-defined unique identifier of the LineItem.voidsetLastModifiedAt(ZonedDateTime lastModifiedAt) Date and time (UTC) the Line Item was last updated.voidsetLineItemMode(LineItemMode lineItemMode) Indicates how the Line Item is added to the Cart.voidsetName(LocalizedString name) Name of the Product.voidsetPerMethodTaxRate(MethodTaxRate... perMethodTaxRate) Tax Rate per Shipping Method for a Cart withMultipleShippingMode.voidsetPerMethodTaxRate(List<MethodTaxRate> perMethodTaxRate) Tax Rate per Shipping Method for a Cart withMultipleShippingMode.voidPrice of a Line Item selected from the Product Variant according to the ProductpriceMode.voidsetPriceMode(LineItemPriceMode priceMode) Indicates how the Price for the Line Item is set.voidsetProductId(String productId) idof the Product the Line Item is based on.voidsetProductKey(String productKey) keyof the Product.voidsetProductSlug(LocalizedString productSlug) slugof the current version of the Product.voidsetProductType(ProductTypeReference productType) Product Type of the Product.voidsetQuantity(Long quantity) voidsetRecurrenceInfo(LineItemRecurrenceInfo recurrenceInfo) Recurring Order and frequency data.voidsetShippingDetails(ItemShippingDetails shippingDetails) Container for Line Item-specific addresses.voidTracks specific quantities of the Line Item within a given State.voidTracks specific quantities of the Line Item within a given State.voidsetSupplyChannel(ChannelReference supplyChannel) Identifies Inventory entries that are reserved.voidsetTaxedPrice(TaxedItemPrice taxedPrice) Automatically set aftertaxRateis set.voidsetTaxedPricePortions(MethodTaxedPrice... taxedPricePortions) Total taxed prices based on the quantity of Line Item assigned to each Shipping Method.voidsetTaxedPricePortions(List<MethodTaxedPrice> taxedPricePortions) Total taxed prices based on the quantity of Line Item assigned to each Shipping Method.voidsetTaxRate(TaxRate taxRate) For a Cart withPlatformTaxMode, thetaxRateof Line Items is set automatically once a shipping address is set.voidsetTotalPrice(CentPrecisionMoney totalPrice) Total price of this Line Item equallingpricemultiplied byquantity.voidsetVariant(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> TwithLineItem(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
idof the Product the Line Item is based on.- Returns:
- productId
-
getProductKey
String getProductKey()keyof the Product.This field is only present on:
- Line Items in a Cart when the
keyis available on that specific Product at the time the LineItem was created or updated on the Cart. - Line Items in an Order when the
keyis 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
slugof the current version of the Product. Updated automatically if theslugchanges. Empty if the Product has been deleted. TheproductSlugfield 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 thepriceModeisEmbeddedProductPriceMode and thevariantfield hasn't been updated, the price may not correspond to a price invariant.prices.- Returns:
- price
-
getQuantity
- Returns:
- quantity
-
getTotalPrice
Total price of this Line Item equalling
pricemultiplied byquantity. If the Line Item is discounted, the total price is thediscountedPricePerQuantitymultiplied byquantity. Includes taxes if the TaxRateincludedInPriceistrue.If
ExternalPriceLineItemPriceMode is used with high-precision money, then the total price is rounded by using theHalfEvenrounding mode.- 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
taxRateis set.- Returns:
- taxedPrice
-
getTaxedPricePortions
Total taxed prices based on the quantity of Line Item assigned to each Shipping Method. Only applicable for Carts with
MultipleShippingMode. Automatically set afterperMethodTaxRateis set.- Returns:
- taxedPricePortions
-
getState
Tracks specific quantities of the Line Item within a given State. When a Line Item is added to a Cart, its full quantity is set to the built-in "Initial" state. State transitions for Line Items are managed on the Order.
- Returns:
- state
-
getTaxRate
- For a Cart with
PlatformTaxMode, thetaxRateof 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
ExternalTaxMode, thetaxRateof Line Items can be set using ExternalTaxRateDraft.
- Returns:
- taxRate
- For a Cart with
-
getPerMethodTaxRate
Tax Rate per Shipping Method for a Cart with
MultipleShippingMode. For a Cart withPlatformTaxMode it is automatically set after the Shipping Method is added. For a Cart withExternalTaxMode, the Tax Rate must be set with ExternalTaxRateDraft.- Returns:
- perMethodTaxRate
-
getSupplyChannel
Identifies Inventory entries that are reserved. The referenced Channel has the
InventorySupplyChannelRoleEnum.- Returns:
- supplyChannel
-
getDistributionChannel
Used to select a Product Price. The referenced Channel has the
ProductDistributionChannelRoleEnum.- 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
quantityof the Line Item. Only present if the inventory mode is different from theinventoryModespecified on the Cart.- Returns:
- inventoryMode
-
getShippingDetails
Container for Line Item-specific addresses.
- Returns:
- shippingDetails
-
getCustom
Custom Fields of the Line Item.
- Specified by:
getCustomin 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
-
getRecurrenceInfo
Recurring Order and frequency data.
- Returns:
- recurrenceInfo
-
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
idof the Product the Line Item is based on.- Parameters:
productId- value to be set
-
setProductKey
keyof the Product.This field is only present on:
- Line Items in a Cart when the
keyis available on that specific Product at the time the LineItem was created or updated on the Cart. - Line Items in an Order when the
keyis 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
slugof the current version of the Product. Updated automatically if theslugchanges. Empty if the Product has been deleted. TheproductSlugfield 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 thepriceModeisEmbeddedProductPriceMode and thevariantfield hasn't been updated, the price may not correspond to a price invariant.prices.- Parameters:
price- value to be set
-
setQuantity
- Parameters:
quantity- value to be set
-
setTotalPrice
Total price of this Line Item equalling
pricemultiplied byquantity. If the Line Item is discounted, the total price is thediscountedPricePerQuantitymultiplied byquantity. Includes taxes if the TaxRateincludedInPriceistrue.If
ExternalPriceLineItemPriceMode is used with high-precision money, then the total price is rounded by using theHalfEvenrounding mode.- 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
taxRateis 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
MultipleShippingMode. Automatically set afterperMethodTaxRateis 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
MultipleShippingMode. Automatically set afterperMethodTaxRateis set.- Parameters:
taxedPricePortions- values to be set
-
setState
Tracks specific quantities of the Line Item within a given State. When a Line Item is added to a Cart, its full quantity is set to the built-in "Initial" state. State transitions for Line Items are managed on the Order.
- Parameters:
state- values to be set
-
setState
Tracks specific quantities of the Line Item within a given State. When a Line Item is added to a Cart, its full quantity is set to the built-in "Initial" state. State transitions for Line Items are managed on the Order.
- Parameters:
state- values to be set
-
setTaxRate
- For a Cart with
PlatformTaxMode, thetaxRateof 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
ExternalTaxMode, thetaxRateof 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
MultipleShippingMode. For a Cart withPlatformTaxMode it is automatically set after the Shipping Method is added. For a Cart withExternalTaxMode, the Tax Rate must be set with ExternalTaxRateDraft.- Parameters:
perMethodTaxRate- values to be set
-
setPerMethodTaxRate
Tax Rate per Shipping Method for a Cart with
MultipleShippingMode. For a Cart withPlatformTaxMode it is automatically set after the Shipping Method is added. For a Cart withExternalTaxMode, 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
InventorySupplyChannelRoleEnum.- Parameters:
supplyChannel- value to be set
-
setDistributionChannel
Used to select a Product Price. The referenced Channel has the
ProductDistributionChannelRoleEnum.- 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
quantityof the Line Item. Only present if the inventory mode is different from theinventoryModespecified 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:
setCustomin 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
-
setRecurrenceInfo
Recurring Order and frequency data.
- Parameters:
recurrenceInfo- 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
-
copyDeep
LineItem copyDeep() -
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
-