Class DefaultCartItemConfigurationService<P extends Product>
java.lang.Object
com.broadleafcommerce.cartoperation.service.configuration.DefaultCartItemConfigurationService<P>
- All Implemented Interfaces:
CartItemConfigurationService<P>
public class DefaultCartItemConfigurationService<P extends Product>
extends Object
implements CartItemConfigurationService<P>
- Author:
- Chad Harchar (charchar)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCartItemConfigurationService(IncludedProductConfigurationService includedProductService, ItemChoiceConfigurationService itemChoiceService, AttributeChoiceConfigurationService attributeChoiceService, org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory) DefaultCartItemConfigurationService(CatalogProvider<? extends CatalogItem> catalogProvider, IncludedProductConfigurationService includedProductService, ItemChoiceConfigurationService itemChoiceService, AttributeChoiceConfigurationService attributeChoiceService, 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 String errorCode, @NonNull String errorMessage) protected intcalculateDependentItemsQuantity(com.broadleafcommerce.cart.client.domain.CartItem parentDependentCartItem, com.broadleafcommerce.cart.client.domain.CartItem cartItem, int parentQuantity) Recursively calculates the quantities of the items dependent on the parent CartItem.protected intcalculateItemAndDependentItemsQuantityWithSameProductId(@NonNull com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, int parentQuantity) Calculates the total quantity of a particular dependent cart item in the cart.protected intcalculateItemAndDependentItemsQuantityWithSameSku(@NonNull com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, int parentQuantity) Calculates the total quantity of a particular dependent cart item in the cart.protected intcalculateItemsQuantity(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, int parentItemQuantity, int itemsInCartQuantity) Calculates the total quantity of a particular item in the cart.protected intcalculateItemsQuantityWithSameProductId(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, int parentItemQuantity) Calculates the total quantity of a particular item in the cart.protected intcalculateItemsQuantityWithSameSku(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, int parentItemQuantity) Calculates the total quantity of a particular item in the cart.booleancartItemHasQuantityThresholds(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull CatalogItemList<? extends CatalogItem> catalogItemList) Determines if the providedCartItem'srelatedCatalogItemhas quantity threshold restrictions.booleancartItemHasQuantityThresholds(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull CatalogItemList<? extends CatalogItem> catalogItemList, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the providedCartItem'srelatedCatalogItemhas quantity threshold restrictions.<R extends CatalogItemRequest>
booleancatalogItemRequestAlreadyExists(@NonNull Collection<R> catalogItemRequests, @NonNull String productId, String variantId) Hook point to prevent duplicateCatalogItemRequestsfrom being built based on the passed in IDs.protected voidconsolidateConfigErrors(@NotNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P broadleafProduct) protected Stream<com.broadleafcommerce.cart.client.domain.CartItem>flattenWithDependents(@NonNull com.broadleafcommerce.cart.client.domain.CartItem item) Returns a flattened stream consisting of the given item with all of its nested dependents.protected AttributeChoiceConfigurationServiceprotected BroadleafProductService<Product>protected CartSubscriptionUtilsprotected CatalogProvider<? extends CatalogItem>Deprecated.protected IncludedProductConfigurationServiceprotected ItemChoiceConfigurationServiceprotected StringgetMessage(@NonNull String errorMessage, Object... args) protected org.springframework.context.MessageSourceprotected CartOperationServiceOfferUtilsprotected StringgetProductType(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Gets the product type from thecart itemif it exists.protected CartOperationServicePropertiesprotected SubscriptionOpsProviderprotected com.broadleafcommerce.common.extension.TypeFactoryprotected StringgetUserRefForReadingUserSubscriptionSummary(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) The userRefType to query the Subscription-Ops service to group them into active and former subscriptions.protected StringgetUserRefTypeForReadingUserSubscriptionSummary(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) The userRefType to query the Subscription-Ops service to group them into active and former subscriptions.protected booleanhasPositiveQuantity(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) protected booleanhasVariantDistinguishingOptions(P product) identifyProductForCartItem(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull CatalogItemList<? extends CatalogItem> catalogItemList) protected booleanisNonSkuTypeOrNullSku(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Determines if a provided CartItem is a Product Type that does not normally have a sku or has a null sku.protected booleanisSubscriptionBillingFrequencyChangeAllowed(@NonNull String subscriptionActionFlow, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull ExistingSubscriptionDetails existingSubscriptionDetails, P product, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanrequiredAttributesMissing(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) voidsetBroadleafProductService(BroadleafProductService<Product> broadleafProductService) voidsetCartSubscriptionUtils(CartSubscriptionUtils cartSubscriptionUtils) voidsetOfferUtils(CartOperationServiceOfferUtils offerUtils) voidsetProperties(CartOperationServiceProperties properties) voidsetSubscriptionOpsProvider(SubscriptionOpsProvider subscriptionOpsProvider) protected voidvalidateBillingFrequencyChange(@NonNull String subscriptionActionFlow, @NonNull ExistingSubscriptionDetails existingSubscriptionDetails, @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) If the givenUpdateItemRequestis changing the billing frequency of the subscription, validates that the change is allowed.voidvalidateCartItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull CatalogItemList<? extends CatalogItem> catalogItemList, @NonNull String validationFlow, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Process cart item configuration by validating catalog information.voidvalidateCartItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull CatalogItem product, @NonNull String validationFlow, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Process cart item configuration by validating catalog information.voidvalidateCartItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull CatalogItem product, String validationFlow) Process cart item configuration by validating catalog information.protected voidvalidateCartItemInternal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull CatalogItem product, @NonNull CatalogItemList<? extends CatalogItem> catalogItemList, boolean isDependentItem, String validationFlow, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidvalidateCustomQuoteItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Processes item configuration validation for custom quote items.voidvalidateCustomQuoteItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Processes item configuration validation for custom quote items.protected voidvalidateDependentItems(com.broadleafcommerce.cart.client.domain.Cart cart, @NotNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NotNull CatalogItemList<? extends CatalogItem> catalogItemList, String validationFlow, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidvalidateIndividuallySold(@NotNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P broadleafProduct) protected voidvalidateItemAndDependentsHavePositiveQuantities(@NonNull com.broadleafcommerce.cart.client.domain.CartItem item) A basic requirement is that all items added to a cart have a positive quantity.voidvalidateNonCatalogItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Processes item configuration validation for non-catalog items.protected voidvalidateProductOptions(@NotNull com.broadleafcommerce.cart.client.domain.Cart cart, @NotNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, String validationFlow, P broadleafProduct) protected voidvalidateQuantityWithinThreshold(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product) Checks if the quantity of the item fits within the threshold.protected voidvalidateSelectorProduct(@NotNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P broadleafProduct) protected voidvalidateSubscriptionCartItem(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates the subscription cart item.voidvalidateSubscriptionCartItemPricing(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) In some cases, it is necessary to validate the cart items after pricing has been hydrated.protected voidvalidateTerms(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P product) Determines if thecartItemis valid based on theproduct'sinfo.booleanvariantCartItemMissingFromCatalogItem(@NonNull CatalogItemList<? extends CatalogItem> catalogItemList, @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if the providedCartItemdoes not have a backingVariantfrom the list ofCatalogItemThis specifically targets Variants by checking the variant ID of a cart item.
-
Constructor Details
-
DefaultCartItemConfigurationService
public DefaultCartItemConfigurationService(IncludedProductConfigurationService includedProductService, ItemChoiceConfigurationService itemChoiceService, AttributeChoiceConfigurationService attributeChoiceService, org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
DefaultCartItemConfigurationService
public DefaultCartItemConfigurationService(CatalogProvider<? extends CatalogItem> catalogProvider, IncludedProductConfigurationService includedProductService, ItemChoiceConfigurationService itemChoiceService, AttributeChoiceConfigurationService attributeChoiceService, org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
getCatalogProvider
Deprecated.This implementation does not usecatalogProviderAccess orcatalogProvider.- Returns:
- The configured
catalogProvider
-
cartItemHasQuantityThresholds
public boolean cartItemHasQuantityThresholds(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull CatalogItemList<? extends CatalogItem> catalogItemList) Description copied from interface:CartItemConfigurationServiceDetermines if the providedCartItem'srelatedCatalogItemhas quantity threshold restrictions.- Specified by:
cartItemHasQuantityThresholdsin interfaceCartItemConfigurationService<P extends Product>- Parameters:
cartItem- TheCartItemthat we need to check for quantity thresholds.catalogItemList- TheCatalogItemListthat should contain theCartItem'srelatedCatalogItem.- Returns:
- If the provided
CartItem'srelatedCatalogItemhas quantity threshold restrictions.
-
cartItemHasQuantityThresholds
public boolean cartItemHasQuantityThresholds(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull CatalogItemList<? extends CatalogItem> catalogItemList, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartItemConfigurationServiceDetermines if the providedCartItem'srelatedCatalogItemhas quantity threshold restrictions.- Specified by:
cartItemHasQuantityThresholdsin interfaceCartItemConfigurationService<P extends Product>- Parameters:
cartItem- TheCartItemthat we need to check for quantity thresholds.catalogItemList- TheCatalogItemListthat should contain theCartItem'srelatedCatalogItem.contextInfo- Context information around sandbox and multitenant state.- Returns:
- If the provided
CartItem'srelatedCatalogItemhas quantity threshold restrictions.
-
validateCartItem
public void validateCartItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull CatalogItemList<? extends CatalogItem> catalogItemList, @NonNull @NonNull String validationFlow, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartItemConfigurationServiceProcess cart item configuration by validating catalog information. 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_ITEMSonCartItem.getGlobalConfigErrors().- Specified by:
validateCartItemin interfaceCartItemConfigurationService<P extends Product>- Parameters:
cart- The cart with the cart itemcartItem- The cart item with which to process configuration.catalogItemList- TheCatalogItemListthat should contain theCartItem'srelatedCatalogItem.validationFlow- The context used to identify validation requirements of theCartItemat that point in its lifecycle. If this is set toValidationStrategy.ADD_ITEM, then the configuration service will try tocontextInfo- Context information around sandbox and multitenant state.
-
validateCartItem
public void validateCartItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull CatalogItem product, String validationFlow) Description copied from interface:CartItemConfigurationServiceProcess cart item configuration by validating catalog information. 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_ITEMSonCartItem.getGlobalConfigErrors().- Specified by:
validateCartItemin interfaceCartItemConfigurationService<P extends Product>- Parameters:
cart- The cart with the cart itemcartItem- The cart item with which to process configuration.product- TheCatalogItemwith configuration to be used for validation.validationFlow- The context used to identify validation requirements of theCartItemat that point in its lifecycle. If this is set toValidationStrategy.ADD_ITEM, then the configuration service will try to
-
validateCartItem
public void validateCartItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull CatalogItem product, @NonNull @NonNull String validationFlow, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartItemConfigurationServiceProcess cart item configuration by validating catalog information. 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_ITEMSonCartItem.getGlobalConfigErrors().- Specified by:
validateCartItemin interfaceCartItemConfigurationService<P extends Product>- Parameters:
cart- The cart with the cart itemcartItem- The cart item with which to process configuration.product- TheCatalogItemwith configuration to be used for validation.validationFlow- The context used to identify validation requirements of theCartItemat that point in its lifecycle. If this is set toValidationStrategy.ADD_ITEM, then the configuration service will try tocontextInfo- Context information around sandbox and multitenant state.
-
validateCustomQuoteItem
public void validateCustomQuoteItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Description copied from interface:CartItemConfigurationServiceProcesses item configuration validation for custom quote items.Any customization should be added here.
- Specified by:
validateCustomQuoteItemin interfaceCartItemConfigurationService<P extends Product>- Parameters:
cart- The cart with the cart itemcartItem- The cart item with which to process configuration- See Also:
-
DefaultCartItemTypes.CUSTOM_QUOTE_ITEM
-
validateCustomQuoteItem
public void validateCustomQuoteItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartItemConfigurationServiceProcesses item configuration validation for custom quote items.Any customization should be added here.
- Specified by:
validateCustomQuoteItemin interfaceCartItemConfigurationService<P extends Product>- Parameters:
cart- The cart with the cart itemcartItem- The cart item with which to process configurationcontextInfo- Context information around sandbox and multitenant state.- See Also:
-
DefaultCartItemTypes.CUSTOM_QUOTE_ITEM
-
validateNonCatalogItem
public void validateNonCatalogItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartItemConfigurationServiceProcesses item configuration validation for non-catalog items.Any customization should be added here.
- Specified by:
validateNonCatalogItemin interfaceCartItemConfigurationService<P extends Product>- Parameters:
cart- The cart with the cart itemcartItem- The cart item with which to process configurationcontextInfo- Context information around sandbox and multitenant state.- See Also:
-
DefaultCartItemTypes.NON_CATALOG_ITEM
-
validateSubscriptionCartItemPricing
public void validateSubscriptionCartItemPricing(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartItemConfigurationServiceIn some cases, it is necessary to validate the cart items after pricing has been hydrated. For example, for Merchandising Bundles with Subscription Items, the prices of the Subscription Items should match the payment strategy of the parent Merchandising Bundle.- Specified by:
validateSubscriptionCartItemPricingin interfaceCartItemConfigurationService<P extends Product>- Parameters:
cart- TheCartbeing priced.contextInfo- Additional sandbox and multitenant info
-
catalogItemRequestAlreadyExists
public <R extends CatalogItemRequest> boolean catalogItemRequestAlreadyExists(@NonNull @NonNull Collection<R> catalogItemRequests, @NonNull @NonNull String productId, @Nullable String variantId) Description copied from interface:CartItemConfigurationServiceHook point to prevent duplicateCatalogItemRequestsfrom being built based on the passed in IDs.The
variantIdUsedToIdentifyCatalogItemRequests propertyis used to determine if the variant ID of theCartItemorAddItemRequestwill be used to determine a duplicateCatalogItemRequestalong with the product ID. By default, this property is set to true.- Specified by:
catalogItemRequestAlreadyExistsin interfaceCartItemConfigurationService<P extends Product>- Parameters:
catalogItemRequests- the list of requests to check for duplicatesproductId- the product ID to check the existingCatalogItemRequestswithvariantId- the possible variant ID to check the existingCatalogItemRequestswith- Returns:
- true if any existing
CatalogItemRequestmatches the passed in product and/or variant IDs
-
variantCartItemMissingFromCatalogItem
public boolean variantCartItemMissingFromCatalogItem(@NonNull @NonNull CatalogItemList<? extends CatalogItem> catalogItemList, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CartItemConfigurationServiceDetermines if the providedCartItemdoes not have a backingVariantfrom the list ofCatalogItemThis specifically targets Variants by checking the variant ID of a cart item.- Specified by:
variantCartItemMissingFromCatalogItemin interfaceCartItemConfigurationService<P extends Product>- Parameters:
catalogItemList- the list ofCatalogItemscartItem- the cart item to checkcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- true if the
cartItemdoes not have a backingVariantfor a variant
-
getProductType
@Nullable protected String getProductType(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Gets the product type from thecart itemif it exists.- Parameters:
cartItem- The cart item whose inventory is being checked- Returns:
- the product type from the
cart itemif it exists - Since:
- Cart Operation Service 2.3.0, Release Train 2.3.0
-
validateCartItemInternal
protected void validateCartItemInternal(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull CatalogItem product, @NonNull @NonNull CatalogItemList<? extends CatalogItem> catalogItemList, boolean isDependentItem, String validationFlow, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
consolidateConfigErrors
protected void consolidateConfigErrors(@NotNull @NotNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P broadleafProduct) -
validateProductOptions
-
validateDependentItems
protected void validateDependentItems(com.broadleafcommerce.cart.client.domain.Cart cart, @NotNull @NotNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NotNull @NotNull CatalogItemList<? extends CatalogItem> catalogItemList, String validationFlow, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
validateSelectorProduct
protected void validateSelectorProduct(@NotNull @NotNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P broadleafProduct) -
validateIndividuallySold
protected void validateIndividuallySold(@NotNull @NotNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, P broadleafProduct) -
hasVariantDistinguishingOptions
-
validateItemAndDependentsHavePositiveQuantities
protected void validateItemAndDependentsHavePositiveQuantities(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem item) A basic requirement is that all items added to a cart have a positive quantity. This method validates the given item and all of its nested dependents to ensure they have a positive quantity. Config errors will be registered on the item if the validation does not pass.- Parameters:
item- the item which should be validated to have a positive quantity for itself and dependents
-
hasPositiveQuantity
protected boolean hasPositiveQuantity(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) -
flattenWithDependents
protected Stream<com.broadleafcommerce.cart.client.domain.CartItem> flattenWithDependents(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem item) Returns a flattened stream consisting of the given item with all of its nested dependents.- Parameters:
item- the item to flatten- Returns:
- a flattened stream consisting of the given item with all of its nested dependents
-
validateQuantityWithinThreshold
protected void validateQuantityWithinThreshold(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull P product) Checks if the quantity of the item fits within the threshold.- Parameters:
cart- The cart for thiscart itemcartItem- The cart item whose quantity is being validatedproduct- The product that this CartItem is intended to represent
-
calculateItemsQuantityWithSameSku
protected int calculateItemsQuantityWithSameSku(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, int parentItemQuantity) Calculates the total quantity of a particular item in the cart. Checks against the sku of the cartItem being added to the cart.- Parameters:
cartItem- the CartItem being added to the cartcart- the current Cart being modifiedparentItemQuantity- the quantity of the parent CartItem- Returns:
- the quantity of items in the cart with the same sku
-
calculateItemAndDependentItemsQuantityWithSameSku
protected int calculateItemAndDependentItemsQuantityWithSameSku(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, int parentQuantity) Calculates the total quantity of a particular dependent cart item in the cart. Checks against the sku of the cartItem being added to the cart.- Parameters:
dependentCartItem- the item dependent on the main CartItem being addedcartItem- the CartItem being added to the cartparentQuantity- the quantity of the parent CartItem for the dependent cart items- Returns:
- the quantity of dependent items in the cart with the same sku
-
calculateItemsQuantityWithSameProductId
protected int calculateItemsQuantityWithSameProductId(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, int parentItemQuantity) Calculates the total quantity of a particular item in the cart. Checks against the productId of the cartItem being added to the cart. This method is useful in cases where a CartItem may not have a sku such as with a BUNDLE type.- Parameters:
cartItem- the CartItem being added to the cartcart- the current Cart being modifiedparentItemQuantity- the quantity of the parent CartItem for the dependent cart items- Returns:
- the quantity of items in the cart with the same productId
-
calculateItemAndDependentItemsQuantityWithSameProductId
protected int calculateItemAndDependentItemsQuantityWithSameProductId(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem dependentCartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, int parentQuantity) Calculates the total quantity of a particular dependent cart item in the cart. Checks against the productId of the cartItem being added to the cart. This method is useful in cases where a CartItem may not have a sku such as with a BUNDLE type.- Parameters:
dependentCartItem- the current dependent cart itemcartItem- the CartItem being added to the cartparentQuantity- the quantity of the parent CartItem for the dependent cart items- Returns:
- the quantity of dependent items in the cart with the same productId
-
calculateItemsQuantity
protected int calculateItemsQuantity(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, int parentItemQuantity, int itemsInCartQuantity) Calculates the total quantity of a particular item in the cart.- Parameters:
cartItem- the CartItem being added to check againstcart- the current Cart being modifiedparentItemQuantity- the quantity of the parent CartItem for the dependent cart itemsitemsInCartQuantity- the quantity of similar items already found in the cart- Returns:
- the quantity of items in the cart
-
calculateDependentItemsQuantity
protected int calculateDependentItemsQuantity(com.broadleafcommerce.cart.client.domain.CartItem parentDependentCartItem, com.broadleafcommerce.cart.client.domain.CartItem cartItem, int parentQuantity) Recursively calculates the quantities of the items dependent on the parent CartItem.- Parameters:
parentDependentCartItem- the CartItem to check for dependentCartItemscartItem- the original parent CartItem being added to the cartparentQuantity- the total quantity of the current parent dependentCartItem- Returns:
- the quantity of currently calculated dependent cart items
-
validateTerms
protected void validateTerms(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull P product) Determines if thecartItemis valid based on theproduct'sinfo.- Parameters:
cartItem- TheCartItemto validate.product- TheProductadded to the cart with source information used for validating the terms.- Since:
- Cart Operation Service 2.2.0, Release Train 2.2.0
-
validateSubscriptionCartItem
protected void validateSubscriptionCartItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull P product, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Validates the subscription cart item.- Parameters:
cart- theCartcontaining theCartItem.cartItem- the subscriptionCartItemto validate.product- the subscriptionProductadded to the cart with source informationcontextInfo- theContextInfofor the current operation- Since:
- Cart Operation Service 2.3.0, Release Train 2.3.0
-
validateBillingFrequencyChange
protected void validateBillingFrequencyChange(@NonNull @NonNull String subscriptionActionFlow, @NonNull @NonNull ExistingSubscriptionDetails existingSubscriptionDetails, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull P product, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) If the givenUpdateItemRequestis changing the billing frequency of the subscription, validates that the change is allowed.By default, the billing frequency change is only allowed if there's no delayed actions against the subscription and if the action being taken isn't a delayed action itself (e.g. prepaid downgrade).
- Parameters:
subscriptionActionFlow- theDefaultSubscriptionActionFlowrepresenting the action being taken against the subscriptionexistingSubscriptionDetails- theExistingSubscriptionDetailscart- theCartcontaining the item being updatedcartItem- theCartItembeing updatedproduct- theProductassociated with the item being updatedcontextInfo- context information around sandbox and multitenant state- Since:
- Cart Operation Service 2.3.0, Release Train 2.3.0
-
isSubscriptionBillingFrequencyChangeAllowed
protected boolean isSubscriptionBillingFrequencyChangeAllowed(@NonNull @NonNull String subscriptionActionFlow, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull ExistingSubscriptionDetails existingSubscriptionDetails, @NonNull P product, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
requiredAttributesMissing
protected boolean requiredAttributesMissing(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) -
addItemConfigError
-
getMessage
-
identifyProductForCartItem
protected Optional<P> identifyProductForCartItem(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull CatalogItemList<? extends CatalogItem> catalogItemList) -
isNonSkuTypeOrNullSku
protected boolean isNonSkuTypeOrNullSku(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem) Determines if a provided CartItem is a Product Type that does not normally have a sku or has a null sku.- Parameters:
cartItem- the CartItem to check for type and sku- Returns:
- True if a CartItem is a non sku type or does not have a sku on it, otherwise false.
-
getUserRefTypeForReadingUserSubscriptionSummary
protected String getUserRefTypeForReadingUserSubscriptionSummary(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) The userRefType to query the Subscription-Ops service to group them into active and former subscriptions.- Parameters:
cart- the cart containing the user reference info- Returns:
- the userRefType
- Since:
- Cart Operation Service 2.3.0, Release Train 2.3.0
-
getUserRefForReadingUserSubscriptionSummary
protected String getUserRefForReadingUserSubscriptionSummary(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) The userRefType to query the Subscription-Ops service to group them into active and former subscriptions.- Parameters:
cart- the cart containing the user reference info- Returns:
- the userRefType
- Since:
- Cart Operation Service 2.3.0, Release Train 2.3.0
-
getIncludedProductService
-
getItemChoiceService
-
getAttributeChoiceService
-
getMessageSource
protected org.springframework.context.MessageSource getMessageSource() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getOfferUtils
-
setOfferUtils
-
getBroadleafProductService
-
setBroadleafProductService
@Autowired public void setBroadleafProductService(BroadleafProductService<Product> broadleafProductService) -
getCartSubscriptionUtils
-
setCartSubscriptionUtils
-
getSubscriptionOpsProvider
-
setSubscriptionOpsProvider
@Autowired(required=false) public void setSubscriptionOpsProvider(@Nullable SubscriptionOpsProvider subscriptionOpsProvider) -
getProperties
-
setProperties
-
catalogProvider