Interface CartItemConfigurationService

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Variant determineVariant​(@NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem, @NonNull Product product)
      Attempt to determine the variant by the requested variant ID on the CartItem.
      void hydrateIncludedProductDependentItems​(com.broadleafcommerce.cart.client.domain.CartItem cartItem, List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, Product product, boolean isAdd)
      Populate IncludedProduct information on CartItem.getDependentCartItems() based on the product configuration.
      void hydrateItemChoiceDependentItems​(com.broadleafcommerce.cart.client.domain.CartItem cartItem, List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems, Product product)
      Populate ItemChoice information on CartItem.getDependentCartItems() based on the product configuration.
      void validateCartItem​(com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.cart.client.domain.CartItem cartItem, Product product, String validationFlow)
      Process cart item configuration by validating product options.
    • Method Detail

      • determineVariant

        @Nullable
        Variant determineVariant​(@NonNull
                                 @NonNull com.broadleafcommerce.cart.client.domain.CartItem cartItem,
                                 @NonNull
                                 @NonNull Product product)
        Attempt to determine the variant by the requested variant ID on the CartItem. Otherwise, if any of the Product's Options are marked as ProductOptionType.VARIANT_DISTINGUISHING, we need to determine the Variant for the CartItem using the CartItem.getAttributeChoices().
        Parameters:
        cartItem - The cart item to determine the variant for.
        product - The Product containing options and variants.
      • hydrateIncludedProductDependentItems

        void hydrateIncludedProductDependentItems​(com.broadleafcommerce.cart.client.domain.CartItem cartItem,
                                                  List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems,
                                                  Product product,
                                                  boolean isAdd)
        Populate IncludedProduct information on CartItem.getDependentCartItems() based on the product configuration.
        Parameters:
        cartItem - The cart item on which to populate dependent item product configuration information.
        potentialDependentItems - The list of CartItem.getDependentCartItems() to pick from to find a match for an IncludedProduct.
        product - The product with configuration to be used for hydration.
        isAdd - Whether we are in an add-to-cart flow
      • hydrateItemChoiceDependentItems

        void hydrateItemChoiceDependentItems​(com.broadleafcommerce.cart.client.domain.CartItem cartItem,
                                             List<com.broadleafcommerce.cart.client.domain.CartItem> potentialDependentItems,
                                             Product product)
        Populate ItemChoice information on CartItem.getDependentCartItems() based on the product configuration.
        Parameters:
        cartItem - The cart item on which to populate dependent item product configuration information.
        potentialDependentItems - The list of CartItem.getDependentCartItems() to pick from to find a match for an ItemChoice.
        product - The product with configuration to be used for hydration.
      • validateCartItem

        void validateCartItem​(com.broadleafcommerce.cart.client.domain.Cart cart,
                              com.broadleafcommerce.cart.client.domain.CartItem cartItem,
                              Product product,
                              String validationFlow)
        Process cart item configuration by validating product options. Errors for the item will be recorded into CartItem.getGlobalConfigErrors(), while errors for specific attributes will be recorded into CartItem.getAttributeConfigErrors(). For hierarchical cart items (items with CartItem.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 as CartItemConfigurationErrorEnum.MISCONFIGURED_DEPENDENT_ITEMS on CartItem.getGlobalConfigErrors().
        Parameters:
        cart - The cart with the cart item
        cartItem - The cart item with which to process configuration.
        validationFlow - The context used to identify validation requirements of the CartItem at that point in its lifecycle. If this is set to ValidationStrategy.ADD_ITEM, then the configuration service will try to