public class DefaultIncludedProductConfigurationService extends Object implements IncludedProductConfigurationService
Constructor and Description |
---|
DefaultIncludedProductConfigurationService(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 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 the
IncludedProduct to use for a CartItem . |
protected String |
getIncludedProductName(@NonNull IncludedProduct includedProduct)
Returns the "name" of the
IncludedProduct to use for a CartItem . |
protected String |
getMessage(@NonNull String errorMessage,
Object... args) |
protected org.springframework.context.MessageSource |
getMessageSource() |
protected com.broadleafcommerce.common.extension.TypeFactory |
getTypeFactory() |
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 the
IncludedProduct as a dependent item in the provided CartItem . |
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 provided
CartItem for the given
IncludedProduct . |
protected void |
validateQuantity(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
com.broadleafcommerce.cart.client.domain.CartItem matchingCartItem,
@NonNull IncludedProduct includedProduct) |
public DefaultIncludedProductConfigurationService(org.springframework.context.MessageSource messageSource, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
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)
IncludedProductConfigurationService
IncludedProduct
as a dependent item in the provided CartItem
. If
there is already an item in CartItem.getDependentCartItems()
which matches the
IncludedProduct
, then that will be hydrated with pricing information. Otherwise, a
new dependent cart item will be added to represent the IncludedProduct
if we are in
an add-to-cart flow.populateIncludedProduct
in interface IncludedProductConfigurationService
cartItem
- The CartItem
for which to populate the IncludedProduct
.includedProduct
- The IncludedProduct
we are populating.potentialDependentItems
- The list of CartItem.getDependentCartItems()
to pick
from to find a match for the IncludedProduct
.isAdd
- Whether we are in an add-to-cart flow, which dictates whether to add an
unmatched IncludedProduct
.protected Optional<com.broadleafcommerce.cart.client.domain.CartItem> findDependentMatchingIncludedProduct(@NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull @NonNull IncludedProduct includedProduct)
protected Optional<com.broadleafcommerce.cart.client.domain.CartItem> findMatchingProduct(@NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull @NonNull IncludedProduct includedProduct)
protected Optional<com.broadleafcommerce.cart.client.domain.CartItem> findMatchingVariant(@NonNull @NonNull List<com.broadleafcommerce.cart.client.domain.CartItem> dependentCartItems, @NonNull @NonNull IncludedProduct includedProduct)
protected com.broadleafcommerce.cart.client.domain.CartItem createDependentItem(@NonNull @NonNull IncludedProduct includedProduct)
protected String getIncludedProductName(@NonNull @NonNull IncludedProduct includedProduct)
IncludedProduct
to use for a CartItem
. This
defaults to the label, but if not present it will defer to the specific Variant or Product's
name.includedProduct
- the IncludedProduct
for which to determine a nameIncludedProduct
to use for a CartItem
protected javax.money.MonetaryAmount getIncludedItemUnitPrice(@NonNull @NonNull IncludedProduct includedProduct)
IncludedProduct
to use for a CartItem
. This
defaults to the overridePrice, but if not present it will defer to the specific Variant or
Product's price.includedProduct
- the IncludedProduct
for which to determine a unitPriceIncludedProduct
to use for a CartItem
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)
IncludedProductConfigurationService
CartItem
for the given
IncludedProduct
.validateIncludedProduct
in interface IncludedProductConfigurationService
cartItem
- The CartItem
to perform included product
validation against.includedProduct
- The IncludedProduct
we are using to validate the cart against.potentialDependentItems
- The list of dependent cart items
to pick from
when validating IncludedProduct
.protected void validateQuantity(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @Nullable com.broadleafcommerce.cart.client.domain.CartItem matchingCartItem, @NonNull @NonNull IncludedProduct includedProduct)
protected String getMessage(@NonNull @NonNull String errorMessage, @Nullable Object... args)
protected void addItemConfigError(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull @NonNull IncludedProduct includedProduct, @NonNull @NonNull String errorCode, @NonNull @NonNull String errorMessage)
protected org.springframework.context.MessageSource getMessageSource()
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
Copyright © 2021. All rights reserved.