Interface CartResolverService

All Known Implementing Classes:
DefaultCartResolverService

public interface CartResolverService
The interface used for resolving in-progress Carts.
Author:
Nick Crum (ncrum)
  • Method Summary

    Modifier and Type
    Method
    Description
     
    Optional<com.broadleafcommerce.cart.client.domain.Cart>
    resolveCartById(ResolveCartRequest resolveCartRequest, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Resolves a Cart given the ResolveCartRequest with the given cart id and data.
    Optional<com.broadleafcommerce.cart.client.domain.Cart>
    resolveCartById(String cartId, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Resolves a Cart given the cart ID, customer, and context.
    default Optional<com.broadleafcommerce.cart.client.domain.Cart>
    resolveCartByStatus(@NonNull String status, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Resolves the Cart with the matching status for the given customer and context.
    Optional<com.broadleafcommerce.cart.client.domain.Cart>
    resolveCartByStatus(@NonNull Collection<String> statuses, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Resolves the Cart with the first matching status for the given customer and context.
    com.broadleafcommerce.cart.client.domain.Cart
    resolveCartForStatusChange(String cartId, Integer cartVersion, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Similar to resolveCartForUpdate(String, Integer, CustomerRef, ContextInfo) except it will allow carts with status DefaultCartStatuses.REQUIRES_APPROVAL to have their statuses updated.
    com.broadleafcommerce.cart.client.domain.Cart
    resolveCartForUpdate(ResolveCartRequest resolveCartRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Resolves the cart with additional validation that it can be updated by checking the Cart.getVersion(), Cart.getStatus(), and sometimes the ResolveCartRequest.getWorkflow().
    default com.broadleafcommerce.cart.client.domain.Cart
    resolveCartForUpdate(String cartId, Integer cartVersion, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Resolves the cart with additional validation that it can be updated by checking the Cart.getVersion() and Cart.getStatus().
    default Optional<com.broadleafcommerce.cart.client.domain.Cart>
    resolveImplicitCart(com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Resolves the given CustomerRef's implicit/default cart, which out of the box means an DefaultCartStatuses.IN_PROCESS cart with null name.
    Optional<com.broadleafcommerce.cart.client.domain.Cart>
    resolveImplicitCart(com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, boolean allowRepriceDueToStaleCartPrices)
    Resolves the given CustomerRef's implicit/default cart, which out of the box means an DefaultCartStatuses.IN_PROCESS cart with null name.
    default Optional<com.broadleafcommerce.cart.client.domain.Cart>
    resolveInProcessCart(com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
  • Method Details

    • resolveCartById

      Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveCartById(String cartId, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves a Cart given the cart ID, customer, and context.

      If the provided CustomerRef is not registered, this will resolve a guest cart for the given ID and context. If the cart is found to be a customer cart, this will return as empty, because an anonymous customer can only access guest carts.

      If the provided CustomerRef is registered, this will resolve a customer cart for the given customer, ID, and context. If the cart is found to be a guest cart, this will return as empty.

      If no cart is found, this will return an empty optional.

      Parameters:
      cartId - the cart ID
      customer - the customer
      contextInfo - the context info
      Returns:
      an optional with a cart, or empty
    • resolveCartById

      Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveCartById(ResolveCartRequest resolveCartRequest, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves a Cart given the ResolveCartRequest with the given cart id and data.

      If the provided CustomerRef is not registered, this will resolve a guest cart for the given ID and context. If the cart is found to be a customer cart, this will return as empty, because an anonymous customer can only access guest carts.

      If the provided CustomerRef is registered, this will resolve a customer cart for the given customer, ID, and context. If the cart is found to be a guest cart, this will return as empty.

      If no cart is found, this will return an empty optional.

      Parameters:
      resolveCartRequest - the cart ID
      customer - the customer
      contextInfo - the context info
      Returns:
      an optional with a cart, or empty
    • resolveCartByStatus

      Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveCartByStatus(@NonNull @NonNull Collection<String> statuses, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves the Cart with the first matching status for the given customer and context.

      This method will iterate through each status, in given order, and attempt to retrieve a cart for that status. The first accessible cart retrieved for a status will be returned.

      If no cart is found, this will return an empty optional.

      Parameters:
      statuses - the statuses to check
      customer - the customer
      contextInfo - the context info
      Returns:
      an optional with a cart, or empty
    • resolveCartForStatusChange

      com.broadleafcommerce.cart.client.domain.Cart resolveCartForStatusChange(String cartId, @Nullable Integer cartVersion, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Similar to resolveCartForUpdate(String, Integer, CustomerRef, ContextInfo) except it will allow carts with status DefaultCartStatuses.REQUIRES_APPROVAL to have their statuses updated. This enables the original requester of the approval to reclaim their cart to make changes.
      Parameters:
      cartId - Id of the cart to resolve
      cartVersion - Cart version expected
      customer - Customer who owns the cart
      contextInfo - Additional sandbox and multitenant info
      Returns:
      The matching cart if it's updatable
      Throws:
      StaleCartException - when the version of the cart resolved is ahead of the cartVersion expected
    • resolveCartForUpdate

      default com.broadleafcommerce.cart.client.domain.Cart resolveCartForUpdate(String cartId, @Nullable Integer cartVersion, @Nullable com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves the cart with additional validation that it can be updated by checking the Cart.getVersion() and Cart.getStatus().
      Parameters:
      cartId - Id of the cart to resolve
      cartVersion - Cart version expected
      customer - Customer who owns the cart
      contextInfo - Additional sandbox and multitenant info
      Returns:
      The matching cart if it's updatable
      Throws:
      StaleCartException - when the version of the cart resolved is ahead of the cartVersion expected
      CartApprovalValidationException - when the cart cannot be updated because the customer is not an approver and the cart's status is DefaultCartStatuses.REQUIRES_APPROVAL.
      CartAwaitingPaymentFinalizationException - when the cart cannot be updated because it is awaiting payment finalization
    • resolveCartForUpdate

      com.broadleafcommerce.cart.client.domain.Cart resolveCartForUpdate(ResolveCartRequest resolveCartRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves the cart with additional validation that it can be updated by checking the Cart.getVersion(), Cart.getStatus(), and sometimes the ResolveCartRequest.getWorkflow().
      Parameters:
      resolveCartRequest - the ResolveCartRequest containing the details for the cart resolution
      contextInfo - Additional sandbox and multitenant info
      Returns:
      The matching cart if it's updatable
    • resolveCartByStatus

      default Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveCartByStatus(@NonNull @NonNull String status, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves the Cart with the matching status for the given customer and context.

      If no cart is found, this will return an empty optional.

      Parameters:
      status - the status to check
      customer - the customer
      contextInfo - the context info
      Returns:
      an optional with a cart, or empty
    • resolveInProcessCart

      @Deprecated default Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveInProcessCart(com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves the current in-progress Cart given the customer and context.

      If no cart is found, this will return an empty optional.

      Prior to 1.8.0, there's an expectation of having only one DefaultCartStatuses.IN_PROCESS cart per user. After 1.8.0, a user can have an unlimited amount of DefaultCartStatuses.IN_PROCESS carts, however a user can only have one implicit/default cart.

      Parameters:
      customer - the customer
      contextInfo - the context info
      Returns:
      an optional with a cart, or empty
    • getCartNotFoundMessage

      String getCartNotFoundMessage(String cartId)
    • resolveImplicitCart

      default Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveImplicitCart(com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Resolves the given CustomerRef's implicit/default cart, which out of the box means an DefaultCartStatuses.IN_PROCESS cart with null name. This method will always reprice the cart to avoid stale prices. To avoid repricing the cart, use resolveImplicitCart(CustomerRef, ContextInfo, boolean)
      Parameters:
      customer - the CustomerRef representing the currently authenticated user
      contextInfo - the context info
      Returns:
      an optional with a cart, or empty
    • resolveImplicitCart

      Optional<com.broadleafcommerce.cart.client.domain.Cart> resolveImplicitCart(com.broadleafcommerce.order.common.domain.CustomerRef customer, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, boolean allowRepriceDueToStaleCartPrices)
      Resolves the given CustomerRef's implicit/default cart, which out of the box means an DefaultCartStatuses.IN_PROCESS cart with null name. By default, shouldReprice is true since we want to reprice the cart. Only for the creation of a net new cart, it is set as false
      Parameters:
      customer - the CustomerRef representing the currently authenticated user
      contextInfo - the context info
      allowRepriceDueToStaleCartPrices - declares if repricing due to stale cart prices should be considered or skipped entirely
      Returns:
      an optional with a cart, or empty