Class CartBuilder

java.lang.Object
com.commercetools.api.models.cart.CartBuilder
All Implemented Interfaces:
Builder<Cart>

public class CartBuilder extends Object implements Builder<Cart>
CartBuilder
Example to create an instance using the builder pattern

     Cart cart = Cart.builder()
             .id("{id}")
             .version(0.3)
             .createdAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .lastModifiedAt(ZonedDateTime.parse("2022-01-01T12:00:00.301Z"))
             .plusLineItems(lineItemsBuilder -> lineItemsBuilder)
             .plusCustomLineItems(customLineItemsBuilder -> customLineItemsBuilder)
             .totalPrice(totalPriceBuilder -> totalPriceBuilder)
             .taxMode(TaxMode.PLATFORM)
             .taxRoundingMode(RoundingMode.HALF_EVEN)
             .taxCalculationMode(TaxCalculationMode.LINE_ITEM_LEVEL)
             .inventoryMode(InventoryMode.NONE)
             .cartState(CartState.ACTIVE)
             .shippingMode(ShippingMode.SINGLE)
             .plusShipping(shippingBuilder -> shippingBuilder)
             .plusItemShippingAddresses(itemShippingAddressesBuilder -> itemShippingAddressesBuilder)
             .plusDiscountCodes(discountCodesBuilder -> discountCodesBuilder)
             .plusDirectDiscounts(directDiscountsBuilder -> directDiscountsBuilder)
             .plusRefusedGifts(refusedGiftsBuilder -> refusedGiftsBuilder)
             .origin(CartOrigin.CUSTOMER)
             .build()
 
  • Constructor Details

    • CartBuilder

      public CartBuilder()
  • Method Details

    • id

      public CartBuilder id(String id)

      Unique identifier of the Cart.

      Parameters:
      id - value to be set
      Returns:
      Builder
    • version

      public CartBuilder version(Long version)

      Current version of the Cart.

      Parameters:
      version - value to be set
      Returns:
      Builder
    • createdAt

      public CartBuilder createdAt(ZonedDateTime createdAt)

      Date and time (UTC) the Cart was initially created.

      Parameters:
      createdAt - value to be set
      Returns:
      Builder
    • lastModifiedAt

      public CartBuilder lastModifiedAt(ZonedDateTime lastModifiedAt)

      Date and time (UTC) the Cart was last updated.

      Parameters:
      lastModifiedAt - value to be set
      Returns:
      Builder
    • key

      public CartBuilder key(@Nullable String key)

      User-defined unique identifier of the Cart.

      Parameters:
      key - value to be set
      Returns:
      Builder
    • customerId

      public CartBuilder customerId(@Nullable String customerId)

      id of the Customer that the Cart belongs to.

      Parameters:
      customerId - value to be set
      Returns:
      Builder
    • customerEmail

      public CartBuilder customerEmail(@Nullable String customerEmail)

      Email address of the Customer that the Cart belongs to.

      Parameters:
      customerEmail - value to be set
      Returns:
      Builder
    • customerGroup

      Reference to the Customer Group of the Customer that the Cart belongs to. Used for Line Item price selection.

      Parameters:
      builder - function to build the customerGroup value
      Returns:
      Builder
    • withCustomerGroup

      Reference to the Customer Group of the Customer that the Cart belongs to. Used for Line Item price selection.

      Parameters:
      builder - function to build the customerGroup value
      Returns:
      Builder
    • customerGroup

      public CartBuilder customerGroup(@Nullable CustomerGroupReference customerGroup)

      Reference to the Customer Group of the Customer that the Cart belongs to. Used for Line Item price selection.

      Parameters:
      customerGroup - value to be set
      Returns:
      Builder
    • anonymousId

      public CartBuilder anonymousId(@Nullable String anonymousId)

      Anonymous session associated with the Cart.

      Parameters:
      anonymousId - value to be set
      Returns:
      Builder
    • businessUnit

      Reference to a Business Unit the Cart belongs to.

      Parameters:
      builder - function to build the businessUnit value
      Returns:
      Builder
    • withBusinessUnit

      Reference to a Business Unit the Cart belongs to.

      Parameters:
      builder - function to build the businessUnit value
      Returns:
      Builder
    • businessUnit

      public CartBuilder businessUnit(@Nullable BusinessUnitKeyReference businessUnit)

      Reference to a Business Unit the Cart belongs to.

      Parameters:
      businessUnit - value to be set
      Returns:
      Builder
    • store

      Reference to a Store the Cart belongs to.

      Parameters:
      builder - function to build the store value
      Returns:
      Builder
    • withStore

      Reference to a Store the Cart belongs to.

      Parameters:
      builder - function to build the store value
      Returns:
      Builder
    • store

      public CartBuilder store(@Nullable StoreKeyReference store)

      Reference to a Store the Cart belongs to.

      Parameters:
      store - value to be set
      Returns:
      Builder
    • lineItems

      public CartBuilder lineItems(LineItem... lineItems)

      Line Items added to the Cart.

      Parameters:
      lineItems - value to be set
      Returns:
      Builder
    • lineItems

      public CartBuilder lineItems(List<LineItem> lineItems)

      Line Items added to the Cart.

      Parameters:
      lineItems - value to be set
      Returns:
      Builder
    • plusLineItems

      public CartBuilder plusLineItems(LineItem... lineItems)

      Line Items added to the Cart.

      Parameters:
      lineItems - value to be set
      Returns:
      Builder
    • plusLineItems

      public CartBuilder plusLineItems(Function<LineItemBuilder,LineItemBuilder> builder)

      Line Items added to the Cart.

      Parameters:
      builder - function to build the lineItems value
      Returns:
      Builder
    • withLineItems

      public CartBuilder withLineItems(Function<LineItemBuilder,LineItemBuilder> builder)

      Line Items added to the Cart.

      Parameters:
      builder - function to build the lineItems value
      Returns:
      Builder
    • addLineItems

      public CartBuilder addLineItems(Function<LineItemBuilder,LineItem> builder)

      Line Items added to the Cart.

      Parameters:
      builder - function to build the lineItems value
      Returns:
      Builder
    • setLineItems

      public CartBuilder setLineItems(Function<LineItemBuilder,LineItem> builder)

      Line Items added to the Cart.

      Parameters:
      builder - function to build the lineItems value
      Returns:
      Builder
    • customLineItems

      public CartBuilder customLineItems(CustomLineItem... customLineItems)

      Custom Line Items added to the Cart.

      Parameters:
      customLineItems - value to be set
      Returns:
      Builder
    • customLineItems

      public CartBuilder customLineItems(List<CustomLineItem> customLineItems)

      Custom Line Items added to the Cart.

      Parameters:
      customLineItems - value to be set
      Returns:
      Builder
    • plusCustomLineItems

      public CartBuilder plusCustomLineItems(CustomLineItem... customLineItems)

      Custom Line Items added to the Cart.

      Parameters:
      customLineItems - value to be set
      Returns:
      Builder
    • plusCustomLineItems

      public CartBuilder plusCustomLineItems(Function<CustomLineItemBuilder,CustomLineItemBuilder> builder)

      Custom Line Items added to the Cart.

      Parameters:
      builder - function to build the customLineItems value
      Returns:
      Builder
    • withCustomLineItems

      public CartBuilder withCustomLineItems(Function<CustomLineItemBuilder,CustomLineItemBuilder> builder)

      Custom Line Items added to the Cart.

      Parameters:
      builder - function to build the customLineItems value
      Returns:
      Builder
    • addCustomLineItems

      public CartBuilder addCustomLineItems(Function<CustomLineItemBuilder,CustomLineItem> builder)

      Custom Line Items added to the Cart.

      Parameters:
      builder - function to build the customLineItems value
      Returns:
      Builder
    • setCustomLineItems

      public CartBuilder setCustomLineItems(Function<CustomLineItemBuilder,CustomLineItem> builder)

      Custom Line Items added to the Cart.

      Parameters:
      builder - function to build the customLineItems value
      Returns:
      Builder
    • totalLineItemQuantity

      public CartBuilder totalLineItemQuantity(@Nullable Long totalLineItemQuantity)

      Sum of all LineItem quantities, excluding CustomLineItems. Only present when the Cart has at least one LineItem.

      Parameters:
      totalLineItemQuantity - value to be set
      Returns:
      Builder
    • totalPrice

      Sum of the totalPrice field of all LineItems and CustomLineItems, and if available, the price field of ShippingInfo. If a discount applies on totalPrice, this field holds the discounted value.

      Taxes are included if TaxRate includedInPrice is true for each price.

      Parameters:
      builder - function to build the totalPrice value
      Returns:
      Builder
    • withTotalPrice

      Sum of the totalPrice field of all LineItems and CustomLineItems, and if available, the price field of ShippingInfo. If a discount applies on totalPrice, this field holds the discounted value.

      Taxes are included if TaxRate includedInPrice is true for each price.

      Parameters:
      builder - function to build the totalPrice value
      Returns:
      Builder
    • totalPrice

      public CartBuilder totalPrice(CentPrecisionMoney totalPrice)

      Sum of the totalPrice field of all LineItems and CustomLineItems, and if available, the price field of ShippingInfo. If a discount applies on totalPrice, this field holds the discounted value.

      Taxes are included if TaxRate includedInPrice is true for each price.

      Parameters:
      totalPrice - value to be set
      Returns:
      Builder
    • taxedPrice

      • For a Cart with Platform TaxMode, it is automatically set when a shipping address is set. For Carts with Multiple ShippingMode, all Line Items and Custom Line Items must be fully distributed between the Shipping Methods (via shippingDetails), otherwise taxedPrice is not automatically set.
      • For a Cart with External TaxMode, it is automatically set when shippingAddress and external Tax Rates for all Line Items, Custom Line Items, and Shipping Methods in the Cart are set. For Carts with Multiple ShippingMode, all allocations must have their respective tax rates present in perMethodTaxRate, otherwise taxedPrice is not automatically set.

      If a discount applies on totalPrice, this field holds the discounted values.

      Parameters:
      builder - function to build the taxedPrice value
      Returns:
      Builder
    • withTaxedPrice

      public CartBuilder withTaxedPrice(Function<TaxedPriceBuilder,TaxedPrice> builder)
      • For a Cart with Platform TaxMode, it is automatically set when a shipping address is set. For Carts with Multiple ShippingMode, all Line Items and Custom Line Items must be fully distributed between the Shipping Methods (via shippingDetails), otherwise taxedPrice is not automatically set.
      • For a Cart with External TaxMode, it is automatically set when shippingAddress and external Tax Rates for all Line Items, Custom Line Items, and Shipping Methods in the Cart are set. For Carts with Multiple ShippingMode, all allocations must have their respective tax rates present in perMethodTaxRate, otherwise taxedPrice is not automatically set.

      If a discount applies on totalPrice, this field holds the discounted values.

      Parameters:
      builder - function to build the taxedPrice value
      Returns:
      Builder
    • taxedPrice

      public CartBuilder taxedPrice(@Nullable TaxedPrice taxedPrice)
      • For a Cart with Platform TaxMode, it is automatically set when a shipping address is set. For Carts with Multiple ShippingMode, all Line Items and Custom Line Items must be fully distributed between the Shipping Methods (via shippingDetails), otherwise taxedPrice is not automatically set.
      • For a Cart with External TaxMode, it is automatically set when shippingAddress and external Tax Rates for all Line Items, Custom Line Items, and Shipping Methods in the Cart are set. For Carts with Multiple ShippingMode, all allocations must have their respective tax rates present in perMethodTaxRate, otherwise taxedPrice is not automatically set.

      If a discount applies on totalPrice, this field holds the discounted values.

      Parameters:
      taxedPrice - value to be set
      Returns:
      Builder
    • taxedShippingPrice

      public CartBuilder taxedShippingPrice(Function<TaxedPriceBuilder,TaxedPriceBuilder> builder)

      Sum of the taxedPrice field of ShippingInfo across all Shipping Methods.

      Parameters:
      builder - function to build the taxedShippingPrice value
      Returns:
      Builder
    • withTaxedShippingPrice

      public CartBuilder withTaxedShippingPrice(Function<TaxedPriceBuilder,TaxedPrice> builder)

      Sum of the taxedPrice field of ShippingInfo across all Shipping Methods.

      Parameters:
      builder - function to build the taxedShippingPrice value
      Returns:
      Builder
    • taxedShippingPrice

      public CartBuilder taxedShippingPrice(@Nullable TaxedPrice taxedShippingPrice)

      Sum of the taxedPrice field of ShippingInfo across all Shipping Methods.

      Parameters:
      taxedShippingPrice - value to be set
      Returns:
      Builder
    • discountOnTotalPrice

      Discounts that apply on the Cart totalPrice.

      Parameters:
      builder - function to build the discountOnTotalPrice value
      Returns:
      Builder
    • withDiscountOnTotalPrice

      public CartBuilder withDiscountOnTotalPrice(Function<DiscountOnTotalPriceBuilder,DiscountOnTotalPrice> builder)

      Discounts that apply on the Cart totalPrice.

      Parameters:
      builder - function to build the discountOnTotalPrice value
      Returns:
      Builder
    • discountOnTotalPrice

      public CartBuilder discountOnTotalPrice(@Nullable DiscountOnTotalPrice discountOnTotalPrice)

      Discounts that apply on the Cart totalPrice.

      Parameters:
      discountOnTotalPrice - value to be set
      Returns:
      Builder
    • taxMode

      public CartBuilder taxMode(TaxMode taxMode)

      Indicates how Tax Rates are set.

      Parameters:
      taxMode - value to be set
      Returns:
      Builder
    • taxRoundingMode

      public CartBuilder taxRoundingMode(RoundingMode taxRoundingMode)

      Indicates how monetary values are rounded when calculating taxes for taxedPrice.

      Parameters:
      taxRoundingMode - value to be set
      Returns:
      Builder
    • taxCalculationMode

      public CartBuilder taxCalculationMode(TaxCalculationMode taxCalculationMode)

      Indicates how taxes are calculated when calculating taxes for taxedPrice.

      Parameters:
      taxCalculationMode - value to be set
      Returns:
      Builder
    • inventoryMode

      public CartBuilder inventoryMode(InventoryMode inventoryMode)

      Indicates how stock quantities are tracked for Line Items in the Cart.

      Parameters:
      inventoryMode - value to be set
      Returns:
      Builder
    • cartState

      public CartBuilder cartState(CartState cartState)

      Current status of the Cart.

      Parameters:
      cartState - value to be set
      Returns:
      Builder
    • billingAddress

      public CartBuilder billingAddress(Function<AddressBuilder,AddressBuilder> builder)

      Billing address associated with the Cart.

      Parameters:
      builder - function to build the billingAddress value
      Returns:
      Builder
    • withBillingAddress

      public CartBuilder withBillingAddress(Function<AddressBuilder,Address> builder)

      Billing address associated with the Cart.

      Parameters:
      builder - function to build the billingAddress value
      Returns:
      Builder
    • billingAddress

      public CartBuilder billingAddress(@Nullable Address billingAddress)

      Billing address associated with the Cart.

      Parameters:
      billingAddress - value to be set
      Returns:
      Builder
    • shippingAddress

      public CartBuilder shippingAddress(Function<AddressBuilder,AddressBuilder> builder)

      Shipping address for a Cart with Single ShippingMode. Determines eligible ShippingMethod rates and Tax Rates of Line Items.

      Parameters:
      builder - function to build the shippingAddress value
      Returns:
      Builder
    • withShippingAddress

      public CartBuilder withShippingAddress(Function<AddressBuilder,Address> builder)

      Shipping address for a Cart with Single ShippingMode. Determines eligible ShippingMethod rates and Tax Rates of Line Items.

      Parameters:
      builder - function to build the shippingAddress value
      Returns:
      Builder
    • shippingAddress

      public CartBuilder shippingAddress(@Nullable Address shippingAddress)

      Shipping address for a Cart with Single ShippingMode. Determines eligible ShippingMethod rates and Tax Rates of Line Items.

      Parameters:
      shippingAddress - value to be set
      Returns:
      Builder
    • shippingMode

      public CartBuilder shippingMode(ShippingMode shippingMode)

      Indicates whether the Cart has one or multiple Shipping Methods.

      Parameters:
      shippingMode - value to be set
      Returns:
      Builder
    • shippingKey

      public CartBuilder shippingKey(@Nullable String shippingKey)

      User-defined unique identifier of the Shipping Method in a Cart with Single ShippingMode.

      Parameters:
      shippingKey - value to be set
      Returns:
      Builder
    • shippingInfo

      Shipping-related information of a Cart with Single ShippingMode. Automatically set when a Shipping Method is set.

      Parameters:
      builder - function to build the shippingInfo value
      Returns:
      Builder
    • withShippingInfo

      public CartBuilder withShippingInfo(Function<ShippingInfoBuilder,ShippingInfo> builder)

      Shipping-related information of a Cart with Single ShippingMode. Automatically set when a Shipping Method is set.

      Parameters:
      builder - function to build the shippingInfo value
      Returns:
      Builder
    • shippingInfo

      public CartBuilder shippingInfo(@Nullable ShippingInfo shippingInfo)

      Shipping-related information of a Cart with Single ShippingMode. Automatically set when a Shipping Method is set.

      Parameters:
      shippingInfo - value to be set
      Returns:
      Builder
    • shippingRateInput

      public CartBuilder shippingRateInput(@Nullable ShippingRateInput shippingRateInput)

      Input used to select a ShippingRatePriceTier. The data type of this field depends on the shippingRateInputType.type configured in the Project:

      • If CartClassification, it is ClassificationShippingRateInput.
      • If CartScore, it is ScoreShippingRateInput.
      • If CartValue, it cannot be used.
      Parameters:
      shippingRateInput - value to be set
      Returns:
      Builder
    • shippingRateInput

      public CartBuilder shippingRateInput(Function<ShippingRateInputBuilder,Builder<? extends ShippingRateInput>> builder)

      Input used to select a ShippingRatePriceTier. The data type of this field depends on the shippingRateInputType.type configured in the Project:

      • If CartClassification, it is ClassificationShippingRateInput.
      • If CartScore, it is ScoreShippingRateInput.
      • If CartValue, it cannot be used.
      Parameters:
      builder - function to build the shippingRateInput value
      Returns:
      Builder
    • shippingCustomFields

      public CartBuilder shippingCustomFields(Function<CustomFieldsBuilder,CustomFieldsBuilder> builder)

      Custom Fields of the Shipping Method in a Cart with Single ShippingMode.

      Parameters:
      builder - function to build the shippingCustomFields value
      Returns:
      Builder
    • withShippingCustomFields

      public CartBuilder withShippingCustomFields(Function<CustomFieldsBuilder,CustomFields> builder)

      Custom Fields of the Shipping Method in a Cart with Single ShippingMode.

      Parameters:
      builder - function to build the shippingCustomFields value
      Returns:
      Builder
    • shippingCustomFields

      public CartBuilder shippingCustomFields(@Nullable CustomFields shippingCustomFields)

      Custom Fields of the Shipping Method in a Cart with Single ShippingMode.

      Parameters:
      shippingCustomFields - value to be set
      Returns:
      Builder
    • shipping

      public CartBuilder shipping(Shipping... shipping)

      Shipping-related information of a Cart with Multiple ShippingMode. Updated automatically each time a new Shipping Method is added.

      Parameters:
      shipping - value to be set
      Returns:
      Builder
    • shipping

      public CartBuilder shipping(List<Shipping> shipping)

      Shipping-related information of a Cart with Multiple ShippingMode. Updated automatically each time a new Shipping Method is added.

      Parameters:
      shipping - value to be set
      Returns:
      Builder
    • plusShipping

      public CartBuilder plusShipping(Shipping... shipping)

      Shipping-related information of a Cart with Multiple ShippingMode. Updated automatically each time a new Shipping Method is added.

      Parameters:
      shipping - value to be set
      Returns:
      Builder
    • plusShipping

      public CartBuilder plusShipping(Function<ShippingBuilder,ShippingBuilder> builder)

      Shipping-related information of a Cart with Multiple ShippingMode. Updated automatically each time a new Shipping Method is added.

      Parameters:
      builder - function to build the shipping value
      Returns:
      Builder
    • withShipping

      public CartBuilder withShipping(Function<ShippingBuilder,ShippingBuilder> builder)

      Shipping-related information of a Cart with Multiple ShippingMode. Updated automatically each time a new Shipping Method is added.

      Parameters:
      builder - function to build the shipping value
      Returns:
      Builder
    • addShipping

      public CartBuilder addShipping(Function<ShippingBuilder,Shipping> builder)

      Shipping-related information of a Cart with Multiple ShippingMode. Updated automatically each time a new Shipping Method is added.

      Parameters:
      builder - function to build the shipping value
      Returns:
      Builder
    • setShipping

      public CartBuilder setShipping(Function<ShippingBuilder,Shipping> builder)

      Shipping-related information of a Cart with Multiple ShippingMode. Updated automatically each time a new Shipping Method is added.

      Parameters:
      builder - function to build the shipping value
      Returns:
      Builder
    • itemShippingAddresses

      public CartBuilder itemShippingAddresses(Address... itemShippingAddresses)

      Additional shipping addresses of the Cart as specified by LineItems using the shippingDetails field.

      For Carts with Single ShippingMode: eligible Shipping Methods or applicable Tax Rates are determined by the address in shippingAddress, and not itemShippingAddresses.

      Parameters:
      itemShippingAddresses - value to be set
      Returns:
      Builder
    • itemShippingAddresses

      public CartBuilder itemShippingAddresses(List<Address> itemShippingAddresses)

      Additional shipping addresses of the Cart as specified by LineItems using the shippingDetails field.

      For Carts with Single ShippingMode: eligible Shipping Methods or applicable Tax Rates are determined by the address in shippingAddress, and not itemShippingAddresses.

      Parameters:
      itemShippingAddresses - value to be set
      Returns:
      Builder
    • plusItemShippingAddresses

      public CartBuilder plusItemShippingAddresses(Address... itemShippingAddresses)

      Additional shipping addresses of the Cart as specified by LineItems using the shippingDetails field.

      For Carts with Single ShippingMode: eligible Shipping Methods or applicable Tax Rates are determined by the address in shippingAddress, and not itemShippingAddresses.

      Parameters:
      itemShippingAddresses - value to be set
      Returns:
      Builder
    • plusItemShippingAddresses

      public CartBuilder plusItemShippingAddresses(Function<AddressBuilder,AddressBuilder> builder)

      Additional shipping addresses of the Cart as specified by LineItems using the shippingDetails field.

      For Carts with Single ShippingMode: eligible Shipping Methods or applicable Tax Rates are determined by the address in shippingAddress, and not itemShippingAddresses.

      Parameters:
      builder - function to build the itemShippingAddresses value
      Returns:
      Builder
    • withItemShippingAddresses

      public CartBuilder withItemShippingAddresses(Function<AddressBuilder,AddressBuilder> builder)

      Additional shipping addresses of the Cart as specified by LineItems using the shippingDetails field.

      For Carts with Single ShippingMode: eligible Shipping Methods or applicable Tax Rates are determined by the address in shippingAddress, and not itemShippingAddresses.

      Parameters:
      builder - function to build the itemShippingAddresses value
      Returns:
      Builder
    • addItemShippingAddresses

      public CartBuilder addItemShippingAddresses(Function<AddressBuilder,Address> builder)

      Additional shipping addresses of the Cart as specified by LineItems using the shippingDetails field.

      For Carts with Single ShippingMode: eligible Shipping Methods or applicable Tax Rates are determined by the address in shippingAddress, and not itemShippingAddresses.

      Parameters:
      builder - function to build the itemShippingAddresses value
      Returns:
      Builder
    • setItemShippingAddresses

      public CartBuilder setItemShippingAddresses(Function<AddressBuilder,Address> builder)

      Additional shipping addresses of the Cart as specified by LineItems using the shippingDetails field.

      For Carts with Single ShippingMode: eligible Shipping Methods or applicable Tax Rates are determined by the address in shippingAddress, and not itemShippingAddresses.

      Parameters:
      builder - function to build the itemShippingAddresses value
      Returns:
      Builder
    • discountCodes

      public CartBuilder discountCodes(DiscountCodeInfo... discountCodes)

      Discount Codes applied to the Cart. A Cart that has directDiscounts cannot have discountCodes.

      Parameters:
      discountCodes - value to be set
      Returns:
      Builder
    • discountCodes

      public CartBuilder discountCodes(List<DiscountCodeInfo> discountCodes)

      Discount Codes applied to the Cart. A Cart that has directDiscounts cannot have discountCodes.

      Parameters:
      discountCodes - value to be set
      Returns:
      Builder
    • plusDiscountCodes

      public CartBuilder plusDiscountCodes(DiscountCodeInfo... discountCodes)

      Discount Codes applied to the Cart. A Cart that has directDiscounts cannot have discountCodes.

      Parameters:
      discountCodes - value to be set
      Returns:
      Builder
    • plusDiscountCodes

      Discount Codes applied to the Cart. A Cart that has directDiscounts cannot have discountCodes.

      Parameters:
      builder - function to build the discountCodes value
      Returns:
      Builder
    • withDiscountCodes

      Discount Codes applied to the Cart. A Cart that has directDiscounts cannot have discountCodes.

      Parameters:
      builder - function to build the discountCodes value
      Returns:
      Builder
    • addDiscountCodes

      public CartBuilder addDiscountCodes(Function<DiscountCodeInfoBuilder,DiscountCodeInfo> builder)

      Discount Codes applied to the Cart. A Cart that has directDiscounts cannot have discountCodes.

      Parameters:
      builder - function to build the discountCodes value
      Returns:
      Builder
    • setDiscountCodes

      public CartBuilder setDiscountCodes(Function<DiscountCodeInfoBuilder,DiscountCodeInfo> builder)

      Discount Codes applied to the Cart. A Cart that has directDiscounts cannot have discountCodes.

      Parameters:
      builder - function to build the discountCodes value
      Returns:
      Builder
    • directDiscounts

      public CartBuilder directDiscounts(DirectDiscount... directDiscounts)

      Direct Discounts added to the Cart. A Cart that has discountCodes cannot have directDiscounts.

      Parameters:
      directDiscounts - value to be set
      Returns:
      Builder
    • directDiscounts

      public CartBuilder directDiscounts(List<DirectDiscount> directDiscounts)

      Direct Discounts added to the Cart. A Cart that has discountCodes cannot have directDiscounts.

      Parameters:
      directDiscounts - value to be set
      Returns:
      Builder
    • plusDirectDiscounts

      public CartBuilder plusDirectDiscounts(DirectDiscount... directDiscounts)

      Direct Discounts added to the Cart. A Cart that has discountCodes cannot have directDiscounts.

      Parameters:
      directDiscounts - value to be set
      Returns:
      Builder
    • plusDirectDiscounts

      public CartBuilder plusDirectDiscounts(Function<DirectDiscountBuilder,DirectDiscountBuilder> builder)

      Direct Discounts added to the Cart. A Cart that has discountCodes cannot have directDiscounts.

      Parameters:
      builder - function to build the directDiscounts value
      Returns:
      Builder
    • withDirectDiscounts

      public CartBuilder withDirectDiscounts(Function<DirectDiscountBuilder,DirectDiscountBuilder> builder)

      Direct Discounts added to the Cart. A Cart that has discountCodes cannot have directDiscounts.

      Parameters:
      builder - function to build the directDiscounts value
      Returns:
      Builder
    • addDirectDiscounts

      public CartBuilder addDirectDiscounts(Function<DirectDiscountBuilder,DirectDiscount> builder)

      Direct Discounts added to the Cart. A Cart that has discountCodes cannot have directDiscounts.

      Parameters:
      builder - function to build the directDiscounts value
      Returns:
      Builder
    • setDirectDiscounts

      public CartBuilder setDirectDiscounts(Function<DirectDiscountBuilder,DirectDiscount> builder)

      Direct Discounts added to the Cart. A Cart that has discountCodes cannot have directDiscounts.

      Parameters:
      builder - function to build the directDiscounts value
      Returns:
      Builder
    • refusedGifts

      public CartBuilder refusedGifts(CartDiscountReference... refusedGifts)

      Automatically set when a Line Item with GiftLineItem LineItemMode is removed from the Cart.

      Parameters:
      refusedGifts - value to be set
      Returns:
      Builder
    • refusedGifts

      public CartBuilder refusedGifts(List<CartDiscountReference> refusedGifts)

      Automatically set when a Line Item with GiftLineItem LineItemMode is removed from the Cart.

      Parameters:
      refusedGifts - value to be set
      Returns:
      Builder
    • plusRefusedGifts

      public CartBuilder plusRefusedGifts(CartDiscountReference... refusedGifts)

      Automatically set when a Line Item with GiftLineItem LineItemMode is removed from the Cart.

      Parameters:
      refusedGifts - value to be set
      Returns:
      Builder
    • plusRefusedGifts

      Automatically set when a Line Item with GiftLineItem LineItemMode is removed from the Cart.

      Parameters:
      builder - function to build the refusedGifts value
      Returns:
      Builder
    • withRefusedGifts

      Automatically set when a Line Item with GiftLineItem LineItemMode is removed from the Cart.

      Parameters:
      builder - function to build the refusedGifts value
      Returns:
      Builder
    • addRefusedGifts

      Automatically set when a Line Item with GiftLineItem LineItemMode is removed from the Cart.

      Parameters:
      builder - function to build the refusedGifts value
      Returns:
      Builder
    • setRefusedGifts

      Automatically set when a Line Item with GiftLineItem LineItemMode is removed from the Cart.

      Parameters:
      builder - function to build the refusedGifts value
      Returns:
      Builder
    • paymentInfo

      Payment information related to the Cart.

      Parameters:
      builder - function to build the paymentInfo value
      Returns:
      Builder
    • withPaymentInfo

      public CartBuilder withPaymentInfo(Function<PaymentInfoBuilder,PaymentInfo> builder)

      Payment information related to the Cart.

      Parameters:
      builder - function to build the paymentInfo value
      Returns:
      Builder
    • paymentInfo

      public CartBuilder paymentInfo(@Nullable PaymentInfo paymentInfo)

      Payment information related to the Cart.

      Parameters:
      paymentInfo - value to be set
      Returns:
      Builder
    • country

      public CartBuilder country(@Nullable String country)

      Used for Line Item price selection.

      Parameters:
      country - value to be set
      Returns:
      Builder
    • locale

      public CartBuilder locale(@Nullable String locale)

      Languages of the Cart. Can only contain languages supported by the Project.

      Parameters:
      locale - value to be set
      Returns:
      Builder
    • origin

      public CartBuilder origin(CartOrigin origin)

      Indicates how the Cart was created.

      Parameters:
      origin - value to be set
      Returns:
      Builder
    • custom

      Custom Fields of the Cart.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • withCustom

      public CartBuilder withCustom(Function<CustomFieldsBuilder,CustomFields> builder)

      Custom Fields of the Cart.

      Parameters:
      builder - function to build the custom value
      Returns:
      Builder
    • custom

      public CartBuilder custom(@Nullable CustomFields custom)

      Custom Fields of the Cart.

      Parameters:
      custom - value to be set
      Returns:
      Builder
    • deleteDaysAfterLastModification

      public CartBuilder deleteDaysAfterLastModification(@Nullable Integer deleteDaysAfterLastModification)

      Number of days after which an active Cart is deleted since its last modification. Configured in Project settings.

      Parameters:
      deleteDaysAfterLastModification - value to be set
      Returns:
      Builder
    • lastModifiedBy

      IDs and references that last modified the Cart.

      Parameters:
      builder - function to build the lastModifiedBy value
      Returns:
      Builder
    • withLastModifiedBy

      public CartBuilder withLastModifiedBy(Function<LastModifiedByBuilder,LastModifiedBy> builder)

      IDs and references that last modified the Cart.

      Parameters:
      builder - function to build the lastModifiedBy value
      Returns:
      Builder
    • lastModifiedBy

      public CartBuilder lastModifiedBy(@Nullable LastModifiedBy lastModifiedBy)

      IDs and references that last modified the Cart.

      Parameters:
      lastModifiedBy - value to be set
      Returns:
      Builder
    • createdBy

      IDs and references that created the Cart.

      Parameters:
      builder - function to build the createdBy value
      Returns:
      Builder
    • withCreatedBy

      public CartBuilder withCreatedBy(Function<CreatedByBuilder,CreatedBy> builder)

      IDs and references that created the Cart.

      Parameters:
      builder - function to build the createdBy value
      Returns:
      Builder
    • createdBy

      public CartBuilder createdBy(@Nullable CreatedBy createdBy)

      IDs and references that created the Cart.

      Parameters:
      createdBy - value to be set
      Returns:
      Builder
    • getId

      public String getId()

      Unique identifier of the Cart.

      Returns:
      id
    • getVersion

      public Long getVersion()

      Current version of the Cart.

      Returns:
      version
    • getCreatedAt

      public ZonedDateTime getCreatedAt()

      Date and time (UTC) the Cart was initially created.

      Returns:
      createdAt
    • getLastModifiedAt

      public ZonedDateTime getLastModifiedAt()

      Date and time (UTC) the Cart was last updated.

      Returns:
      lastModifiedAt
    • getKey

      @Nullable public String getKey()

      User-defined unique identifier of the Cart.

      Returns:
      key
    • getCustomerId

      @Nullable public String getCustomerId()

      id of the Customer that the Cart belongs to.

      Returns:
      customerId
    • getCustomerEmail

      @Nullable public String getCustomerEmail()

      Email address of the Customer that the Cart belongs to.

      Returns:
      customerEmail
    • getCustomerGroup

      @Nullable public CustomerGroupReference getCustomerGroup()

      Reference to the Customer Group of the Customer that the Cart belongs to. Used for Line Item price selection.

      Returns:
      customerGroup
    • getAnonymousId

      @Nullable public String getAnonymousId()

      Anonymous session associated with the Cart.

      Returns:
      anonymousId
    • getBusinessUnit

      @Nullable public BusinessUnitKeyReference getBusinessUnit()

      Reference to a Business Unit the Cart belongs to.

      Returns:
      businessUnit
    • getStore

      @Nullable public StoreKeyReference getStore()

      Reference to a Store the Cart belongs to.

      Returns:
      store
    • getLineItems

      public List<LineItem> getLineItems()

      Line Items added to the Cart.

      Returns:
      lineItems
    • getCustomLineItems

      public List<CustomLineItem> getCustomLineItems()

      Custom Line Items added to the Cart.

      Returns:
      customLineItems
    • getTotalLineItemQuantity

      @Nullable public Long getTotalLineItemQuantity()

      Sum of all LineItem quantities, excluding CustomLineItems. Only present when the Cart has at least one LineItem.

      Returns:
      totalLineItemQuantity
    • getTotalPrice

      public CentPrecisionMoney getTotalPrice()

      Sum of the totalPrice field of all LineItems and CustomLineItems, and if available, the price field of ShippingInfo. If a discount applies on totalPrice, this field holds the discounted value.

      Taxes are included if TaxRate includedInPrice is true for each price.

      Returns:
      totalPrice
    • getTaxedPrice

      @Nullable public TaxedPrice getTaxedPrice()
      • For a Cart with Platform TaxMode, it is automatically set when a shipping address is set. For Carts with Multiple ShippingMode, all Line Items and Custom Line Items must be fully distributed between the Shipping Methods (via shippingDetails), otherwise taxedPrice is not automatically set.
      • For a Cart with External TaxMode, it is automatically set when shippingAddress and external Tax Rates for all Line Items, Custom Line Items, and Shipping Methods in the Cart are set. For Carts with Multiple ShippingMode, all allocations must have their respective tax rates present in perMethodTaxRate, otherwise taxedPrice is not automatically set.

      If a discount applies on totalPrice, this field holds the discounted values.

      Returns:
      taxedPrice
    • getTaxedShippingPrice

      @Nullable public TaxedPrice getTaxedShippingPrice()

      Sum of the taxedPrice field of ShippingInfo across all Shipping Methods.

      Returns:
      taxedShippingPrice
    • getDiscountOnTotalPrice

      @Nullable public DiscountOnTotalPrice getDiscountOnTotalPrice()

      Discounts that apply on the Cart totalPrice.

      Returns:
      discountOnTotalPrice
    • getTaxMode

      public TaxMode getTaxMode()

      Indicates how Tax Rates are set.

      Returns:
      taxMode
    • getTaxRoundingMode

      public RoundingMode getTaxRoundingMode()

      Indicates how monetary values are rounded when calculating taxes for taxedPrice.

      Returns:
      taxRoundingMode
    • getTaxCalculationMode

      public TaxCalculationMode getTaxCalculationMode()

      Indicates how taxes are calculated when calculating taxes for taxedPrice.

      Returns:
      taxCalculationMode
    • getInventoryMode

      public InventoryMode getInventoryMode()

      Indicates how stock quantities are tracked for Line Items in the Cart.

      Returns:
      inventoryMode
    • getCartState

      public CartState getCartState()

      Current status of the Cart.

      Returns:
      cartState
    • getBillingAddress

      @Nullable public Address getBillingAddress()

      Billing address associated with the Cart.

      Returns:
      billingAddress
    • getShippingAddress

      @Nullable public Address getShippingAddress()

      Shipping address for a Cart with Single ShippingMode. Determines eligible ShippingMethod rates and Tax Rates of Line Items.

      Returns:
      shippingAddress
    • getShippingMode

      public ShippingMode getShippingMode()

      Indicates whether the Cart has one or multiple Shipping Methods.

      Returns:
      shippingMode
    • getShippingKey

      @Nullable public String getShippingKey()

      User-defined unique identifier of the Shipping Method in a Cart with Single ShippingMode.

      Returns:
      shippingKey
    • getShippingInfo

      @Nullable public ShippingInfo getShippingInfo()

      Shipping-related information of a Cart with Single ShippingMode. Automatically set when a Shipping Method is set.

      Returns:
      shippingInfo
    • getShippingRateInput

      @Nullable public ShippingRateInput getShippingRateInput()

      Input used to select a ShippingRatePriceTier. The data type of this field depends on the shippingRateInputType.type configured in the Project:

      • If CartClassification, it is ClassificationShippingRateInput.
      • If CartScore, it is ScoreShippingRateInput.
      • If CartValue, it cannot be used.
      Returns:
      shippingRateInput
    • getShippingCustomFields

      @Nullable public CustomFields getShippingCustomFields()

      Custom Fields of the Shipping Method in a Cart with Single ShippingMode.

      Returns:
      shippingCustomFields
    • getShipping

      public List<Shipping> getShipping()

      Shipping-related information of a Cart with Multiple ShippingMode. Updated automatically each time a new Shipping Method is added.

      Returns:
      shipping
    • getItemShippingAddresses

      public List<Address> getItemShippingAddresses()

      Additional shipping addresses of the Cart as specified by LineItems using the shippingDetails field.

      For Carts with Single ShippingMode: eligible Shipping Methods or applicable Tax Rates are determined by the address in shippingAddress, and not itemShippingAddresses.

      Returns:
      itemShippingAddresses
    • getDiscountCodes

      public List<DiscountCodeInfo> getDiscountCodes()

      Discount Codes applied to the Cart. A Cart that has directDiscounts cannot have discountCodes.

      Returns:
      discountCodes
    • getDirectDiscounts

      public List<DirectDiscount> getDirectDiscounts()

      Direct Discounts added to the Cart. A Cart that has discountCodes cannot have directDiscounts.

      Returns:
      directDiscounts
    • getRefusedGifts

      public List<CartDiscountReference> getRefusedGifts()

      Automatically set when a Line Item with GiftLineItem LineItemMode is removed from the Cart.

      Returns:
      refusedGifts
    • getPaymentInfo

      @Nullable public PaymentInfo getPaymentInfo()

      Payment information related to the Cart.

      Returns:
      paymentInfo
    • getCountry

      @Nullable public String getCountry()

      Used for Line Item price selection.

      Returns:
      country
    • getLocale

      @Nullable public String getLocale()

      Languages of the Cart. Can only contain languages supported by the Project.

      Returns:
      locale
    • getOrigin

      public CartOrigin getOrigin()

      Indicates how the Cart was created.

      Returns:
      origin
    • getCustom

      @Nullable public CustomFields getCustom()

      Custom Fields of the Cart.

      Returns:
      custom
    • getDeleteDaysAfterLastModification

      @Nullable public Integer getDeleteDaysAfterLastModification()

      Number of days after which an active Cart is deleted since its last modification. Configured in Project settings.

      Returns:
      deleteDaysAfterLastModification
    • getLastModifiedBy

      @Nullable public LastModifiedBy getLastModifiedBy()

      IDs and references that last modified the Cart.

      Returns:
      lastModifiedBy
    • getCreatedBy

      @Nullable public CreatedBy getCreatedBy()

      IDs and references that created the Cart.

      Returns:
      createdBy
    • build

      public Cart build()
      builds Cart with checking for non-null required values
      Specified by:
      build in interface Builder<Cart>
      Returns:
      Cart
    • buildUnchecked

      public Cart buildUnchecked()
      builds Cart without checking for non-null required values
      Returns:
      Cart
    • of

      public static CartBuilder of()
      factory method for an instance of CartBuilder
      Returns:
      builder
    • of

      public static CartBuilder of(Cart template)
      create builder for Cart instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder