Interface LineItem

All Superinterfaces:
Customizable<LineItem>

public interface LineItem extends 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 Details

    • getId

      @NotNull @NotNull String getId()

      Unique identifier of the LineItem.

      Returns:
      id
    • getKey

      String getKey()

      User-defined unique identifier of the LineItem.

      Returns:
      key
    • getProductId

      @NotNull @NotNull String 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
    • getName

      @NotNull @Valid @NotNull @Valid LocalizedString getName()

      Name of the Product.

      Returns:
      name
    • getProductSlug

      @Valid @Valid LocalizedString getProductSlug()

      slug of the current version of the Product. Updated automatically if the slug changes. Empty if the Product has been deleted. The productSlug field of LineItem is not expanded when using Reference Expansion.

      Returns:
      productSlug
    • getProductType

      @NotNull @Valid @NotNull @Valid ProductTypeReference getProductType()

      Product Type of the Product.

      Returns:
      productType
    • getVariant

      @NotNull @Valid @NotNull @Valid ProductVariant 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

      @NotNull @Valid @NotNull @Valid Price getPrice()

      Price of a Line Item selected from the Product Variant according to the Product priceMode. If the priceMode is Embedded ProductPriceMode and the variant field hasn't been updated, the price may not correspond to a price in variant.prices.

      Returns:
      price
    • getQuantity

      @NotNull @NotNull Long getQuantity()

      Number of Line Items of the given Product Variant present in the Cart or Order.

      Returns:
      quantity
    • getTotalPrice

      @NotNull @Valid @NotNull @Valid CentPrecisionMoney getTotalPrice()

      Total price of this Line Item equalling price multiplied by quantity. If the Line Item is discounted, the total price is the discountedPricePerQuantity multiplied by quantity. Includes taxes if the TaxRate includedInPrice is true.

      Returns:
      totalPrice
    • getDiscountedPricePerQuantity

      @NotNull @Valid @NotNull @Valid List<DiscountedLineItemPriceForQuantity> getDiscountedPricePerQuantity()

      Discounted price of a single quantity of the Line Item.

      Returns:
      discountedPricePerQuantity
    • getTaxedPrice

      @Valid @Valid TaxedItemPrice getTaxedPrice()

      Automatically set after taxRate is set.

      Returns:
      taxedPrice
    • getTaxedPricePortions

      @NotNull @Valid @NotNull @Valid List<MethodTaxedPrice> 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 after perMethodTaxRate is set.

      Returns:
      taxedPricePortions
    • getState

      @NotNull @Valid @NotNull @Valid List<ItemState> getState()

      State of the Line Item in the Cart or the Order.

      Returns:
      state
    • getTaxRate

      @Valid @Valid TaxRate getTaxRate()
      • For a Cart with Platform TaxMode, the taxRate 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, the taxRate of Line Items can be set using ExternalTaxRateDraft.
      Returns:
      taxRate
    • getPerMethodTaxRate

      @NotNull @Valid @NotNull @Valid List<MethodTaxRate> getPerMethodTaxRate()

      Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

      Returns:
      perMethodTaxRate
    • getSupplyChannel

      @Valid @Valid ChannelReference getSupplyChannel()

      Identifies Inventory entries that are reserved. The referenced Channel has the InventorySupply ChannelRoleEnum.

      Returns:
      supplyChannel
    • getDistributionChannel

      @Valid @Valid ChannelReference getDistributionChannel()

      Used to select a Product Price. The referenced Channel has the ProductDistribution ChannelRoleEnum.

      Returns:
      distributionChannel
    • getPriceMode

      @NotNull @NotNull LineItemPriceMode getPriceMode()

      Indicates how the Price for the Line Item is set.

      Returns:
      priceMode
    • getLineItemMode

      @NotNull @NotNull LineItemMode 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 the inventoryMode specified on the Cart.

      Returns:
      inventoryMode
    • getShippingDetails

      @Valid @Valid ItemShippingDetails getShippingDetails()

      Container for Line Item-specific addresses.

      Returns:
      shippingDetails
    • getCustom

      @Valid @Valid CustomFields getCustom()

      Custom Fields of the Line Item.

      Specified by:
      getCustom in interface Customizable<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

      void setId(String id)

      Unique identifier of the LineItem.

      Parameters:
      id - value to be set
    • setKey

      void setKey(String key)

      User-defined unique identifier of the LineItem.

      Parameters:
      key - value to be set
    • setProductId

      void setProductId(String productId)

      id of the Product the Line Item is based on.

      Parameters:
      productId - value to be set
    • setProductKey

      void setProductKey(String productKey)

      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
    • setName

      void setName(LocalizedString name)

      Name of the Product.

      Parameters:
      name - value to be set
    • setProductSlug

      void setProductSlug(LocalizedString productSlug)

      slug of the current version of the Product. Updated automatically if the slug changes. Empty if the Product has been deleted. The productSlug field of LineItem is not expanded when using Reference Expansion.

      Parameters:
      productSlug - value to be set
    • setProductType

      void setProductType(ProductTypeReference productType)

      Product Type of the Product.

      Parameters:
      productType - value to be set
    • setVariant

      void setVariant(ProductVariant variant)

      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

      void setPrice(Price price)

      Price of a Line Item selected from the Product Variant according to the Product priceMode. If the priceMode is Embedded ProductPriceMode and the variant field hasn't been updated, the price may not correspond to a price in variant.prices.

      Parameters:
      price - value to be set
    • setQuantity

      void setQuantity(Long quantity)

      Number of Line Items of the given Product Variant present in the Cart or Order.

      Parameters:
      quantity - value to be set
    • setTotalPrice

      void setTotalPrice(CentPrecisionMoney totalPrice)

      Total price of this Line Item equalling price multiplied by quantity. If the Line Item is discounted, the total price is the discountedPricePerQuantity multiplied by quantity. Includes taxes if the TaxRate includedInPrice is true.

      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

      void setTaxedPrice(TaxedItemPrice taxedPrice)

      Automatically set after taxRate is set.

      Parameters:
      taxedPrice - value to be set
    • setTaxedPricePortions

      void setTaxedPricePortions(MethodTaxedPrice... taxedPricePortions)

      Total taxed prices based on the quantity of Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. Automatically set after perMethodTaxRate is set.

      Parameters:
      taxedPricePortions - values to be set
    • setTaxedPricePortions

      void setTaxedPricePortions(List<MethodTaxedPrice> taxedPricePortions)

      Total taxed prices based on the quantity of Line Item assigned to each Shipping Method. Only applicable for Carts with Multiple ShippingMode. Automatically set after perMethodTaxRate is set.

      Parameters:
      taxedPricePortions - values to be set
    • setState

      void setState(ItemState... state)

      State of the Line Item in the Cart or the Order.

      Parameters:
      state - values to be set
    • setState

      void setState(List<ItemState> state)

      State of the Line Item in the Cart or the Order.

      Parameters:
      state - values to be set
    • setTaxRate

      void setTaxRate(TaxRate taxRate)
      • For a Cart with Platform TaxMode, the taxRate 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, the taxRate of Line Items can be set using ExternalTaxRateDraft.
      Parameters:
      taxRate - value to be set
    • setPerMethodTaxRate

      void setPerMethodTaxRate(MethodTaxRate... perMethodTaxRate)

      Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

      Parameters:
      perMethodTaxRate - values to be set
    • setPerMethodTaxRate

      void setPerMethodTaxRate(List<MethodTaxRate> perMethodTaxRate)

      Tax Rate per Shipping Method for a Cart with Multiple ShippingMode. For a Cart with Platform TaxMode it is automatically set after the Shipping Method is added. For a Cart with External TaxMode, the Tax Rate must be set with ExternalTaxRateDraft.

      Parameters:
      perMethodTaxRate - values to be set
    • setSupplyChannel

      void setSupplyChannel(ChannelReference supplyChannel)

      Identifies Inventory entries that are reserved. The referenced Channel has the InventorySupply ChannelRoleEnum.

      Parameters:
      supplyChannel - value to be set
    • setDistributionChannel

      void setDistributionChannel(ChannelReference distributionChannel)

      Used to select a Product Price. The referenced Channel has the ProductDistribution ChannelRoleEnum.

      Parameters:
      distributionChannel - value to be set
    • setPriceMode

      void setPriceMode(LineItemPriceMode priceMode)

      Indicates how the Price for the Line Item is set.

      Parameters:
      priceMode - value to be set
    • setLineItemMode

      void setLineItemMode(LineItemMode lineItemMode)

      Indicates how the Line Item is added to the Cart.

      Parameters:
      lineItemMode - value to be set
    • setInventoryMode

      void setInventoryMode(InventoryMode inventoryMode)

      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 the inventoryMode specified on the Cart.

      Parameters:
      inventoryMode - value to be set
    • setShippingDetails

      void setShippingDetails(ItemShippingDetails shippingDetails)

      Container for Line Item-specific addresses.

      Parameters:
      shippingDetails - value to be set
    • setCustom

      void setCustom(CustomFields custom)

      Custom Fields of the Line Item.

      Specified by:
      setCustom in interface Customizable<LineItem>
      Parameters:
      custom - value to be set
    • setAddedAt

      void setAddedAt(ZonedDateTime addedAt)

      Date and time (UTC) the Line Item was added to the Cart.

      Parameters:
      addedAt - value to be set
    • setLastModifiedAt

      void setLastModifiedAt(ZonedDateTime lastModifiedAt)

      Date and time (UTC) the Line Item was last updated.

      Parameters:
      lastModifiedAt - value to be set
    • of

      static LineItem of()
      factory method
      Returns:
      instance of LineItem
    • of

      static LineItem of(LineItem template)
      factory method to create a shallow copy LineItem
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • deepCopy

      @Nullable static LineItem deepCopy(@Nullable LineItem template)
      factory method to create a deep copy of LineItem
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • builder

      static LineItemBuilder builder()
      builder factory method for LineItem
      Returns:
      builder
    • builder

      static LineItemBuilder builder(LineItem template)
      create builder for LineItem instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder
    • withLineItem

      default <T> T withLineItem(Function<LineItem,T> helper)
      accessor map function
      Type Parameters:
      T - mapped type
      Parameters:
      helper - function to map the object
      Returns:
      mapped value
    • typeReference

      static com.fasterxml.jackson.core.type.TypeReference<LineItem> typeReference()
      gives a TypeReference for usage with Jackson DataBind
      Returns:
      TypeReference