Interface CustomLineItem

All Superinterfaces:
Customizable<CustomLineItem>
All Known Implementing Classes:
CustomLineItemImpl

public interface CustomLineItem extends Customizable<CustomLineItem>

A generic item that can be added to the Cart but is not bound to a Product that can be used for discounts (negative money), vouchers, complex cart rules, additional services, or fees. You control the lifecycle of this item.


Example to create an instance using the builder pattern

     CustomLineItem customLineItem = CustomLineItem.builder()
             .id("{id}")
             .name(nameBuilder -> nameBuilder)
             .money(moneyBuilder -> moneyBuilder)
             .totalPrice(totalPriceBuilder -> totalPriceBuilder)
             .slug("{slug}")
             .quantity(0.3)
             .plusState(stateBuilder -> stateBuilder)
             .plusDiscountedPricePerQuantity(discountedPricePerQuantityBuilder -> discountedPricePerQuantityBuilder)
             .priceMode(CustomLineItemPriceMode.STANDARD)
             .build()
 
  • Method Details

    • getId

      @NotNull @NotNull String getId()

      Unique identifier of the Custom Line Item.

      Returns:
      id
    • getName

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

      Name of the Custom Line Item.

      Returns:
      name
    • getMoney

      @NotNull @Valid @NotNull @Valid TypedMoney getMoney()

      Money value of the Custom Line Item.

      Returns:
      money
    • getTaxedPrice

      @Valid @Valid TaxedItemPrice getTaxedPrice()

      Automatically set after the taxRate is set.

      Returns:
      taxedPrice
    • getTotalPrice

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

      Total price of the Custom Line Item (money multiplied by quantity). If the Custom Line Item is discounted, the total price is discountedPricePerQuantity multiplied by quantity.

      Includes taxes if the TaxRate includedInPrice is true.

      Returns:
      totalPrice
    • getSlug

      @NotNull @NotNull String getSlug()

      User-defined identifier used in a deep-link URL for the Custom Line Item. It matches the pattern [a-zA-Z0-9_-]{2,256}.

      Returns:
      slug
    • getQuantity

      @NotNull @NotNull Long getQuantity()

      Number of Custom Line Items in the Cart.

      Returns:
      quantity
    • getState

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

      State of the Custom Line Item in the Cart.

      Returns:
      state
    • getTaxCategory

      Used to select a Tax Rate when a Cart has the Platform TaxMode.

      Returns:
      taxCategory
    • getTaxRate

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

      Discounted price of a single quantity of the Custom Line Item.

      Returns:
      discountedPricePerQuantity
    • getCustom

      @Valid @Valid CustomFields getCustom()

      Custom Fields of the Custom Line Item.

      Specified by:
      getCustom in interface Customizable<CustomLineItem>
      Returns:
      custom
    • getShippingDetails

      Container for Custom Line Item-specific addresses.

      Returns:
      shippingDetails
    • getPriceMode

      Indicates whether Cart Discounts with a matching CartDiscountCustomLineItemsTarget are applied to the Custom Line Item.

      Returns:
      priceMode
    • setId

      void setId(String id)

      Unique identifier of the Custom Line Item.

      Parameters:
      id - value to be set
    • setName

      Name of the Custom Line Item.

      Parameters:
      name - value to be set
    • setMoney

      void setMoney(TypedMoney money)

      Money value of the Custom Line Item.

      Parameters:
      money - value to be set
    • setTaxedPrice

      void setTaxedPrice(TaxedItemPrice taxedPrice)

      Automatically set after the taxRate is set.

      Parameters:
      taxedPrice - value to be set
    • setTotalPrice

      Total price of the Custom Line Item (money multiplied by quantity). If the Custom Line Item is discounted, the total price is discountedPricePerQuantity multiplied by quantity.

      Includes taxes if the TaxRate includedInPrice is true.

      Parameters:
      totalPrice - value to be set
    • setSlug

      void setSlug(String slug)

      User-defined identifier used in a deep-link URL for the Custom Line Item. It matches the pattern [a-zA-Z0-9_-]{2,256}.

      Parameters:
      slug - value to be set
    • setQuantity

      void setQuantity(Long quantity)

      Number of Custom Line Items in the Cart.

      Parameters:
      quantity - value to be set
    • setState

      void setState(ItemState... state)

      State of the Custom Line Item in the Cart.

      Parameters:
      state - values to be set
    • setState

      void setState(List<ItemState> state)

      State of the Custom Line Item in the Cart.

      Parameters:
      state - values to be set
    • setTaxCategory

      Used to select a Tax Rate when a Cart has the Platform TaxMode.

      Parameters:
      taxCategory - value to be set
    • setTaxRate

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

      Discounted price of a single quantity of the Custom Line Item.

      Parameters:
      discountedPricePerQuantity - values to be set
    • setDiscountedPricePerQuantity

      Discounted price of a single quantity of the Custom Line Item.

      Parameters:
      discountedPricePerQuantity - values to be set
    • setCustom

      void setCustom(CustomFields custom)

      Custom Fields of the Custom Line Item.

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

      void setShippingDetails(ItemShippingDetails shippingDetails)

      Container for Custom Line Item-specific addresses.

      Parameters:
      shippingDetails - value to be set
    • setPriceMode

      Indicates whether Cart Discounts with a matching CartDiscountCustomLineItemsTarget are applied to the Custom Line Item.

      Parameters:
      priceMode - value to be set
    • of

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

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

      factory method to create a deep copy of CustomLineItem
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • builder

      builder factory method for CustomLineItem
      Returns:
      builder
    • builder

      create builder for CustomLineItem instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder
    • withCustomLineItem

      default <T> T withCustomLineItem(Function<CustomLineItem,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<CustomLineItem> typeReference()
      gives a TypeReference for usage with Jackson DataBind
      Returns:
      TypeReference