public interface CartItemConfigurationService
Modifier and Type | Method and 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 the
CartItem . |
void |
hydrateIncludedProductDependentItems(com.broadleafcommerce.cart.client.domain.CartItem cartItem,
List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems,
Product product,
boolean isAdd)
Populate
IncludedProduct information on CartItem.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)
Populate
ItemChoice information on CartItem.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.
|
@Nullable Variant determineVariant(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Product product)
CartItem
.
Otherwise, if any of the Product's Options
are marked as
ProductOptionType.VARIANT_DISTINGUISHING
, we need to determine the Variant
for the CartItem
using the CartItem.getAttributeChoices()
.cartItem
- The cart item to determine the variant for.product
- The Product
containing options and variants.void hydrateIncludedProductDependentItems(com.broadleafcommerce.cart.client.domain.CartItem cartItem, List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, Product product, boolean isAdd)
IncludedProduct
information on CartItem.getDependentCartItems()
based on the product configuration.cartItem
- The cart item on which to populate dependent item product configuration
information.potentialDependentItems
- The list of CartItem.getDependentCartItems()
to pick
from to find a match for an IncludedProduct
.product
- The product with configuration to be used for hydration.isAdd
- Whether we are in an add-to-cart flowvoid hydrateItemChoiceDependentItems(com.broadleafcommerce.cart.client.domain.CartItem cartItem, List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, Product product)
ItemChoice
information on CartItem.getDependentCartItems()
based on
the product configuration.cartItem
- The cart item on which to populate dependent item product configuration
information.potentialDependentItems
- The list of CartItem.getDependentCartItems()
to pick
from to find a match for an ItemChoice
.product
- The product with configuration to be used for hydration.void validateCartItem(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartItem cartItem, Product product, String validationFlow)
CartItem.getGlobalConfigErrors()
, while errors for specific attributes
will be recorded into CartItem.getAttributeConfigErrors()
.
For hierarchical cart items (items with CartItem.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 as
CartItemConfigurationErrorEnum.MISCONFIGURED_DEPENDENT_ITEMS
on
CartItem.getGlobalConfigErrors()
.cart
- The cart with the cart itemcartItem
- The cart item with which to process configuration.validationFlow
- The context used to identify validation requirements of the
CartItem
at that point in its lifecycle. If this is set to
ValidationStrategy.ADD_ITEM
, then the configuration service will try toCopyright © 2021. All rights reserved.