Interface Cart

All Superinterfaces:
BaseResource, CartMixin, Customizable<Cart>, DomainResource<Cart>, Identifiable<Cart>, OrderLike<Cart>, Referencable<Cart>, ResourceIdentifiable<Cart>, Versioned<Cart>, WithKey

Cart
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()
 
  • Method Details

    • getId

      @NotNull @NotNull String getId()

      Unique identifier of the Cart.

      Specified by:
      getId in interface BaseResource
      Specified by:
      getId in interface DomainResource<Cart>
      Specified by:
      getId in interface Identifiable<Cart>
      Specified by:
      getId in interface OrderLike<Cart>
      Specified by:
      getId in interface Versioned<Cart>
      Returns:
      id
    • getVersion

      @NotNull @NotNull Long getVersion()

      Current version of the Cart.

      Specified by:
      getVersion in interface BaseResource
      Specified by:
      getVersion in interface DomainResource<Cart>
      Specified by:
      getVersion in interface OrderLike<Cart>
      Specified by:
      getVersion in interface Versioned<Cart>
      Returns:
      version
    • getKey

      String getKey()

      User-defined unique identifier of the Cart.

      Specified by:
      getKey in interface WithKey
      Returns:
      key
    • getCustomerId

      String getCustomerId()

      id of the Customer that the Cart belongs to.

      Specified by:
      getCustomerId in interface OrderLike<Cart>
      Returns:
      customerId
    • getCustomerEmail

      String getCustomerEmail()

      Email address of the Customer that the Cart belongs to.

      Specified by:
      getCustomerEmail in interface OrderLike<Cart>
      Returns:
      customerEmail
    • getCustomerGroup

      @Valid @Valid CustomerGroupReference getCustomerGroup()

      Reference to the Customer Group of the Customer that the Cart belongs to. Used for LineItem Price selection.

      Specified by:
      getCustomerGroup in interface OrderLike<Cart>
      Returns:
      customerGroup
    • getAnonymousId

      String getAnonymousId()

      Anonymous session associated with the Cart.

      Specified by:
      getAnonymousId in interface OrderLike<Cart>
      Returns:
      anonymousId
    • getBusinessUnit

      @Valid @Valid BusinessUnitKeyReference getBusinessUnit()

      Reference to a Business Unit the Cart belongs to.

      Returns:
      businessUnit
    • getStore

      @Valid @Valid StoreKeyReference getStore()

      Reference to a Store the Cart belongs to.

      Specified by:
      getStore in interface OrderLike<Cart>
      Returns:
      store
    • getLineItems

      @NotNull @Valid @NotNull @Valid List<LineItem> getLineItems()

      Line Items added to the Cart.

      Specified by:
      getLineItems in interface OrderLike<Cart>
      Returns:
      lineItems
    • getCustomLineItems

      @NotNull @Valid @NotNull @Valid List<CustomLineItem> getCustomLineItems()

      Custom Line Items added to the Cart.

      Specified by:
      getCustomLineItems in interface OrderLike<Cart>
      Returns:
      customLineItems
    • getTotalLineItemQuantity

      Long getTotalLineItemQuantity()

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

      Returns:
      totalLineItemQuantity
    • getTotalPrice

      @NotNull @Valid @NotNull @Valid 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.

      Specified by:
      getTotalPrice in interface OrderLike<Cart>
      Returns:
      totalPrice
    • getTaxedPrice

      @Valid @Valid TaxedPrice getTaxedPrice()
      • For a Cart with Platform TaxMode, it is automatically set when a shipping address is 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.

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

      Specified by:
      getTaxedPrice in interface OrderLike<Cart>
      Returns:
      taxedPrice
    • getTaxedShippingPrice

      @Valid @Valid TaxedPrice getTaxedShippingPrice()

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

      Returns:
      taxedShippingPrice
    • getDiscountOnTotalPrice

      @Valid @Valid DiscountOnTotalPrice getDiscountOnTotalPrice()

      Discounts that apply on the Cart totalPrice.

      Returns:
      discountOnTotalPrice
    • getTaxMode

      @NotNull @NotNull TaxMode getTaxMode()

      Indicates how Tax Rates are set.

      Specified by:
      getTaxMode in interface OrderLike<Cart>
      Returns:
      taxMode
    • getTaxRoundingMode

      @NotNull @NotNull RoundingMode getTaxRoundingMode()

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

      Specified by:
      getTaxRoundingMode in interface OrderLike<Cart>
      Returns:
      taxRoundingMode
    • getTaxCalculationMode

      @NotNull @NotNull TaxCalculationMode getTaxCalculationMode()

      Indicates how taxes are calculated when calculating taxes for taxedPrice.

      Specified by:
      getTaxCalculationMode in interface OrderLike<Cart>
      Returns:
      taxCalculationMode
    • getInventoryMode

      @NotNull @NotNull InventoryMode getInventoryMode()

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

      Specified by:
      getInventoryMode in interface OrderLike<Cart>
      Returns:
      inventoryMode
    • getCartState

      @NotNull @NotNull CartState getCartState()

      Current status of the Cart.

      Returns:
      cartState
    • getBillingAddress

      @Valid @Valid Address getBillingAddress()

      Billing address associated with the Cart.

      Specified by:
      getBillingAddress in interface OrderLike<Cart>
      Returns:
      billingAddress
    • getShippingAddress

      @Valid @Valid Address getShippingAddress()

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

      Specified by:
      getShippingAddress in interface OrderLike<Cart>
      Returns:
      shippingAddress
    • getShippingMode

      @NotNull @NotNull ShippingMode getShippingMode()

      Indicates whether the Cart has one or multiple Shipping Methods.

      Returns:
      shippingMode
    • getShippingKey

      String getShippingKey()

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

      Returns:
      shippingKey
    • getShippingInfo

      @Valid @Valid ShippingInfo getShippingInfo()

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

      Specified by:
      getShippingInfo in interface OrderLike<Cart>
      Returns:
      shippingInfo
    • getShippingRateInput

      @Valid @Valid 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.
      Specified by:
      getShippingRateInput in interface OrderLike<Cart>
      Returns:
      shippingRateInput
    • getShippingCustomFields

      @Valid @Valid CustomFields getShippingCustomFields()

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

      Specified by:
      getShippingCustomFields in interface OrderLike<Cart>
      Returns:
      shippingCustomFields
    • getShipping

      @NotNull @Valid @NotNull @Valid 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

      @NotNull @Valid @NotNull @Valid 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.

      Specified by:
      getItemShippingAddresses in interface OrderLike<Cart>
      Returns:
      itemShippingAddresses
    • getDiscountCodes

      @NotNull @Valid @NotNull @Valid List<DiscountCodeInfo> getDiscountCodes()

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

      Specified by:
      getDiscountCodes in interface OrderLike<Cart>
      Returns:
      discountCodes
    • getDirectDiscounts

      @NotNull @Valid @NotNull @Valid List<DirectDiscount> getDirectDiscounts()

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

      Returns:
      directDiscounts
    • getRefusedGifts

      @NotNull @Valid @NotNull @Valid List<CartDiscountReference> getRefusedGifts()

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

      Specified by:
      getRefusedGifts in interface OrderLike<Cart>
      Returns:
      refusedGifts
    • getPaymentInfo

      @Valid @Valid PaymentInfo getPaymentInfo()

      Payment information related to the Cart.

      Specified by:
      getPaymentInfo in interface OrderLike<Cart>
      Returns:
      paymentInfo
    • getCountry

      String getCountry()

      Used for LineItem Price selection.

      Specified by:
      getCountry in interface OrderLike<Cart>
      Returns:
      country
    • getLocale

      String getLocale()

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

      Specified by:
      getLocale in interface OrderLike<Cart>
      Returns:
      locale
    • getOrigin

      @NotNull @NotNull CartOrigin getOrigin()

      Indicates how the Cart was created.

      Specified by:
      getOrigin in interface OrderLike<Cart>
      Returns:
      origin
    • getCustom

      @Valid @Valid CustomFields getCustom()

      Custom Fields of the Cart.

      Specified by:
      getCustom in interface Customizable<Cart>
      Specified by:
      getCustom in interface OrderLike<Cart>
      Returns:
      custom
    • getDeleteDaysAfterLastModification

      Integer getDeleteDaysAfterLastModification()

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

      Returns:
      deleteDaysAfterLastModification
    • getCreatedAt

      @NotNull @NotNull ZonedDateTime getCreatedAt()

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

      Specified by:
      getCreatedAt in interface BaseResource
      Specified by:
      getCreatedAt in interface OrderLike<Cart>
      Returns:
      createdAt
    • getLastModifiedAt

      @NotNull @NotNull ZonedDateTime getLastModifiedAt()

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

      Specified by:
      getLastModifiedAt in interface BaseResource
      Specified by:
      getLastModifiedAt in interface OrderLike<Cart>
      Returns:
      lastModifiedAt
    • getLastModifiedBy

      @Valid @Valid LastModifiedBy getLastModifiedBy()

      Present on resources updated after 1 February 2019 except for events not tracked.

      Specified by:
      getLastModifiedBy in interface OrderLike<Cart>
      Returns:
      lastModifiedBy
    • getCreatedBy

      @Valid @Valid CreatedBy getCreatedBy()

      Present on resources created after 1 February 2019 except for events not tracked.

      Specified by:
      getCreatedBy in interface OrderLike<Cart>
      Returns:
      createdBy
    • setId

      void setId(String id)

      Unique identifier of the Cart.

      Specified by:
      setId in interface BaseResource
      Parameters:
      id - value to be set
    • setVersion

      void setVersion(Long version)

      Current version of the Cart.

      Specified by:
      setVersion in interface BaseResource
      Parameters:
      version - value to be set
    • setKey

      void setKey(String key)

      User-defined unique identifier of the Cart.

      Parameters:
      key - value to be set
    • setCustomerId

      void setCustomerId(String customerId)

      id of the Customer that the Cart belongs to.

      Parameters:
      customerId - value to be set
    • setCustomerEmail

      void setCustomerEmail(String customerEmail)

      Email address of the Customer that the Cart belongs to.

      Parameters:
      customerEmail - value to be set
    • setCustomerGroup

      void setCustomerGroup(CustomerGroupReference customerGroup)

      Reference to the Customer Group of the Customer that the Cart belongs to. Used for LineItem Price selection.

      Parameters:
      customerGroup - value to be set
    • setAnonymousId

      void setAnonymousId(String anonymousId)

      Anonymous session associated with the Cart.

      Parameters:
      anonymousId - value to be set
    • setBusinessUnit

      void setBusinessUnit(BusinessUnitKeyReference businessUnit)

      Reference to a Business Unit the Cart belongs to.

      Parameters:
      businessUnit - value to be set
    • setStore

      void setStore(StoreKeyReference store)

      Reference to a Store the Cart belongs to.

      Parameters:
      store - value to be set
    • setLineItems

      void setLineItems(LineItem... lineItems)

      Line Items added to the Cart.

      Parameters:
      lineItems - values to be set
    • setLineItems

      void setLineItems(List<LineItem> lineItems)

      Line Items added to the Cart.

      Parameters:
      lineItems - values to be set
    • setCustomLineItems

      void setCustomLineItems(CustomLineItem... customLineItems)

      Custom Line Items added to the Cart.

      Parameters:
      customLineItems - values to be set
    • setCustomLineItems

      void setCustomLineItems(List<CustomLineItem> customLineItems)

      Custom Line Items added to the Cart.

      Parameters:
      customLineItems - values to be set
    • setTotalLineItemQuantity

      void setTotalLineItemQuantity(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
    • setTotalPrice

      void setTotalPrice(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
    • setTaxedPrice

      void setTaxedPrice(TaxedPrice taxedPrice)
      • For a Cart with Platform TaxMode, it is automatically set when a shipping address is 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.

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

      Parameters:
      taxedPrice - value to be set
    • setTaxedShippingPrice

      void setTaxedShippingPrice(TaxedPrice taxedShippingPrice)

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

      Parameters:
      taxedShippingPrice - value to be set
    • setDiscountOnTotalPrice

      void setDiscountOnTotalPrice(DiscountOnTotalPrice discountOnTotalPrice)

      Discounts that apply on the Cart totalPrice.

      Parameters:
      discountOnTotalPrice - value to be set
    • setTaxMode

      void setTaxMode(TaxMode taxMode)

      Indicates how Tax Rates are set.

      Parameters:
      taxMode - value to be set
    • setTaxRoundingMode

      void setTaxRoundingMode(RoundingMode taxRoundingMode)

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

      Parameters:
      taxRoundingMode - value to be set
    • setTaxCalculationMode

      void setTaxCalculationMode(TaxCalculationMode taxCalculationMode)

      Indicates how taxes are calculated when calculating taxes for taxedPrice.

      Parameters:
      taxCalculationMode - value to be set
    • setInventoryMode

      void setInventoryMode(InventoryMode inventoryMode)

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

      Parameters:
      inventoryMode - value to be set
    • setCartState

      void setCartState(CartState cartState)

      Current status of the Cart.

      Parameters:
      cartState - value to be set
    • setBillingAddress

      void setBillingAddress(Address billingAddress)

      Billing address associated with the Cart.

      Parameters:
      billingAddress - value to be set
    • setShippingAddress

      void setShippingAddress(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
    • setShippingMode

      void setShippingMode(ShippingMode shippingMode)

      Indicates whether the Cart has one or multiple Shipping Methods.

      Parameters:
      shippingMode - value to be set
    • setShippingKey

      void setShippingKey(String shippingKey)

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

      Parameters:
      shippingKey - value to be set
    • setShippingInfo

      void setShippingInfo(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
    • setShippingRateInput

      void setShippingRateInput(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
    • setShippingCustomFields

      void setShippingCustomFields(CustomFields shippingCustomFields)

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

      Parameters:
      shippingCustomFields - value to be set
    • setShipping

      void setShipping(Shipping... shipping)

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

      Parameters:
      shipping - values to be set
    • setShipping

      void setShipping(List<Shipping> shipping)

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

      Parameters:
      shipping - values to be set
    • setItemShippingAddresses

      void setItemShippingAddresses(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 - values to be set
    • setItemShippingAddresses

      void setItemShippingAddresses(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 - values to be set
    • setDiscountCodes

      void setDiscountCodes(DiscountCodeInfo... discountCodes)

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

      Parameters:
      discountCodes - values to be set
    • setDiscountCodes

      void setDiscountCodes(List<DiscountCodeInfo> discountCodes)

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

      Parameters:
      discountCodes - values to be set
    • setDirectDiscounts

      void setDirectDiscounts(DirectDiscount... directDiscounts)

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

      Parameters:
      directDiscounts - values to be set
    • setDirectDiscounts

      void setDirectDiscounts(List<DirectDiscount> directDiscounts)

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

      Parameters:
      directDiscounts - values to be set
    • setRefusedGifts

      void setRefusedGifts(CartDiscountReference... refusedGifts)

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

      Parameters:
      refusedGifts - values to be set
    • setRefusedGifts

      void setRefusedGifts(List<CartDiscountReference> refusedGifts)

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

      Parameters:
      refusedGifts - values to be set
    • setPaymentInfo

      void setPaymentInfo(PaymentInfo paymentInfo)

      Payment information related to the Cart.

      Parameters:
      paymentInfo - value to be set
    • setCountry

      void setCountry(String country)

      Used for LineItem Price selection.

      Parameters:
      country - value to be set
    • setLocale

      void setLocale(String locale)

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

      Parameters:
      locale - value to be set
    • setOrigin

      void setOrigin(CartOrigin origin)

      Indicates how the Cart was created.

      Parameters:
      origin - value to be set
    • setCustom

      void setCustom(CustomFields custom)

      Custom Fields of the Cart.

      Specified by:
      setCustom in interface Customizable<Cart>
      Parameters:
      custom - value to be set
    • setDeleteDaysAfterLastModification

      void setDeleteDaysAfterLastModification(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
    • setCreatedAt

      void setCreatedAt(ZonedDateTime createdAt)

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

      Specified by:
      setCreatedAt in interface BaseResource
      Parameters:
      createdAt - value to be set
    • setLastModifiedAt

      void setLastModifiedAt(ZonedDateTime lastModifiedAt)

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

      Specified by:
      setLastModifiedAt in interface BaseResource
      Parameters:
      lastModifiedAt - value to be set
    • setLastModifiedBy

      void setLastModifiedBy(LastModifiedBy lastModifiedBy)

      Present on resources updated after 1 February 2019 except for events not tracked.

      Parameters:
      lastModifiedBy - value to be set
    • setCreatedBy

      void setCreatedBy(CreatedBy createdBy)

      Present on resources created after 1 February 2019 except for events not tracked.

      Parameters:
      createdBy - value to be set
    • of

      static Cart of()
      factory method
      Returns:
      instance of Cart
    • of

      static Cart of(Cart template)
      factory method to create a shallow copy Cart
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • deepCopy

      @Nullable static Cart deepCopy(@Nullable Cart template)
      factory method to create a deep copy of Cart
      Parameters:
      template - instance to be copied
      Returns:
      copy instance
    • builder

      static CartBuilder builder()
      builder factory method for Cart
      Returns:
      builder
    • builder

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

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