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(ResolveCartRequest resolveCartRequest, com.broadleafcommerce.order.common.domain.CustomerRef customer, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Resolves aCartgiven theResolveCartRequestwith 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 aCartgiven 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 theCartwith 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 theCartwith the first matching status for the given customer and context.com.broadleafcommerce.cart.client.domain.CartresolveCartForStatusChange(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_APPROVALto have their statuses updated.com.broadleafcommerce.cart.client.domain.CartresolveCartForUpdate(ResolveCartRequest resolveCartRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Resolves the cart with additional validation that it can be updated by checking theCart.getVersion(),Cart.getStatus(), and sometimes theResolveCartRequest.getWorkflow().default com.broadleafcommerce.cart.client.domain.CartresolveCartForUpdate(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().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 givenCustomerRef's implicit/default cart, which out of the box means anDefaultCartStatuses.IN_PROCESScart withnullname.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 givenCustomerRef's implicit/default cart, which out of the box means anDefaultCartStatuses.IN_PROCESScart withnullname.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.
-
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 aCartgiven the cart ID, customer, and context.If the provided
CustomerRefis 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
CustomerRefis 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
-
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 aCartgiven theResolveCartRequestwith the given cart id and data.If the provided
CustomerRefis 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
CustomerRefis 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 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 theCartwith 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_APPROVALto 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 thecartVersionexpected
-
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 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 thecartVersionexpectedCartApprovalValidationException- when the cart cannot be updated because the customer is not an approver and the cart's status isDefaultCartStatuses.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 theCart.getVersion(),Cart.getStatus(), and sometimes theResolveCartRequest.getWorkflow().- Parameters:
resolveCartRequest- theResolveCartRequestcontaining the details for the cart resolutioncontextInfo- 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 theCartwith 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 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.in favor ofresolveImplicitCart(CustomerRef, ContextInfo, boolean)insteadResolves the current in-progressCartgiven 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_PROCESScart per user. After 1.8.0, a user can have an unlimited amount ofDefaultCartStatuses.IN_PROCESScarts, 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
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 givenCustomerRef's implicit/default cart, which out of the box means anDefaultCartStatuses.IN_PROCESScart withnullname. This method will always reprice the cart to avoid stale prices. To avoid repricing the cart, useresolveImplicitCart(CustomerRef, ContextInfo, boolean)- Parameters:
customer- theCustomerRefrepresenting the currently authenticated usercontextInfo- 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 givenCustomerRef's implicit/default cart, which out of the box means anDefaultCartStatuses.IN_PROCESScart withnullname. By default,shouldRepriceis true since we want to reprice the cart. Only for the creation of a net new cart, it is set asfalse- Parameters:
customer- theCustomerRefrepresenting the currently authenticated usercontextInfo- the context infoallowRepriceDueToStaleCartPrices- declares if repricing due to stale cart prices should be considered or skipped entirely- Returns:
- an optional with a cart, or empty
-
resolveImplicitCart(CustomerRef, ContextInfo, boolean)instead