java.lang.Object
com.broadleafcommerce.cart.client.domain.Cart
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware, com.broadleafcommerce.money.CurrencyConsumer, Serializable, javax.money.CurrencySupplier
Direct Known Subclasses:
CheckoutCart

public class Cart extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware, javax.money.CurrencySupplier, com.broadleafcommerce.money.CurrencyConsumer
Represents a customer facing shopping cart with items, pricing and fulfillment information.
Author:
Chad Harchar (charchar)
See Also:
  • Constructor Details

    • Cart

      public Cart()
  • Method Details

    • getQuantity

      public int getQuantity()
      Returns the sum of the quantities of all the cartItems.
      Returns:
      the sum of the quantities of all the cartItems.
    • isAnonymous

      public boolean isAnonymous()
      Returns whether or not the cart is for an anonymous user.
      Returns:
      whether or not the cart is for an anonymous user.
    • setCurrency

      public void setCurrency(javax.money.CurrencyUnit currencyUnit)
      Specified by:
      setCurrency in interface com.broadleafcommerce.money.CurrencyConsumer
    • getCurrency

      public javax.money.CurrencyUnit getCurrency()
      Specified by:
      getCurrency in interface javax.money.CurrencySupplier
    • getCartItemsWithDependentItems

      public List<CartItem> getCartItemsWithDependentItems()
    • getRecurringSubtotals

      public Map<String,javax.money.MonetaryAmount> getRecurringSubtotals()
      The estimated recurring subtotal for the first period discounted for all items grouped by their recurring period type.
      Since:
      Cart Client 2.0.4
    • getRecurringAdjustmentsTotals

      public Map<String,javax.money.MonetaryAmount> getRecurringAdjustmentsTotals()
      The estimated recurring adjustments total for the first period discounted for all items grouped by their recurring period type.
      Since:
      Cart Client 2.0.4
    • getRecurringTotals

      public Map<String,javax.money.MonetaryAmount> getRecurringTotals()
      The estimated recurring total for the first period discounted for all items grouped by their recurring period type.
      Since:
      Cart Client 2.0.4
    • getId

      public String getId()
      The context ID of the cart.
      Returns:
      the context ID of the cart
    • getName

      public String getName()
      A unique name for the cart, used for retrieval. This field is not displayed anywhere.
      Returns:
      a unique name for the cart, used for retrieval
    • getType

      public String getType()
      The type of cart.
      See Also:
    • getStatus

      public String getStatus()
      The status of this cart.
      Returns:
      The status of this cart.
      See Also:
    • getCustomerRef

      public com.broadleafcommerce.order.common.domain.CustomerRef getCustomerRef()
      A reference to the customer that owns this cart.
      Returns:
      A reference to the customer that owns this cart.
    • getApprovalRequestedDate

      public Instant getApprovalRequestedDate()
      The time this cart was submitted for approval.

      This field is only needed for B2B carts to represent the cart approval process. For B2C carts, we don't expect a value to be provided for this field.

    • getApproverEmail

      public String getApproverEmail()
      The cart approver's email address.

      This field is only needed for B2B carts to represent the cart approver's email address. For B2C carts, we don't expect a value to be provided for this field.

      Returns:
      The cart approver's email address.
    • getEmailAddress

      public String getEmailAddress()
      The customer's email address.
      Returns:
      The customer's email address.
    • getOrderNumber

      public String getOrderNumber()
      The unique number associated with this Cart. Typically, this is generated and set on cart submission. Used for record keeping and communicating with the customer instead of just using getId() since that exposes unwanted information about your database.
      Returns:
      The unique number associated with this Cart.
    • getCreateDate

      public Instant getCreateDate()
      The date that this cart was first created.
      Returns:
      The date that this cart was first created.
    • getSubmitDate

      public Instant getSubmitDate()
      The date that this cart was submitted. Only set if the cart status is DefaultCartStatuses.SUBMITTED, otherwise null.
      Returns:
      The date that this cart was submitted.
      See Also:
    • getLocale

      public Locale getLocale()
      The locale for this cart. Used to determine what locale this cart was in for translations and other location-based functionality.
      Returns:
      The locale code for this cart.
    • getCartPricing

      public CartPricing getCartPricing()
      Embedded container for all pricing information on this cart.
      Returns:
      Embedded container for all pricing information on this cart.
    • getCartItems

      public List<CartItem> getCartItems()
      Items that are contained within this cart. Typically represents a good or service that the customer is purchasing.
      Returns:
      Items for purchase that are contained within this cart.
    • getFulfillmentGroups

      public List<FulfillmentGroup> getFulfillmentGroups()
      A list of fulfillment information for this cart. A cart can have many fulfillment groups associated with it in order to support multi-address and multi-type shipping.
      Returns:
      A list of fulfillment information for this cart.
    • getAdjustments

      public List<com.broadleafcommerce.order.common.domain.Adjustment> getAdjustments()
      Adjustments to order pricing that should be applied to CartPricing.getSubtotal().
      Returns:
      Adjustments to order pricing that should be applied to CartPricing.getSubtotal().
    • getOfferCodes

      public List<String> getOfferCodes()
      A list of offer codes that a user has added to their cart. Can be used to apply Adjustments to different aspects of the order.
      Returns:
      A list of offer codes that a user has added to their cart.
    • getVouchers

      public List<com.broadleafcommerce.order.common.domain.Voucher> getVouchers()
      A list of Vouchers that this Cart is qualifier for.

      This mainly serves as a temporary storage and for UI display, the Vouchers will not be processed until the order is completed.

    • getCampaignRefs

      public List<com.broadleafcommerce.order.common.domain.CampaignRef> getCampaignRefs()
      A list of campaign references that are attached to this cart. Similar to getOfferCodes(), the CampaignRef.getCampaignTrackingId() can be used to apply Adjustments to different aspects of the order. The difference is that these items need to be validated against a valid "Campaign" before being added to this list.
      Returns:
      A list of campaign references that are attached to this cart.
    • getAssignedSalesRepId

      public String getAssignedSalesRepId()
      The id of the assigned sales rep.

      This is field is only used for quotes for the sales rep review process.

    • getAssignedSalesRepEmail

      public String getAssignedSalesRepEmail()
      The email of the assigned sales rep.

      This is field is only used for quotes for the sales rep review process.

    • getAttributes

      public Map<String,Object> getAttributes()
      Miscellaneous attributes for this cart.
      Returns:
      Miscellaneous attributes for this cart.
    • getInternalAttributes

      public Map<String,Object> getInternalAttributes()
      Miscellaneous internal attributes for this item. Distinguished from getAttributes() in that this map is used for attributes that assist in the internal working of Broadleaf MicroServices. For example, attributes to help with processing the cart's checkout.
      Returns:
      Miscellaneous internal attributes for this item.
    • getAttributeChoices

      public Map<String,com.broadleafcommerce.order.common.domain.AttributeChoiceValue> getAttributeChoices()
      Attribute choices for this cart driven by its items' product options, where each key is the attributeName from an attribute choice.
      Returns:
      Attribute choices for this cart driven by its items' product options, where each key is the attributeName from an attribute choice.
    • getCheckoutSubmissions

      public Map<String,Instant> getCheckoutSubmissions()
      The checkout submissions made for this cart where each key is the request ID of a checkout and the value is an Instant timestamp of when the checkout was made.
      Returns:
      The checkout submissions made for this cart where each key is the request ID and the value is an Instant timestamp of when the checkout was made.
    • isPriced

      public boolean isPriced()
      Flag to indicate whether this cart has been fully priced. This means totalling of items, adjustments, shipping and tax.
      Returns:
      Flag to indicate whether this cart has been fully priced.
    • isTaxEstimated

      public boolean isTaxEstimated()
      Flag to indicate whether the taxes on the cart are estimates.
      Returns:
      Flag to indicate whether the taxes on the cart are estimates.
    • getVersion

      public Integer getVersion()
      The version of this cart. Used for checking that the requested version of the cart is up-to-date before saving changes. Required for any request which results in an update being made to the cart. This should never be manually incremented/decremented.
    • getCartAlerts

      public List<CartAlert> getCartAlerts()
      The list of the alerts for this Cart. NOTE: This is a transient property that is not persisted in the database.
      Returns:
      the list of the cart alerts
    • getLastCatalogReprice

      public Instant getLastCatalogReprice()
      The last time the cart was fully repriced with the most updated catalog pricing.
      Returns:
      The last time the cart was fully repriced with the most updated catalog pricing.
    • getExpirationDate

      public Instant getExpirationDate()
      The expiration date of the cart. This is typically only used for DefaultCartTypes.QUOTE-typed carts.
    • getLastUpdatedAudit

      public CartActionAudit getLastUpdatedAudit()
      The id of this cart's most recent audit.
    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • setId

      public void setId(String id)
      The context ID of the cart.
      Parameters:
      id - the context ID of the cart
    • setName

      public void setName(String name)
      A unique name for the cart, used for retrieval. This field is not displayed anywhere.
      Parameters:
      name - a unique name for the cart, used for retrieval
    • setType

      public void setType(String type)
      The type of cart.
      See Also:
    • setStatus

      public void setStatus(String status)
      The status of this cart.
      Parameters:
      status - The status of this cart.
      See Also:
    • setCustomerRef

      public void setCustomerRef(com.broadleafcommerce.order.common.domain.CustomerRef customerRef)
      A reference to the customer that owns this cart.
      Parameters:
      customerRef - A reference to the customer that owns this cart.
    • setApprovalRequestedDate

      public void setApprovalRequestedDate(Instant approvalRequestedDate)
      The time this cart was submitted for approval.

      This field is only needed for B2B carts to represent the cart approval process. For B2C carts, we don't expect a value to be provided for this field.

    • setApproverEmail

      public void setApproverEmail(String approverEmail)
      The cart approver's email address.

      This field is only needed for B2B carts to represent the cart approver's email address. For B2C carts, we don't expect a value to be provided for this field.

      Parameters:
      approverEmail - The cart approver's email address.
    • setEmailAddress

      public void setEmailAddress(String emailAddress)
      The customer's email address.
      Parameters:
      emailAddress - The customer's email address.
    • setOrderNumber

      public void setOrderNumber(String orderNumber)
      The unique number associated with this Cart. Typically, this is generated and set on cart submission. Used for record keeping and communicating with the customer instead of just using getId() since that exposes unwanted information about your database.
      Parameters:
      orderNumber - The unique number associated with this Cart.
    • setCreateDate

      public void setCreateDate(Instant createDate)
      The date that this cart was first created.
      Parameters:
      createDate - The date that this cart was first created.
    • setSubmitDate

      public void setSubmitDate(Instant submitDate)
      The date that this cart was submitted. Only set if the cart status is DefaultCartStatuses.SUBMITTED, otherwise null.
      Parameters:
      submitDate - The date that this cart was submitted.
      See Also:
    • setLocale

      public void setLocale(Locale locale)
      The locale for this cart. Used to determine what locale this cart was in for translations and other location-based functionality.
      Parameters:
      locale - The locale code for this cart.
    • setCartPricing

      public void setCartPricing(CartPricing cartPricing)
      Embedded container for all pricing information on this cart.
      Parameters:
      cartPricing - Embedded container for all pricing information on this cart.
    • setCartItems

      public void setCartItems(List<CartItem> cartItems)
      Items that are contained within this cart. Typically represents a good or service that the customer is purchasing.
      Parameters:
      cartItems - Items for purchase that are contained within this cart.
    • setFulfillmentGroups

      public void setFulfillmentGroups(List<FulfillmentGroup> fulfillmentGroups)
      A list of fulfillment information for this cart. A cart can have many fulfillment groups associated with it in order to support multi-address and multi-type shipping.
      Parameters:
      fulfillmentGroups - A list of fulfillment information for this cart.
    • setAdjustments

      public void setAdjustments(List<com.broadleafcommerce.order.common.domain.Adjustment> adjustments)
      Adjustments to order pricing that should be applied to CartPricing.getSubtotal().
      Parameters:
      adjustments - Adjustments to order pricing that should be applied to CartPricing.getSubtotal().
    • setOfferCodes

      public void setOfferCodes(List<String> offerCodes)
      A list of offer codes that a user has added to their cart. Can be used to apply Adjustments to different aspects of the order.
      Parameters:
      offerCodes - A list of offer codes that a user has added to their cart.
    • setVouchers

      public void setVouchers(List<com.broadleafcommerce.order.common.domain.Voucher> vouchers)
      A list of Vouchers that this Cart is qualifier for.

      This mainly serves as a temporary storage and for UI display, the Vouchers will not be processed until the order is completed.

    • setCampaignRefs

      public void setCampaignRefs(List<com.broadleafcommerce.order.common.domain.CampaignRef> campaignRefs)
      A list of campaign references that are attached to this cart. Similar to getOfferCodes(), the CampaignRef.getCampaignTrackingId() can be used to apply Adjustments to different aspects of the order. The difference is that these items need to be validated against a valid "Campaign" before being added to this list.
      Parameters:
      campaignRefs - A list of campaign references that are attached to this cart.
    • setAssignedSalesRepId

      public void setAssignedSalesRepId(String assignedSalesRepId)
      The id of the assigned sales rep.

      This is field is only used for quotes for the sales rep review process.

    • setAssignedSalesRepEmail

      public void setAssignedSalesRepEmail(String assignedSalesRepEmail)
      The email of the assigned sales rep.

      This is field is only used for quotes for the sales rep review process.

    • setAttributes

      public void setAttributes(Map<String,Object> attributes)
      Miscellaneous attributes for this cart.
      Parameters:
      attributes - Miscellaneous attributes for this cart.
    • setInternalAttributes

      public void setInternalAttributes(Map<String,Object> internalAttributes)
      Miscellaneous internal attributes for this item. Distinguished from getAttributes() in that this map is used for attributes that assist in the internal working of Broadleaf MicroServices. For example, attributes to help with processing the cart's checkout.
      Parameters:
      internalAttributes - Miscellaneous internal attributes for this item.
    • setAttributeChoices

      public void setAttributeChoices(Map<String,com.broadleafcommerce.order.common.domain.AttributeChoiceValue> attributeChoices)
      Attribute choices for this cart driven by its items' product options, where each key is the attributeName from an attribute choice.
      Parameters:
      attributeChoices - Attribute choices for this cart driven by its items' product options, where each key is the attributeName from an attribute choice.
    • setCheckoutSubmissions

      public void setCheckoutSubmissions(Map<String,Instant> checkoutSubmissions)
      The checkout submissions made for this cart where each key is the request ID of a checkout and the value is an Instant timestamp of when the checkout was made.
      Parameters:
      checkoutSubmissions - The checkout submissions made for this cart where each key is the request ID of a checkout and the value is an Instant timestamp of when the checkout was made.
    • setPriced

      public void setPriced(boolean isPriced)
      Flag to indicate whether this cart has been fully priced. This means totalling of items, adjustments, shipping and tax.
      Parameters:
      isPriced - Flag to indicate whether this cart has been fully priced.
    • setTaxEstimated

      public void setTaxEstimated(boolean isTaxEstimated)
      Flag to indicate whether the taxes on the cart are estimates.
      Parameters:
      isTaxEstimated - Flag to indicate whether the taxes on the cart are estimates.
    • setVersion

      public void setVersion(Integer version)
      The version of this cart. Used for checking that the requested version of the cart is up-to-date before saving changes. Required for any request which results in an update being made to the cart. This should never be manually incremented/decremented.
    • setCartAlerts

      public void setCartAlerts(List<CartAlert> cartAlerts)
      The list of the alerts for this Cart. NOTE: This is a transient property that is not persisted in the database.
      Parameters:
      cartAlerts - the list of the cart alerts
    • setLastCatalogReprice

      public void setLastCatalogReprice(Instant lastCatalogReprice)
      The last time the cart was fully repriced with the most updated catalog pricing.
      Parameters:
      lastCatalogReprice - The last time the cart was fully repriced with the most updated catalog pricing.
    • setExpirationDate

      public void setExpirationDate(Instant expirationDate)
      The expiration date of the cart. This is typically only used for DefaultCartTypes.QUOTE-typed carts.
    • setLastUpdatedAudit

      public void setLastUpdatedAudit(CartActionAudit lastUpdatedAudit)
      The id of this cart's most recent audit.
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object