If the Cart contains a LineItem for a Product Variant with the same LineItemMode, Custom Fields, supply and distribution channel, then only the quantity of the existing Line Item is increased. If LineItem shippingDetails is set, it is merged. All addresses will be present afterwards and, for address keys present in both shipping details, the quantity will be summed up. A new Line Item is added when the externalPrice or externalTotalPrice is set in this update action. The LineItem price is set as described in LineItem Price selection.

If the Tax Rate is not set, a [MissingTaxRateForCountry](ctp:api:type:MissingTaxRateForCountryError) error is returned.

If the Line Items do not have a Price according to the [Product](ctp:api:type:Product) `priceMode` value for a selected currency and/or country, Customer Group, or Channel, a [MatchingPriceNotFound](ctp:api:type:MatchingPriceNotFoundError) error is returned.
interface MyCartAddLineItemAction {
    action: "addLineItem";
    addedAt?: string;
    custom?: CustomFieldsDraft;
    distributionChannel?: ChannelResourceIdentifier;
    productId?: string;
    quantity?: number;
    shippingDetails?: ItemShippingDetailsDraft;
    sku?: string;
    supplyChannel?: ChannelResourceIdentifier;
    variantId?: number;
}

Properties

action: "addLineItem"
addedAt?: string

Date and time (UTC) the Line Item was added to the Cart. If not set, it defaults to the current date and time.

Optional for backwards compatibility reasons.

Custom Fields for the Line Item.

distributionChannel?: ChannelResourceIdentifier

Used to select a Product Price. The Channel must have the ProductDistribution ChannelRoleEnum. If the Cart is bound to a Store with distributionChannels set, the Channel must match one of the Store's distribution channels.

productId?: string

id of the Product.

Either the `productId` and `variantId`, or `sku` must be provided.
quantity?: number

Number of Line Items to add to the Cart.

shippingDetails?: ItemShippingDetailsDraft

Container for Line Item-specific addresses.

sku?: string

sku of the ProductVariant.

Either the `productId` and `variantId`, or `sku` must be provided.

Used to identify Inventory entries that must be reserved. The Channel must have the InventorySupply ChannelRoleEnum.

variantId?: number

id of the ProductVariant in the Product.

If not given, the Master Variant is used.

Either the `productId` and `variantId`, or `sku` must be provided.

Generated using TypeDoc