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 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 the 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.
      Specified by:
      populateIncludedProduct in interface IncludedProductConfigurationService
      Parameters:
      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.
    • isDiscountable

      protected boolean isDiscountable(IncludedProduct includedProduct)
    • 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

      protected String getIncludedProductName(@NonNull @NonNull IncludedProduct includedProduct)
      Returns the "name" of the 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.
      Parameters:
      includedProduct - the IncludedProduct for which to determine a name
      Returns:
      the "name" of the IncludedProduct to use for a CartItem
    • getIncludedItemUnitPrice

      protected javax.money.MonetaryAmount getIncludedItemUnitPrice(@NonNull @NonNull IncludedProduct includedProduct)
      Returns the "unitPrice" of the 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.
      Parameters:
      includedProduct - the IncludedProduct for which to determine a unitPrice
      Returns:
      the "unitPrice" of the IncludedProduct to use for a CartItem
    • 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 provided CartItem for the given IncludedProduct.
      Specified by:
      validateIncludedProduct in interface IncludedProductConfigurationService
      Parameters:
      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.
    • 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

      protected String getMessage(@NonNull @NonNull String errorMessage, @Nullable Object... args)
    • 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()
    • getConfigurationProperties

      protected CartItemConfigurationProperties getConfigurationProperties()
    • setConfigurationProperties

      @Autowired public void setConfigurationProperties(CartItemConfigurationProperties configurationProperties)