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](ctp:api:type:InvalidOperationError) error is returned.

If the Tax Rate is not set, a [MissingTaxRateForCountry](ctp:api:type:MissingTaxRateForCountryError) error is returned.
interface CartAddCustomLineItemAction {
    action: "addCustomLineItem";
    custom?: CustomFieldsDraft;
    externalTaxRate?: ExternalTaxRateDraft;
    money: _Money;
    name: LocalizedString;
    priceMode?: string;
    quantity?: number;
    shippingDetails?: ItemShippingDetailsDraft;
    slug: string;
    taxCategory?: TaxCategoryResourceIdentifier;
}

Properties

action: "addCustomLineItem"

Custom Fields for the Custom Line Item.

externalTaxRate?: ExternalTaxRateDraft

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

money: _Money

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

Name of the Custom Line Item.

priceMode?: string
  • If Standard, Cart Discounts with a matching CartDiscountCustomLineItemsTarget are applied to the Custom Line Item.
    • If External, Cart Discounts are not considered on the Custom Line Item.
quantity?: number

Number of Custom Line Items to add to the Cart.

shippingDetails?: ItemShippingDetailsDraft

Container for Custom Line Item-specific addresses.

slug: string

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}.

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

If [TaxMode](ctp:api:type:TaxMode) is `Platform`, this field must not be empty.

Generated using TypeDoc