Interface CartAddCustomLineItemAction

All Superinterfaces:
CartUpdateAction, CustomizableDraft<CartAddCustomLineItemAction>, ResourceUpdateAction<CartUpdateAction>

public interface CartAddCustomLineItemAction extends CartUpdateAction, CustomizableDraft<CartAddCustomLineItemAction>

If the Cart already contains a CustomLineItem with the same slug, name, money, taxCategory, state, and Custom Fields, then only the quantity of the existing Custom Line Item is increased. If CustomLineItem shippingDetails are set, they are merged with the targets that already exist on the ItemShippingDetails of the Custom Line Item. In case of overlapping address keys the ItemShippingTarget quantity is summed up.

If the Cart already contains a Custom Line Item with the same slug that is otherwise not identical, an InvalidOperation error is returned.

If the Tax Rate is not set, a MissingTaxRateForCountry error is returned.


Example to create an instance using the builder pattern

     CartAddCustomLineItemAction cartAddCustomLineItemAction = CartAddCustomLineItemAction.builder()
             .money(moneyBuilder -> moneyBuilder)
             .name(nameBuilder -> nameBuilder)
             .slug("{slug}")
             .build()
 
  • Field Details

    • ADD_CUSTOM_LINE_ITEM

      static final String ADD_CUSTOM_LINE_ITEM
      discriminator value for CartAddCustomLineItemAction
      See Also:
  • Method Details

    • getMoney

      @NotNull @Valid @NotNull @Valid Money getMoney()

      Money value of the Custom Line Item. The value can be negative.

      Returns:
      money
    • getName

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

      Name of the Custom Line Item.

      Returns:
      name
    • getKey

      String getKey()

      User-defined unique identifier of the Custom Line Item.

      Returns:
      key
    • getQuantity

      Long getQuantity()

      Number of Custom Line Items to add to the Cart.

      Returns:
      quantity
    • getSlug

      @NotNull @NotNull String getSlug()

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

      Returns:
      slug
    • getTaxCategory

      @Valid @Valid TaxCategoryResourceIdentifier getTaxCategory()

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

      If TaxMode is Platform, this field must not be empty.

      Returns:
      taxCategory
    • getExternalTaxRate

      @Valid @Valid ExternalTaxRateDraft getExternalTaxRate()

      An external Tax Rate can be set if the Cart has External TaxMode.

      Returns:
      externalTaxRate
    • getShippingDetails

      @Valid @Valid ItemShippingDetailsDraft getShippingDetails()

      Container for Custom Line Item-specific addresses.

      Returns:
      shippingDetails
    • getCustom

      @Valid @Valid CustomFieldsDraft getCustom()

      Custom Fields for the Custom Line Item.

      Specified by:
      getCustom in interface CustomizableDraft<CartAddCustomLineItemAction>
      Returns:
      custom
    • getPriceMode

      CustomLineItemPriceMode getPriceMode()
      • If Standard, Cart Discounts with a matching CartDiscountCustomLineItemsTarget, MultiBuyCustomLineItemsTarget, or CartDiscountPatternTarget are applied to the Custom Line Item.
      • If External, Cart Discounts are not considered on the Custom Line Item.
      Returns:
      priceMode
    • setMoney

      void setMoney(Money money)

      Money value of the Custom Line Item. The value can be negative.

      Parameters:
      money - value to be set
    • setName

      void setName(LocalizedString name)

      Name of the Custom Line Item.

      Parameters:
      name - value to be set
    • setKey

      void setKey(String key)

      User-defined unique identifier of the Custom Line Item.

      Parameters:
      key - value to be set
    • setQuantity

      void setQuantity(Long quantity)

      Number of Custom Line Items to add to the Cart.

      Parameters:
      quantity - value to be set
    • setSlug

      void setSlug(String slug)

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

      Parameters:
      slug - value to be set
    • setTaxCategory

      void setTaxCategory(TaxCategoryResourceIdentifier taxCategory)

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

      If TaxMode is Platform, this field must not be empty.

      Parameters:
      taxCategory - value to be set
    • setExternalTaxRate

      void setExternalTaxRate(ExternalTaxRateDraft externalTaxRate)

      An external Tax Rate can be set if the Cart has External TaxMode.

      Parameters:
      externalTaxRate - value to be set
    • setShippingDetails

      void setShippingDetails(ItemShippingDetailsDraft shippingDetails)

      Container for Custom Line Item-specific addresses.

      Parameters:
      shippingDetails - value to be set
    • setCustom

      void setCustom(CustomFieldsDraft custom)

      Custom Fields for the Custom Line Item.

      Specified by:
      setCustom in interface CustomizableDraft<CartAddCustomLineItemAction>
      Parameters:
      custom - value to be set
    • setPriceMode

      void setPriceMode(CustomLineItemPriceMode priceMode)
      • If Standard, Cart Discounts with a matching CartDiscountCustomLineItemsTarget, MultiBuyCustomLineItemsTarget, or CartDiscountPatternTarget are applied to the Custom Line Item.
      • If External, Cart Discounts are not considered on the Custom Line Item.
      Parameters:
      priceMode - value to be set
    • of

      factory method
      Returns:
      instance of CartAddCustomLineItemAction
    • of

      factory method to create a shallow copy CartAddCustomLineItemAction
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • deepCopy

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

      builder factory method for CartAddCustomLineItemAction
      Returns:
      builder
    • builder

      create builder for CartAddCustomLineItemAction instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder
    • withCartAddCustomLineItemAction

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