Class DefaultIncludedProductConfigurationService
java.lang.Object
com.broadleafcommerce.cartoperation.service.configuration.DefaultIncludedProductConfigurationService
- All Implemented Interfaces:
IncludedProductConfigurationService
public class DefaultIncludedProductConfigurationService
extends Object
implements IncludedProductConfigurationService
- Author:
- Chad Harchar (charchar)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultIncludedProductConfigurationService
(org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addItemConfigError
(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull IncludedProduct includedProduct, @NonNull String errorCode, @NonNull String errorMessage) protected com.broadleafcommerce.cart.client.domain.CartItem
createDependentItem
(@NonNull IncludedProduct includedProduct) protected Optional<com.broadleafcommerce.cart.client.domain.CartItem>
findDependentMatchingIncludedProduct
(@NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull IncludedProduct includedProduct) protected Optional<com.broadleafcommerce.cart.client.domain.CartItem>
findMatchingProduct
(@NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull IncludedProduct includedProduct) protected Optional<com.broadleafcommerce.cart.client.domain.CartItem>
findMatchingVariant
(@NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull IncludedProduct includedProduct) protected javax.money.MonetaryAmount
getIncludedItemUnitPrice
(@NonNull IncludedProduct includedProduct) Returns the "unitPrice" of theIncludedProduct
to use for aCartItem
.protected String
getIncludedProductName
(@NonNull IncludedProduct includedProduct) Returns the "name" of theIncludedProduct
to use for aCartItem
.protected String
getMessage
(@NonNull String errorMessage, Object... args) protected org.springframework.context.MessageSource
protected com.broadleafcommerce.common.extension.TypeFactory
void
populateIncludedProduct
(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull IncludedProduct includedProduct, @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, boolean isAdd) Populate theIncludedProduct
as a dependent item in the providedCartItem
.void
validateIncludedProduct
(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull IncludedProduct includedProduct, @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems) Perform validation against the providedCartItem
for the givenIncludedProduct
.protected void
validateQuantity
(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.cart.client.domain.CartItem matchingCartItem, @NonNull IncludedProduct includedProduct)
-
Constructor Details
-
DefaultIncludedProductConfigurationService
public DefaultIncludedProductConfigurationService(org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
populateIncludedProduct
public void populateIncludedProduct(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull IncludedProduct includedProduct, @NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, boolean isAdd) Description copied from interface:IncludedProductConfigurationService
Populate theIncludedProduct
as a dependent item in the providedCartItem
. If there is already an item inCartItem.getDependentCartItems()
which matches theIncludedProduct
, then that will be hydrated with pricing information. Otherwise, a new dependent cart item will be added to represent theIncludedProduct
if we are in an add-to-cart flow.- Specified by:
populateIncludedProduct
in interfaceIncludedProductConfigurationService
- Parameters:
cartItem
- TheCartItem
for which to populate theIncludedProduct
.includedProduct
- TheIncludedProduct
we are populating.potentialDependentItems
- The list ofCartItem.getDependentCartItems()
to pick from to find a match for theIncludedProduct
.isAdd
- Whether we are in an add-to-cart flow, which dictates whether to add an unmatchedIncludedProduct
.
-
findDependentMatchingIncludedProduct
protected Optional<com.broadleafcommerce.cart.client.domain.CartItem> findDependentMatchingIncludedProduct(@NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull @NonNull IncludedProduct includedProduct) -
findMatchingProduct
protected Optional<com.broadleafcommerce.cart.client.domain.CartItem> findMatchingProduct(@NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull @NonNull IncludedProduct includedProduct) -
findMatchingVariant
protected Optional<com.broadleafcommerce.cart.client.domain.CartItem> findMatchingVariant(@NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull @NonNull IncludedProduct includedProduct) -
createDependentItem
protected com.broadleafcommerce.cart.client.domain.CartItem createDependentItem(@NonNull @NonNull IncludedProduct includedProduct) -
getIncludedProductName
Returns the "name" of theIncludedProduct
to use for aCartItem
. This defaults to the label, but if not present it will defer to the specific Variant or Product's name.- Parameters:
includedProduct
- theIncludedProduct
for which to determine a name- Returns:
- the "name" of the
IncludedProduct
to use for aCartItem
-
getIncludedItemUnitPrice
protected javax.money.MonetaryAmount getIncludedItemUnitPrice(@NonNull @NonNull IncludedProduct includedProduct) Returns the "unitPrice" of theIncludedProduct
to use for aCartItem
. This defaults to the overridePrice, but if not present it will defer to the specific Variant or Product's price.- Parameters:
includedProduct
- theIncludedProduct
for which to determine a unitPrice- Returns:
- the "unitPrice" of the
IncludedProduct
to use for aCartItem
-
validateIncludedProduct
public void validateIncludedProduct(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull IncludedProduct includedProduct, @NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems) Description copied from interface:IncludedProductConfigurationService
Perform validation against the providedCartItem
for the givenIncludedProduct
.- Specified by:
validateIncludedProduct
in interfaceIncludedProductConfigurationService
- Parameters:
cartItem
- TheCartItem
to performincluded product
validation against.includedProduct
- TheIncludedProduct
we are using to validate the cart against.potentialDependentItems
- The list ofdependent cart items
to pick from when validatingIncludedProduct
.
-
validateQuantity
protected void validateQuantity(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.cart.client.domain.CartItem matchingCartItem, @NonNull @NonNull IncludedProduct includedProduct) -
getMessage
-
addItemConfigError
protected void addItemConfigError(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull IncludedProduct includedProduct, @NonNull @NonNull String errorCode, @NonNull @NonNull String errorMessage) -
getMessageSource
protected org.springframework.context.MessageSource getMessageSource() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-