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 Summary
Modifier and TypeMethodDescriptioncreateMessageForDisableRule(DisableProductBundleRuleModel disableRule, ProductModel product) Generates the message explaining why given product is disabled with specific rule.getChangePriceBundleRule(BundleTemplateModel targetComponent, ProductModel targetProduct, ProductModel conditionalProduct, CurrencyModel currency) Returns aChangeProductPriceBundleRuleModelvalid for the giventargetProduct.getChangePriceBundleRuleForOrderEntry(AbstractOrderEntryModel orderEntryModel) Returns aChangeProductPriceBundleRuleModelvalid for the givenorderEntryModel.getChangePriceBundleRuleWithLowestPrice(ProductModel targetProduct, CurrencyModel currency) Searches for the lowest priceChangeProductPriceBundleRuleModelof the giventargetProductin any bundle packagegetDisableProductBundleRules(ProductModel product, EntryGroup entryGroup, AbstractOrderModel order) getDisableRuleForBundleProduct(BundleTemplateModel bundleTemplate, ProductModel product1, ProductModel product2) Returns aDisableProductBundleRuleModelwhich does not allow that the given productsproduct1andproduct2are added together to a bundle.getDisableRuleForBundleProduct(AbstractOrderModel masterAbstractOrder, ProductModel product, EntryGroup entryGroup, boolean ignoreCurrentProducts) Returns aDisableProductBundleRuleModelvalid for the givenproductignoring productsignoreProductsin the cart.
-
Method Details
-
getChangePriceBundleRuleForOrderEntry
@Nullable ChangeProductPriceBundleRuleModel getChangePriceBundleRuleForOrderEntry(@Nonnull AbstractOrderEntryModel orderEntryModel) Returns aChangeProductPriceBundleRuleModelvalid for the givenorderEntryModel. The method calculates the lowest product price for the product in the givenorderEntryModelwhich 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
ChangeProductPriceBundleRuleModelif existing or null
-
getChangePriceBundleRule
@Nullable ChangeProductPriceBundleRuleModel getChangePriceBundleRule(@Nonnull BundleTemplateModel targetComponent, @Nonnull ProductModel targetProduct, @Nonnull ProductModel conditionalProduct, @Nonnull CurrencyModel currency) Returns aChangeProductPriceBundleRuleModelvalid for the giventargetProduct. The method calculates (forecasts) the lowest product price for the giventargetProductwhich shall be added to a bundle based on the given bundle template (targetComponent) in combination with the givenconditionalProduct. 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 giventargetProductis or shall be added to a bundletargetProduct- product that is added to a bundle and for which the product price is calculatedconditionalProduct- second product that is added to the same bundle as the giventargetProductand that is the condition for aChangeProductPriceBundleRuleModelto be selectedcurrency- the currency theChangeProductPriceBundleRuleModelmust match to be selected- Returns:
- a
ChangeProductPriceBundleRuleModelif existing or null
-
getDisableRuleForBundleProduct
@Nullable DisableProductBundleRuleModel getDisableRuleForBundleProduct(@Nonnull BundleTemplateModel bundleTemplate, @Nonnull ProductModel product1, @Nonnull ProductModel product2) Returns aDisableProductBundleRuleModelwhich does not allow that the given productsproduct1andproduct2are added together to a bundle. In case no such disable rule existsnullis returned.- Parameters:
bundleTemplate- bundle template based on which the giventargetProductandconditionalProductshall be added to the bundleproduct1- first product that shall be added to the bundleproduct2- second product that shall be added to the bundle- Returns:
- the first
DisableProductBundleRuleModelthat is found which means that the givenproduct1andproduct2cannot be added together to the bundle in the cart.nullif noDisableProductBundleRuleModelapplies and the products can be added to the bundle.
-
getChangePriceBundleRuleWithLowestPrice
@Nullable ChangeProductPriceBundleRuleModel getChangePriceBundleRuleWithLowestPrice(@Nonnull ProductModel targetProduct, @Nonnull CurrencyModel currency) Searches for the lowest priceChangeProductPriceBundleRuleModelof the giventargetProductin any bundle package- Parameters:
targetProduct- the product for which the lowest bundle price is searchedcurrency- the currency theChangeProductPriceBundleRuleModelmust match to be selected- Returns:
ChangeProductPriceBundleRuleModelif existing or null
-
createMessageForDisableRule
Generates the message explaining why given product is disabled with specific rule.- Parameters:
disableRule-DisableProductBundleRuleModelwhich disabled given product for specific conditional productsproduct- Disabled product- Returns:
- Message about the disable rule for given product
-
getDisableProductBundleRules
List<DisableProductBundleRuleModel> getDisableProductBundleRules(ProductModel product, EntryGroup entryGroup, AbstractOrderModel order) Returns a list ofDisableProductBundleRuleModelvalid for the givenproductin the givenorder. The method searches forDisableProductBundleRuleModels that can be applied if the givenproductis or would be added to the givenorderin the context of the givenentryGroup.- Parameters:
product- product that is or shall be added to the bundle and for which applicableDisableProductBundleRuleModels are searchedentryGroup- entry group representing a bundle to which theproductis or shall be addedorder- the cart/order to which the givenproductis added- Returns:
- the list of
DisableProductBundleRuleModelwhich are blocking addingproductcannot be added to the bundle in the cart.
-
getDisableRuleForBundleProduct
@Nullable DisableProductBundleRuleModel getDisableRuleForBundleProduct(@Nonnull AbstractOrderModel masterAbstractOrder, @Nonnull ProductModel product, @Nonnull EntryGroup entryGroup, boolean ignoreCurrentProducts) Returns aDisableProductBundleRuleModelvalid for the givenproductignoring productsignoreProductsin the cart. The method searches forDisableProductBundleRuleModel's that can be applied if the givenproductis or would be added to the givenmasterAbstractOrderin the context of the givenentryGroupandbundleTemplate.- Parameters:
masterAbstractOrder- the master cart/order to which the givenproductis addedproduct- product that is or shall be added to the bundle and for which applicableDisableProductBundleRuleModel's are searchedentryGroup- entry group based on which the givenproductis or shall be added to the bundleignoreCurrentProducts- if the products in the current bundletemplate should be ignored- Returns:
- the first
DisableProductBundleRuleModelthat is found which means that the givenproductcannot be added to the bundle in the cart.nullif noDisableProductBundleRuleModelapplies and the product can be added to the bundle.
-