Interface CartAddLineItemAction
- All Superinterfaces:
CartUpdateAction,CustomizableDraft<CartAddLineItemAction>,ResourceUpdateAction<CartUpdateAction>
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 Line Item price selection.
If the Tax Rate is not set, a MissingTaxRateForCountry error is returned.
If the Line Items do not have a Price according to the Product priceMode value for a selected currency and/or country, Customer Group, or Channel, a MatchingPriceNotFound error is returned.
If the Line Items are added to a Cart bound to a Store with active Product Selections, the selected Product Variant must be available in that Store, otherwise an InvalidInput error is returned.
Example to create an instance using the builder pattern
CartAddLineItemAction cartAddLineItemAction = CartAddLineItemAction.builder()
.build()
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringdiscriminator value for CartAddLineItemAction -
Method Summary
Modifier and TypeMethodDescriptionstatic CartAddLineItemActionBuilderbuilder()builder factory method for CartAddLineItemActionstatic CartAddLineItemActionBuilderbuilder(CartAddLineItemAction template) create builder for CartAddLineItemAction instancecopyDeep()static CartAddLineItemActiondeepCopy(CartAddLineItemAction template) factory method to create a deep copy of CartAddLineItemActionDate and time (UTC) the Product Variant is added to the Cart.@Valid CustomFieldsDraftCustom Fields for the Line Item.@Valid ChannelResourceIdentifierUsed to select a Product Price.@Valid Money@Valid ExternalTaxRateDraftSets the external Tax Rate for the Line Item, if the Cart has theExternalTaxMode andSingleShippingMode.@Valid ExternalLineItemTotalPriceSets the LineItempriceandtotalPricevalues, and thepriceModetoExternalTotalLineItemPriceMode.Inventory mode specific to the Line Item only, and valid for the entirequantityof the Line Item.getKey()User-defined unique identifier of the LineItem.@Valid List<MethodExternalTaxRateDraft>Sets the external Tax Rates for individual Shipping Methods, if the Cart has theExternalTaxMode andMultipleShippingMode.idof the published Product.Quantity of the Product Variant to add to the Cart.@Valid LineItemRecurrenceInfoDraftRecurring Order and frequency data.@Valid ItemShippingDetailsDraftContainer for Line Item-specific addresses.getSku()SKU of the ProductVariant.@Valid ChannelResourceIdentifierUsed to identify Inventory entries that must be reserved.idof the ProductVariant in the Product.static CartAddLineItemActionof()factory methodstatic CartAddLineItemActionof(CartAddLineItemAction template) factory method to create a shallow copy CartAddLineItemActionvoidsetAddedAt(ZonedDateTime addedAt) Date and time (UTC) the Product Variant is added to the Cart.voidsetCustom(CustomFieldsDraft custom) Custom Fields for the Line Item.voidsetDistributionChannel(ChannelResourceIdentifier distributionChannel) Used to select a Product Price.voidsetExternalPrice(Money externalPrice) voidsetExternalTaxRate(ExternalTaxRateDraft externalTaxRate) Sets the external Tax Rate for the Line Item, if the Cart has theExternalTaxMode andSingleShippingMode.voidsetExternalTotalPrice(ExternalLineItemTotalPrice externalTotalPrice) Sets the LineItempriceandtotalPricevalues, and thepriceModetoExternalTotalLineItemPriceMode.voidsetInventoryMode(InventoryMode inventoryMode) Inventory mode specific to the Line Item only, and valid for the entirequantityof the Line Item.voidUser-defined unique identifier of the LineItem.voidsetPerMethodExternalTaxRate(MethodExternalTaxRateDraft... perMethodExternalTaxRate) Sets the external Tax Rates for individual Shipping Methods, if the Cart has theExternalTaxMode andMultipleShippingMode.voidsetPerMethodExternalTaxRate(List<MethodExternalTaxRateDraft> perMethodExternalTaxRate) Sets the external Tax Rates for individual Shipping Methods, if the Cart has theExternalTaxMode andMultipleShippingMode.voidsetProductId(String productId) idof the published Product.voidsetQuantity(Long quantity) Quantity of the Product Variant to add to the Cart.voidsetRecurrenceInfo(LineItemRecurrenceInfoDraft recurrenceInfo) Recurring Order and frequency data.voidsetShippingDetails(ItemShippingDetailsDraft shippingDetails) Container for Line Item-specific addresses.voidSKU of the ProductVariant.voidsetSupplyChannel(ChannelResourceIdentifier supplyChannel) Used to identify Inventory entries that must be reserved.voidsetVariantId(Long variantId) idof the ProductVariant in the Product.static com.fasterxml.jackson.core.type.TypeReference<CartAddLineItemAction>gives a TypeReference for usage with Jackson DataBinddefault <T> Taccessor map functionMethods inherited from interface com.commercetools.api.models.cart.CartUpdateAction
getAction, withCartUpdateActionMethods inherited from interface com.commercetools.api.models.CustomizableDraft
unwrapCustomizableDraftMethods inherited from interface com.commercetools.api.models.ResourceUpdateAction
get
-
Field Details
-
ADD_LINE_ITEM
discriminator value for CartAddLineItemAction- See Also:
-
-
Method Details
-
getKey
String getKey()User-defined unique identifier of the LineItem.
- Returns:
- key
-
getProductId
String getProductId()idof the published Product.Either the
productIdandvariantId, orskumust be provided.- Returns:
- productId
-
getVariantId
Long getVariantId()idof the ProductVariant in the Product. If not provided, the Master Variant is used.Either the
productIdandvariantId, orskumust be provided.- Returns:
- variantId
-
getSku
String getSku()SKU of the ProductVariant.
Either the
productIdandvariantId, orskumust be provided.- Returns:
- sku
-
getQuantity
Long getQuantity()Quantity of the Product Variant to add to the Cart.
- Returns:
- quantity
-
getAddedAt
ZonedDateTime getAddedAt()Date and time (UTC) the Product Variant is added to the Cart. If not set, it defaults to the current date and time.
Optional for backwards compatibility reasons.
- Returns:
- addedAt
-
getDistributionChannel
Used to select a Product Price. The Channel must have the
ProductDistributionChannelRoleEnum. If the Cart is bound to a Store withdistributionChannelsset, the Channel must match one of the Store's distribution channels.- Returns:
- distributionChannel
-
getSupplyChannel
Used to identify Inventory entries that must be reserved. The Channel must have the
InventorySupplyChannelRoleEnum.- Returns:
- supplyChannel
-
getExternalPrice
Sets the LineItem
pricevalue, and thepriceModetoExternalPriceLineItemPriceMode.To set the money value in high precision, use HighPrecisionMoneyDraft.
- Returns:
- externalPrice
-
getExternalTotalPrice
Sets the LineItem
priceandtotalPricevalues, and thepriceModetoExternalTotalLineItemPriceMode.- Returns:
- externalTotalPrice
-
getExternalTaxRate
Sets the external Tax Rate for the Line Item, if the Cart has the
ExternalTaxMode andSingleShippingMode. If the Cart hasMultipleShippingMode, the Tax Rate is accepted but ignored.- Returns:
- externalTaxRate
-
getPerMethodExternalTaxRate
Sets the external Tax Rates for individual Shipping Methods, if the Cart has the
ExternalTaxMode andMultipleShippingMode.- Returns:
- perMethodExternalTaxRate
-
getInventoryMode
InventoryMode getInventoryMode()Inventory mode specific to the Line Item only, and valid for the entire
quantityof the Line Item. Set only if the inventory mode should be different from theinventoryModespecified on the Cart.- Returns:
- inventoryMode
-
getShippingDetails
Container for Line Item-specific addresses.
- Returns:
- shippingDetails
-
getRecurrenceInfo
Recurring Order and frequency data.
- Returns:
- recurrenceInfo
-
getCustom
Custom Fields for the Line Item.
- Specified by:
getCustomin interfaceCustomizableDraft<CartAddLineItemAction>- Returns:
- custom
-
setKey
User-defined unique identifier of the LineItem.
- Parameters:
key- value to be set
-
setProductId
idof the published Product.Either the
productIdandvariantId, orskumust be provided.- Parameters:
productId- value to be set
-
setVariantId
idof the ProductVariant in the Product. If not provided, the Master Variant is used.Either the
productIdandvariantId, orskumust be provided.- Parameters:
variantId- value to be set
-
setSku
SKU of the ProductVariant.
Either the
productIdandvariantId, orskumust be provided.- Parameters:
sku- value to be set
-
setQuantity
Quantity of the Product Variant to add to the Cart.
- Parameters:
quantity- value to be set
-
setAddedAt
Date and time (UTC) the Product Variant is added to the Cart. If not set, it defaults to the current date and time.
Optional for backwards compatibility reasons.
- Parameters:
addedAt- value to be set
-
setDistributionChannel
Used to select a Product Price. The Channel must have the
ProductDistributionChannelRoleEnum. If the Cart is bound to a Store withdistributionChannelsset, the Channel must match one of the Store's distribution channels.- Parameters:
distributionChannel- value to be set
-
setSupplyChannel
Used to identify Inventory entries that must be reserved. The Channel must have the
InventorySupplyChannelRoleEnum.- Parameters:
supplyChannel- value to be set
-
setExternalPrice
Sets the LineItem
pricevalue, and thepriceModetoExternalPriceLineItemPriceMode.To set the money value in high precision, use HighPrecisionMoneyDraft.
- Parameters:
externalPrice- value to be set
-
setExternalTotalPrice
Sets the LineItem
priceandtotalPricevalues, and thepriceModetoExternalTotalLineItemPriceMode.- Parameters:
externalTotalPrice- value to be set
-
setExternalTaxRate
Sets the external Tax Rate for the Line Item, if the Cart has the
ExternalTaxMode andSingleShippingMode. If the Cart hasMultipleShippingMode, the Tax Rate is accepted but ignored.- Parameters:
externalTaxRate- value to be set
-
setPerMethodExternalTaxRate
Sets the external Tax Rates for individual Shipping Methods, if the Cart has the
ExternalTaxMode andMultipleShippingMode.- Parameters:
perMethodExternalTaxRate- values to be set
-
setPerMethodExternalTaxRate
Sets the external Tax Rates for individual Shipping Methods, if the Cart has the
ExternalTaxMode andMultipleShippingMode.- Parameters:
perMethodExternalTaxRate- values to be set
-
setInventoryMode
Inventory mode specific to the Line Item only, and valid for the entire
quantityof the Line Item. Set only if the inventory mode should be different from theinventoryModespecified on the Cart.- Parameters:
inventoryMode- value to be set
-
setShippingDetails
Container for Line Item-specific addresses.
- Parameters:
shippingDetails- value to be set
-
setRecurrenceInfo
Recurring Order and frequency data.
- Parameters:
recurrenceInfo- value to be set
-
setCustom
Custom Fields for the Line Item.
- Specified by:
setCustomin interfaceCustomizableDraft<CartAddLineItemAction>- Parameters:
custom- value to be set
-
of
factory method- Returns:
- instance of CartAddLineItemAction
-
of
factory method to create a shallow copy CartAddLineItemAction- Parameters:
template- instance to be copied- Returns:
- copy instance
-
copyDeep
CartAddLineItemAction copyDeep()- Specified by:
copyDeepin interfaceCartUpdateAction
-
deepCopy
factory method to create a deep copy of CartAddLineItemAction- Parameters:
template- instance to be copied- Returns:
- copy instance
-
builder
builder factory method for CartAddLineItemAction- Returns:
- builder
-
builder
create builder for CartAddLineItemAction instance- Parameters:
template- instance with prefilled values for the builder- Returns:
- builder
-
withCartAddLineItemAction
accessor map function- Type Parameters:
T- mapped type- Parameters:
helper- function to map the object- Returns:
- mapped value
-
typeReference
gives a TypeReference for usage with Jackson DataBind- Returns:
- TypeReference
-