Interface CartItemConfigurationService
-
- All Known Implementing Classes:
DefaultCartItemConfigurationService
public interface CartItemConfigurationService
- Author:
- Chad Harchar (charchar)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Variant
determineVariant(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull Product product)
Attempt to determine the variant by the requested variant ID on theCartItem
.void
hydrateIncludedProductDependentItems(com.broadleafcommerce.cart.client.domain.CartItem cartItem, List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, Product product, boolean isAdd)
PopulateIncludedProduct
information onCartItem.getDependentCartItems()
based on the product configuration.void
hydrateItemChoiceDependentItems(com.broadleafcommerce.cart.client.domain.CartItem cartItem, List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, Product product)
PopulateItemChoice
information onCartItem.getDependentCartItems()
based on the product configuration.void
validateCartItem(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartItem cartItem, Product product, String validationFlow)
Process cart item configuration by validating product options.
-
-
-
Method Detail
-
determineVariant
@Nullable Variant determineVariant(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Product product)
Attempt to determine the variant by the requested variant ID on theCartItem
. Otherwise, if any of theProduct's Options
are marked asProductOptionType.VARIANT_DISTINGUISHING
, we need to determine theVariant
for theCartItem
using theCartItem.getAttributeChoices()
.- Parameters:
cartItem
- The cart item to determine the variant for.product
- TheProduct
containing options and variants.
-
hydrateIncludedProductDependentItems
void hydrateIncludedProductDependentItems(com.broadleafcommerce.cart.client.domain.CartItem cartItem, List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, Product product, boolean isAdd)
PopulateIncludedProduct
information onCartItem.getDependentCartItems()
based on the product configuration.- Parameters:
cartItem
- The cart item on which to populate dependent item product configuration information.potentialDependentItems
- The list ofCartItem.getDependentCartItems()
to pick from to find a match for anIncludedProduct
.product
- The product with configuration to be used for hydration.isAdd
- Whether we are in an add-to-cart flow
-
hydrateItemChoiceDependentItems
void hydrateItemChoiceDependentItems(com.broadleafcommerce.cart.client.domain.CartItem cartItem, List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, Product product)
PopulateItemChoice
information onCartItem.getDependentCartItems()
based on the product configuration.- Parameters:
cartItem
- The cart item on which to populate dependent item product configuration information.potentialDependentItems
- The list ofCartItem.getDependentCartItems()
to pick from to find a match for anItemChoice
.product
- The product with configuration to be used for hydration.
-
validateCartItem
void validateCartItem(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartItem cartItem, Product product, String validationFlow)
Process cart item configuration by validating product options. Errors for the item will be recorded intoCartItem.getGlobalConfigErrors()
, while errors for specific attributes will be recorded intoCartItem.getAttributeConfigErrors()
. For hierarchical cart items (items withCartItem.getDependentCartItems()
) it is intended that this method be called from the bottom up, i.e., the lowest level dependent item gets called first. That way, errors on items will be properly cascaded up the hierarchy asCartItemConfigurationErrorEnum.MISCONFIGURED_DEPENDENT_ITEMS
onCartItem.getGlobalConfigErrors()
.- Parameters:
cart
- The cart with the cart itemcartItem
- The cart item with which to process configuration.validationFlow
- The context used to identify validation requirements of theCartItem
at that point in its lifecycle. If this is set toValidationStrategy.ADD_ITEM
, then the configuration service will try to
-
-