Interface CartResolverService
- All Known Implementing Classes:
DefaultCartResolverService
Carts
.- Author:
- Nick Crum (ncrum)
-
Method Summary
Modifier and TypeMethodDescriptiongetCartNotFoundMessage
(String cartId) 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 aCart
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 theCart
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 theCart
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 toresolveCartForUpdate(String, Integer, CustomerRef, ContextInfo)
except it will allow carts with statusDefaultCartStatuses.REQUIRES_APPROVAL
to have their statuses updated.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 theCart.getVersion()
andCart.getStatus()
.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 givenCustomerRef
's implicit/default cart, which out of the box means anDefaultCartStatuses.IN_PROCESS
cart withnull
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) Deprecated, for removal: This API element is subject to removal in a future version.
-
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 aCart
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 IDcustomer
- the customercontextInfo
- 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 theCart
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 checkcustomer
- the customercontextInfo
- 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 toresolveCartForUpdate(String, Integer, CustomerRef, ContextInfo)
except it will allow carts with statusDefaultCartStatuses.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 resolvecartVersion
- Cart version expectedcustomer
- Customer who owns the cartcontextInfo
- 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 thecartVersion
expected
-
resolveCartForUpdate
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 theCart.getVersion()
andCart.getStatus()
.- Parameters:
cartId
- Id of the cart to resolvecartVersion
- Cart version expectedcustomer
- Customer who owns the cartcontextInfo
- 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 thecartVersion
expectedCartApprovalValidationException
- when the cart cannot be updated because the customer is not an approver and the cart's status isDefaultCartStatuses.REQUIRES_APPROVAL
.
-
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 theCart
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 checkcustomer
- the customercontextInfo
- the context info- Returns:
- an optional with a cart, or empty
-
resolveInProcessCart
@Deprecated(since="1.8.0", forRemoval=true) 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) Deprecated, for removal: This API element is subject to removal in a future version.since 1.8.0, useresolveImplicitCart(CustomerRef, ContextInfo)
insteadResolves the current in-progressCart
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 ofDefaultCartStatuses.IN_PROCESS
carts, however a user can only have one implicit/default cart.- Parameters:
customer
- the customercontextInfo
- the context info- Returns:
- an optional with a cart, or empty
-
getCartNotFoundMessage
-
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) Resolves the givenCustomerRef
's implicit/default cart, which out of the box means anDefaultCartStatuses.IN_PROCESS
cart withnull
name.- Parameters:
customer
- theCustomerRef
representing the currently authenticated usercontextInfo
- the context info- Returns:
- an optional with a cart, or empty
-
resolveImplicitCart(CustomerRef, ContextInfo)
instead