Interface BundleRuleService

  • All Known Implementing Classes:
    DefaultBundleCommerceRuleService, DefaultBundleRuleService

    public interface BundleRuleService
    Commerce service that exposes methods to find a matching rule for the product price ChangeProductPriceBundleRuleModel or information about whether it is disabled DisableProductBundleRuleModel when part of a bundle. The rules are depending on the other products in the same bundle in the cart or newly products to add. These are the different ways on how to find a rule:
    • provisioning the rule based on two products that are not yet in the cart
    • finding the rule based only on products already in the cart in a bundle
    • combination of both: provisioning the rule based on an existing bundle in the cart and a new additional product
    • Method Detail

      • getChangePriceBundleRuleForOrderEntry

        @Nullable
        ChangeProductPriceBundleRuleModel getChangePriceBundleRuleForOrderEntry​(@Nonnull
                                                                                AbstractOrderEntryModel orderEntryModel)
        Returns a ChangeProductPriceBundleRuleModel valid for the given orderEntryModel. The method calculates the lowest product price for the product in the given orderEntryModel which is added to a bundle. The calculation is based on the entry's bundle template and the other products in the same bundle (conditional products)
        Parameters:
        orderEntryModel - entry that is added to the cart as part of a bundle
        Returns:
        a ChangeProductPriceBundleRuleModel if existing or null
      • getChangePriceBundleRule

        @Nullable
        ChangeProductPriceBundleRuleModel getChangePriceBundleRule​(@Nonnull
                                                                   BundleTemplateModel targetComponent,
                                                                   @Nonnull
                                                                   ProductModel targetProduct,
                                                                   @Nonnull
                                                                   ProductModel conditionalProduct,
                                                                   @Nonnull
                                                                   CurrencyModel currency)
        Returns a ChangeProductPriceBundleRuleModel valid for the given targetProduct. The method calculates (forecasts) the lowest product price for the given targetProduct which shall be added to a bundle based on the given bundle template (targetComponent) in combination with the given conditionalProduct. The bundle or a cart to which the given products should be added may or may not yet exist. The method just forecasts the possible price for the given combination of input parameters.
        Parameters:
        targetComponent - bundle template based on which the given targetProduct is or shall be added to a bundle
        targetProduct - product that is added to a bundle and for which the product price is calculated
        conditionalProduct - second product that is added to the same bundle as the given targetProduct and that is the condition for a ChangeProductPriceBundleRuleModel to be selected
        currency - the currency the ChangeProductPriceBundleRuleModel must match to be selected
        Returns:
        a ChangeProductPriceBundleRuleModel if existing or null
      • getDisableRuleForBundleProduct

        @Nullable
        DisableProductBundleRuleModel getDisableRuleForBundleProduct​(@Nonnull
                                                                     BundleTemplateModel bundleTemplate,
                                                                     @Nonnull
                                                                     ProductModel product1,
                                                                     @Nonnull
                                                                     ProductModel product2)
        Returns a DisableProductBundleRuleModel which does not allow that the given products product1 and product2 are added together to a bundle. In case no such disable rule exists null is returned.
        Parameters:
        bundleTemplate - bundle template based on which the given targetProduct and conditionalProduct shall be added to the bundle
        product1 - first product that shall be added to the bundle
        product2 - second product that shall be added to the bundle
        Returns:
        the first DisableProductBundleRuleModel that is found which means that the given product1 and product2 cannot be added together to the bundle in the cart. null if no DisableProductBundleRuleModel applies and the products can be added to the bundle.
      • createMessageForDisableRule

        java.lang.String createMessageForDisableRule​(DisableProductBundleRuleModel disableRule,
                                                     ProductModel product)
        Generates the message explaining why given product is disabled with specific rule.
        Parameters:
        disableRule - DisableProductBundleRuleModel which disabled given product for specific conditional products
        product - Disabled product
        Returns:
        Message about the disable rule for given product
      • getDisableRuleForBundleProduct

        @Nullable
        DisableProductBundleRuleModel getDisableRuleForBundleProduct​(@Nonnull
                                                                     AbstractOrderModel masterAbstractOrder,
                                                                     @Nonnull
                                                                     ProductModel product,
                                                                     @Nonnull
                                                                     EntryGroup entryGroup,
                                                                     boolean ignoreCurrentProducts)
        Returns a DisableProductBundleRuleModel valid for the given product ignoring products ignoreProducts in the cart. The method searches for DisableProductBundleRuleModel's that can be applied if the given product is or would be added to the given masterAbstractOrder in the context of the given entryGroup and bundleTemplate.
        Parameters:
        masterAbstractOrder - the master cart/order to which the given product is added
        product - product that is or shall be added to the bundle and for which applicable DisableProductBundleRuleModel's are searched
        entryGroup - entry group based on which the given product is or shall be added to the bundle
        ignoreCurrentProducts - if the products in the current bundletemplate should be ignored
        Returns:
        the first DisableProductBundleRuleModel that is found which means that the given product cannot be added to the bundle in the cart. null if no DisableProductBundleRuleModel applies and the product can be added to the bundle.