Class DefaultItemChoiceConfigurationService
java.lang.Object
com.broadleafcommerce.cartoperation.service.configuration.DefaultItemChoiceConfigurationService
- All Implemented Interfaces:
ItemChoiceConfigurationService
public class DefaultItemChoiceConfigurationService
extends Object
implements ItemChoiceConfigurationService
- Author:
- Chad Harchar (charchar)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultItemChoiceConfigurationService(org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddItemConfigError(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull ItemChoice itemChoice, @NonNull String errorCode, @NonNull String errorMessage) protected List<com.broadleafcommerce.cart.client.domain.CartItem>findAndHydrateDependentsInCategory(@NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull ItemChoice itemChoice) protected List<com.broadleafcommerce.cart.client.domain.CartItem>findAndHydrateDependentsMatchingItemChoice(@NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull ItemChoice itemChoice) protected List<com.broadleafcommerce.cart.client.domain.CartItem>findAndHydrateDependentsMatchingProducts(@NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull ItemChoice itemChoice) protected List<com.broadleafcommerce.cart.client.domain.CartItem>findAndHydrateDependentsMatchingVariants(@NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull ItemChoice itemChoice) protected MatchingDependentsContextfindDependentsMatchingItemChoice(@NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull ItemChoice itemChoice) protected CartSubscriptionUtilsprotected StringgetMessage(@NonNull String errorMessage, Object... args) protected org.springframework.context.MessageSourceprotected com.broadleafcommerce.common.extension.TypeFactoryprotected voidhydrateItemChoicePricingDetails(@NonNull ItemChoice itemChoice, @NonNull com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem) Hydrates the pricing details for the parentItemChoiceon thedependent CartItemrepresenting a specific choice.protected booleanisDiscountAllowed(@NonNull ItemChoice itemChoice) protected booleanisDiscountAllowed(@NonNull ItemChoice itemChoice, SpecificItemChoice specificItemChoice) voidpopulateItemChoice(com.broadleafcommerce.cart.client.domain.CartItem cartItem, ProductOption option, List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems) Populates item choices inCartItem.getDependentCartItems()and hydrates them with pricing information fromItemChoiceandSpecificItemChoice.voidsetCartSubscriptionUtils(CartSubscriptionUtils cartSubscriptionUtils) protected booleanshouldValidateItemChoiceForSubscriptionItem(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull ItemChoice itemChoice) Whether the cart item representing a subscription item should be validated during the current flow using theItemChoice.voidvalidateItemChoice(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull ProductOption option, @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems) Perform validation against the providedCartItemfor the givenProductOptionof typeProductOptionType.isItemChoice(String).protected voidvalidateItemChoiceForSubscriptionItem(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull ItemChoice itemChoice, @NonNull MatchingDependentsContext matchingCartItems, @NonNull ProductOption option) Validates subscription related properties for theMatchingDependentsContextbased on theItemChoice, which is derived from theProducttheCartItemrepresents.protected voidvalidateMaxQuantity(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull ItemChoice itemChoice, @NonNull MatchingDependentsContext matchingCartItems, @NonNull ProductOption option) protected voidvalidateMinQuantity(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull ItemChoice itemChoice, @NonNull MatchingDependentsContext matchingCartItems, @NonNull ProductOption option) protected voidvalidateSubscriptionItemAddAfterPurchase(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull ItemChoice itemChoice, @NonNull MatchingDependentsContext matchingCartItems, int quantityPriorModification) protected booleanvalidateSubscriptionItemEditAfterPurchase(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull ItemChoice itemChoice, @NonNull MatchingDependentsContext matchingCartItems, int quantityPriorModification) protected voidvalidateSubscriptionItemQuantityDecreaseDeadline(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull ItemChoice itemChoice, @NonNull MatchingDependentsContext matchingCartItems, int quantityPriorModification) protected voidvalidateSubscriptionItemQuantityEditAfterPurchase(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull ItemChoice itemChoice, @NonNull MatchingDependentsContext matchingCartItems, int quantityPriorModification)
-
Constructor Details
-
DefaultItemChoiceConfigurationService
public DefaultItemChoiceConfigurationService(org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
populateItemChoice
public void populateItemChoice(com.broadleafcommerce.cart.client.domain.CartItem cartItem, ProductOption option, List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems) Description copied from interface:ItemChoiceConfigurationServicePopulates item choices inCartItem.getDependentCartItems()and hydrates them with pricing information fromItemChoiceandSpecificItemChoice.- Specified by:
populateItemChoicein interfaceItemChoiceConfigurationService- Parameters:
cartItem- TheCartItemon which to populateItemChoices.option- TheProductOption(and itsProductOption.getItemChoice()for the item to populate and hydratepotentialDependentItems- The list ofdependent cart itemsto pick from when populatingItemChoice.
-
findAndHydrateDependentsMatchingItemChoice
protected List<com.broadleafcommerce.cart.client.domain.CartItem> findAndHydrateDependentsMatchingItemChoice(@NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull @NonNull ItemChoice itemChoice) -
findAndHydrateDependentsInCategory
protected List<com.broadleafcommerce.cart.client.domain.CartItem> findAndHydrateDependentsInCategory(@NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull @NonNull ItemChoice itemChoice) -
findAndHydrateDependentsMatchingProducts
protected List<com.broadleafcommerce.cart.client.domain.CartItem> findAndHydrateDependentsMatchingProducts(@NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull @NonNull ItemChoice itemChoice) -
findAndHydrateDependentsMatchingVariants
protected List<com.broadleafcommerce.cart.client.domain.CartItem> findAndHydrateDependentsMatchingVariants(@NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull @NonNull ItemChoice itemChoice) -
hydrateItemChoicePricingDetails
protected void hydrateItemChoicePricingDetails(@NonNull @NonNull ItemChoice itemChoice, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem) Hydrates the pricing details for the parentItemChoiceon thedependent CartItemrepresenting a specific choice. This information will be needed when pricing since theItemChoice.getOverridePrice()should be used if the specific item doesn't have its own rather than using the underlyingProduct'sorVariant's.- Parameters:
itemChoice- The parentItemChoiceof thedependentCartItemrepresenting aSpecificItemChoice.dependentCartItem- TheCartItemrepresenting aSpecificItemChoice
-
isDiscountAllowed
-
isDiscountAllowed
protected boolean isDiscountAllowed(@NonNull @NonNull ItemChoice itemChoice, SpecificItemChoice specificItemChoice) -
validateItemChoice
public void validateItemChoice(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull ProductOption option, @NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems) Description copied from interface:ItemChoiceConfigurationServicePerform validation against the providedCartItemfor the givenProductOptionof typeProductOptionType.isItemChoice(String). This will also hydrateCartItemwith pricing information fromItemChoiceandSpecificItemChoice.- Specified by:
validateItemChoicein interfaceItemChoiceConfigurationService- Parameters:
cartItem- TheCartItemto performitem choicevalidation against.option- TheProductOption(and it'sProductOption.getItemChoice()we are using to validate the cart against.potentialDependentItems- The list ofdependent cart itemsto pick from when validatingItemChoice.
-
findDependentsMatchingItemChoice
protected MatchingDependentsContext findDependentsMatchingItemChoice(@NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull @NonNull ItemChoice itemChoice) -
validateMinQuantity
protected void validateMinQuantity(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull ItemChoice itemChoice, @NonNull @NonNull MatchingDependentsContext matchingCartItems, @NonNull @NonNull ProductOption option) -
validateMaxQuantity
protected void validateMaxQuantity(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull ItemChoice itemChoice, @NonNull @NonNull MatchingDependentsContext matchingCartItems, @NonNull @NonNull ProductOption option) -
validateItemChoiceForSubscriptionItem
protected void validateItemChoiceForSubscriptionItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull ItemChoice itemChoice, @NonNull @NonNull MatchingDependentsContext matchingCartItems, @NonNull @NonNull ProductOption option) Validates subscription related properties for theMatchingDependentsContextbased on theItemChoice, which is derived from theProducttheCartItemrepresents.- Parameters:
cartItem- The parentCartItemwhose dependents should be validateditemChoice- TheItemChoicebeing used as the source of validation rules for the dependentsmatchingCartItems- TheMatchingDependentsContextwith the dependents to validate based on theitemChoice.option- TheProductOptionsource of theItemChoice- Since:
- Cart Operation Service 2.3.0, Release Train 2.3.0
-
shouldValidateItemChoiceForSubscriptionItem
protected boolean shouldValidateItemChoiceForSubscriptionItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull ItemChoice itemChoice) Whether the cart item representing a subscription item should be validated during the current flow using theItemChoice.- Parameters:
cartItem- The parentCartItemwhose dependents should be validateditemChoice- TheItemChoicebeing used as the source of validation rules for the dependents- Returns:
- Whether the cart item representing a subscription item should be validated during the current flow.
- Since:
- Cart Operation Service 2.3.0, Release Train 2.3.0
- See Also:
-
validateSubscriptionItemEditAfterPurchase
protected boolean validateSubscriptionItemEditAfterPurchase(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull ItemChoice itemChoice, @NonNull @NonNull MatchingDependentsContext matchingCartItems, int quantityPriorModification) -
validateSubscriptionItemAddAfterPurchase
protected void validateSubscriptionItemAddAfterPurchase(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull ItemChoice itemChoice, @NonNull @NonNull MatchingDependentsContext matchingCartItems, int quantityPriorModification) -
validateSubscriptionItemQuantityEditAfterPurchase
protected void validateSubscriptionItemQuantityEditAfterPurchase(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull ItemChoice itemChoice, @NonNull @NonNull MatchingDependentsContext matchingCartItems, int quantityPriorModification) -
validateSubscriptionItemQuantityDecreaseDeadline
protected void validateSubscriptionItemQuantityDecreaseDeadline(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull ItemChoice itemChoice, @NonNull @NonNull MatchingDependentsContext matchingCartItems, int quantityPriorModification) -
getMessage
-
addItemConfigError
protected void addItemConfigError(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull ItemChoice itemChoice, @NonNull @NonNull String errorCode, @NonNull @NonNull String errorMessage) -
getMessageSource
protected org.springframework.context.MessageSource getMessageSource() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getCartSubscriptionUtils
-
setCartSubscriptionUtils
-