public class DefaultCartItemConfigurationService extends Object implements CartItemConfigurationService
| Constructor and Description |
|---|
DefaultCartItemConfigurationService(CatalogProvider catalogProvider,
IncludedProductConfigurationService includedProductService,
ItemChoiceConfigurationService itemChoiceService,
AttributeChoiceConfigurationService attributeChoiceService,
org.springframework.context.MessageSource messageSource,
com.broadleafcommerce.common.extension.TypeFactory typeFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addItemConfigError(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
@NonNull String errorCode,
@NonNull String errorMessage) |
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. |
protected AttributeChoiceConfigurationService |
getAttributeChoiceService() |
protected CatalogProvider |
getCatalogProvider()
Deprecated.
This implementation does not use
catalogProvider |
protected IncludedProductConfigurationService |
getIncludedProductService() |
protected ItemChoiceConfigurationService |
getItemChoiceService() |
protected String |
getMessage(@NonNull String errorMessage,
Object... args) |
protected org.springframework.context.MessageSource |
getMessageSource() |
protected com.broadleafcommerce.common.extension.TypeFactory |
getTypeFactory() |
protected boolean |
hasVariantDistinguishingOptions(@NonNull Product product) |
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. |
protected boolean |
requiredAttributesMissing(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) |
void |
validateCartItem(com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.cart.client.domain.CartItem cartItem,
Product product,
String validationFlow)
Validate the
CartItem against the provided Product. |
protected void |
validateItemAndDependentsHavePositiveQuantities(com.broadleafcommerce.cart.client.domain.CartItem item)
A basic requirement is that all items added to a cart have a positive quantity.
|
public DefaultCartItemConfigurationService(CatalogProvider catalogProvider, IncludedProductConfigurationService includedProductService, ItemChoiceConfigurationService itemChoiceService, AttributeChoiceConfigurationService attributeChoiceService, org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
@Deprecated protected CatalogProvider getCatalogProvider()
catalogProvidercatalogProvider.catalogProvider@Nullable public Variant determineVariant(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull Product product)
CartItemConfigurationServiceCartItem.
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().determineVariant in interface CartItemConfigurationServicecartItem - The cart item to determine the variant for.product - The Product containing options and variants.protected boolean hasVariantDistinguishingOptions(@NonNull
@NonNull Product product)
public void hydrateIncludedProductDependentItems(com.broadleafcommerce.cart.client.domain.CartItem cartItem,
List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems,
Product product,
boolean isAdd)
CartItemConfigurationServiceIncludedProduct information on CartItem.getDependentCartItems()
based on the product configuration.hydrateIncludedProductDependentItems in interface CartItemConfigurationServicecartItem - 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 flowpublic void hydrateItemChoiceDependentItems(com.broadleafcommerce.cart.client.domain.CartItem cartItem,
List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems,
Product product)
CartItemConfigurationServiceItemChoice information on CartItem.getDependentCartItems() based on
the product configuration.hydrateItemChoiceDependentItems in interface CartItemConfigurationServicecartItem - 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.public void validateCartItem(@Nullable
com.broadleafcommerce.cart.client.domain.Cart cart,
com.broadleafcommerce.cart.client.domain.CartItem cartItem,
Product product,
String validationFlow)
CartItem against the provided Product. For each of
Product.getOptions(), determine if it is
ProductOptionType.isItemChoice(String) or
ProductOptionType.isAttributeChoice(String) and validate the cart item in the
corresponding service. Populate the cart with any errors found.validateCartItem in interface CartItemConfigurationServicecart - The cart with the cart itemcartItem - The CartItem to validate.product - The Product to get options from to validate the cart against.validationFlow - The context used to identify validation requirements of the
CartItem at that point in its lifecycle.protected void validateItemAndDependentsHavePositiveQuantities(com.broadleafcommerce.cart.client.domain.CartItem item)
item - the item which should be validated to have a positive quantity for itself and
dependentsprotected boolean requiredAttributesMissing(@NonNull
@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem)
protected void addItemConfigError(@NonNull
@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
@NonNull
@NonNull String errorCode,
@NonNull
@NonNull String errorMessage)
protected String getMessage(@NonNull @NonNull String errorMessage, @Nullable Object... args)
protected IncludedProductConfigurationService getIncludedProductService()
protected ItemChoiceConfigurationService getItemChoiceService()
protected AttributeChoiceConfigurationService getAttributeChoiceService()
protected org.springframework.context.MessageSource getMessageSource()
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
Copyright © 2021. All rights reserved.