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)
             .plusTaxedPricePortions(taxedPricePortionsBuilder -> taxedPricePortionsBuilder)
             .totalPrice(totalPriceBuilder -> totalPriceBuilder)
             .slug("{slug}")
             .quantity(0.3)
             .plusState(stateBuilder -> stateBuilder)
             .plusPerMethodTaxRate(perMethodTaxRateBuilder -> perMethodTaxRateBuilder)
             .plusDiscountedPricePerQuantity(discountedPricePerQuantityBuilder -> discountedPricePerQuantityBuilder)
             .priceMode(CustomLineItemPriceMode.STANDARD)
             .build()
 
  • Method Details

    • getId

      @NotNull @NotNull String getId()

      Unique identifier of the Custom Line Item.

      Returns:
      id
    • getKey

      String getKey()

      User-defined unique identifier of the Custom Line Item.

      Returns:
      key
    • 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
    • getTaxedPricePortions

      @NotNull @Valid @NotNull @Valid List<MethodTaxedPrice> getTaxedPricePortions()

      Taxed price of the Shipping Method that is automatically set after perMethodTaxRate is set.

      Returns:
      taxedPricePortions
    • 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 or Order.

      Returns:
      quantity
    • getState

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

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

      Returns:
      state
    • getTaxCategory

      @Valid @Valid TaxCategoryReference 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
    • 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
    • getDiscountedPricePerQuantity

      @NotNull @Valid @NotNull @Valid List<DiscountedLineItemPriceForQuantity> 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

      @Valid @Valid ItemShippingDetails getShippingDetails()

      Container for Custom Line Item-specific addresses.

      Returns:
      shippingDetails
    • getPriceMode

      @NotNull @NotNull CustomLineItemPriceMode 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
    • setKey

      void setKey(String key)

      User-defined unique identifier of the Custom Line Item.

      Parameters:
      key - value to be set
    • setName

      void setName(LocalizedString name)

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

      void setTaxedPricePortions(MethodTaxedPrice... taxedPricePortions)

      Taxed price of the Shipping Method that is automatically set after perMethodTaxRate is set.

      Parameters:
      taxedPricePortions - values to be set
    • setTaxedPricePortions

      void setTaxedPricePortions(List<MethodTaxedPrice> taxedPricePortions)

      Taxed price of the Shipping Method that is automatically set after perMethodTaxRate is set.

      Parameters:
      taxedPricePortions - values to be set
    • setTotalPrice

      void setTotalPrice(CentPrecisionMoney totalPrice)

      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 or Order.

      Parameters:
      quantity - value to be set
    • setState

      void setState(ItemState... state)

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

      Parameters:
      state - values to be set
    • setState

      void setState(List<ItemState> state)

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

      Parameters:
      state - values to be set
    • setTaxCategory

      void setTaxCategory(TaxCategoryReference taxCategory)

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

      void setDiscountedPricePerQuantity(DiscountedLineItemPriceForQuantity... discountedPricePerQuantity)

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

      Parameters:
      discountedPricePerQuantity - values to be set
    • setDiscountedPricePerQuantity

      void setDiscountedPricePerQuantity(List<DiscountedLineItemPriceForQuantity> discountedPricePerQuantity)

      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

      void setPriceMode(CustomLineItemPriceMode priceMode)

      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

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

      static CustomLineItemBuilder builder()
      builder factory method for CustomLineItem
      Returns:
      builder
    • builder

      static CustomLineItemBuilder builder(CustomLineItem template)
      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