com.elasticpath.domain.rules
Interface PromotionRuleDelegate

All Superinterfaces:
EpDomain, Persistence, java.io.Serializable, ValueObject
All Known Implementing Classes:
PromotionRuleDelegateImpl

public interface PromotionRuleDelegate
extends ValueObject

This interface provides helper methods that can be invoked from Drools code to make queries on the system. The intent of this interface/implementation is to move as much logic as possible out of the rule code so that the drools code is as simple as possible. Note: If rules require a helper method that would be useful to other domain objects, move the helper/convenience method to the domain model rather than implementing it here.


Method Summary
 void applyCartSkuDiscountAmount(ShoppingCart shoppingCart, long ruleId, java.lang.String skuCode, java.lang.String amount, int maxItems, java.lang.String exceptionStr)
          Apply a discount amount to a product in the cart.
 void applyCartSkuDiscountPercent(ShoppingCart shoppingCart, long ruleId, java.lang.String skuCode, java.lang.String percent, int maxItems, java.lang.String exceptionStr)
          Apply a discount amount to a product in the cart.
 void applyCatalogProductDiscountAmount(ShoppingCart shoppingCart, long ruleId, Product product, java.util.Currency currency, java.lang.String amount, java.lang.String exceptionStr)
          Reduces the price of a product by the specified amount.
 void applyCatalogSkuDiscountAmount(ShoppingCart shoppingCart, long ruleId, Product product, java.lang.String skuCode, java.util.Currency currency, java.lang.String amount)
          Reduces the price of a sku by the specified amount.
 void applyCatalogSkuDiscountPercent(ShoppingCart shoppingCart, long ruleId, Product product, java.lang.String skuCode, java.util.Currency currency, java.lang.String percent)
          Reduces the price of a sku by the specified amount.
 void applyNFreeSkus(ShoppingCart shoppingCart, long ruleId, java.lang.String skuCode, int numSkus)
          Add N items of a product to the cart at a zero price.
 void applyNthProductDiscountPercent(ShoppingCart shoppingCart, long ruleId, long productId, java.lang.String percent, int nthItem, java.lang.String exceptionStr)
          Apply a percentage discount to the Nth item of a given product in the cart.
 void applyOrderCategoryDiscountAmount(ShoppingCart shoppingCart, long ruleId, long categoryId, java.lang.String amount, int maxItems, java.lang.String exceptionStr)
          Apply a discount amount to all items in a particular category in the cart.
 void applyOrderCategoryDiscountPercent(ShoppingCart shoppingCart, long ruleId, long categoryId, java.lang.String percent, int maxItems, java.lang.String exceptionStr)
          Apply a percentage discount to all items in a particular category in the cart.
 void applyOrderDiscountAmount(ShoppingCart shoppingCart, long ruleId, java.lang.String amount)
          Reduces the subtotal of the shopping cart by the specified amount.
 void applyOrderDiscountPercent(ShoppingCart shoppingCart, long ruleId, java.lang.String percent)
          Reduces the subtotal of the shopping cart by the specified percent.
 void applyProductDiscountAmount(ShoppingCart shoppingCart, long ruleId, long productId, java.lang.String amount, int maxItems, java.lang.String exceptionStr)
          Apply a discount amount to a product in the cart.
 void applyProductDiscountPercent(ShoppingCart shoppingCart, long ruleId, long productId, java.lang.String percent, int maxItems, java.lang.String exceptionStr)
          Apply a percentage discount to a product in the cart.
 void applyProductDiscountPercent(ShoppingCart shoppingCart, long ruleId, Product product, java.util.Currency currency, java.lang.String percent, java.lang.String exceptionStr)
          Reduces the price of a product by the specified amount.
 void applyShippingDiscountAmount(ShoppingCart shoppingCart, long ruleId, java.lang.String amount, long shippingMethodId)
          Reduces the shipping cost of the shopping cart by the specified amount.
 void applyShippingDiscountPercent(ShoppingCart shoppingCart, long ruleId, java.lang.String percent, long shippingMethodId)
          Reduces the shipping cost of the shopping cart by the specified percent.
 boolean cartContainsItemsOfCategory(ShoppingCart shoppingCart, long categoryId, int numItems, java.lang.String exceptionStr)
          Checks if the shopping cart contains the specified quantity of items of the given product.
 boolean cartContainsProduct(ShoppingCart shoppingCart, long productId, int quantity, java.lang.String exceptionStr)
          Checks if the shopping cart contains the specified quantity of items of the given product.
 boolean cartContainsSku(ShoppingCart shoppingCart, java.lang.String skuCode, int quantity)
          Checks if the shopping cart contains the specified quantity of items with the specified sku code.
 boolean cartCurrencyMatches(ShoppingCart shoppingCart, java.lang.String currencyCode)
          Checks if the currency of a shopping cart matches the specified currency code.
 boolean cartHasPromoCode(ShoppingCart shoppingCart, java.lang.String promoCode)
          Checks if the shopping cart has the specified promo code entered by the user.
 boolean cartSubtotalExceeds(ShoppingCart shoppingCart, java.lang.String amount, java.lang.String exceptionStr)
          Checks if the shopping cart subtotal exceeds the specified amount.
 boolean catalogBrandIs(Product product, boolean isBrand, java.lang.String brandCode, java.lang.String exceptionStr)
          Returns true if the given product is/is not of the specified brand.
 boolean catalogProductInCategory(Product product, boolean isIn, long categoryUid, java.lang.String exceptionStr)
          Checks if the given product is in the category with the specified categoryID.
 boolean catalogProductIs(Product product, boolean isProduct, long productUid, java.lang.String exceptionStr)
          Returns true if the given product is/is not the product with the specified Id.
 boolean checkDateRange(java.lang.String startDateString, java.lang.String endDateString)
          Checks that the current date is between the specified dates.
 boolean customerInGroup(ShoppingCart shoppingCart, long customerGroup)
          Checks if the customer is in the specified customer group.
 boolean isExistingCustomer(ShoppingCart shoppingCart)
          Checks if the customer already has an account in the system.
 boolean isFirstTimeBuyer(ShoppingCart shoppingCart)
          Checks if the customer is a first time buyer.
 
Methods inherited from interface com.elasticpath.domain.Persistence
executeBeforePersistAction, getUidPk, isPersistent, setDefaultValues, setUidPk
 
Methods inherited from interface com.elasticpath.domain.EpDomain
getElasticPath, setElasticPath
 

Method Detail

applyCartSkuDiscountAmount

void applyCartSkuDiscountAmount(ShoppingCart shoppingCart,
                                long ruleId,
                                java.lang.String skuCode,
                                java.lang.String amount,
                                int maxItems,
                                java.lang.String exceptionStr)
Apply a discount amount to a product in the cart.

Parameters:
shoppingCart - the shopping cart to have a discounted
ruleId - the id of the rule executing this action
skuCode - the sku code of the sku to be discounted
amount - the amount of the discount
maxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.

applyCartSkuDiscountPercent

void applyCartSkuDiscountPercent(ShoppingCart shoppingCart,
                                 long ruleId,
                                 java.lang.String skuCode,
                                 java.lang.String percent,
                                 int maxItems,
                                 java.lang.String exceptionStr)
Apply a discount amount to a product in the cart.

Parameters:
shoppingCart - the shopping cart to have a discounted
ruleId - the id of the rule executing this action
skuCode - the sku code of the sku to be discounted
percent - the percentage of the promotion X 100 (e.g. 50 means 50% off).
maxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.

applyCatalogProductDiscountAmount

void applyCatalogProductDiscountAmount(ShoppingCart shoppingCart,
                                       long ruleId,
                                       Product product,
                                       java.util.Currency currency,
                                       java.lang.String amount,
                                       java.lang.String exceptionStr)
Reduces the price of a product by the specified amount.

Parameters:
shoppingCart - the customer's shopping cart
ruleId - the id of the rule executing this action
product - the product to be discounted
currency - the Currency of the price to be reduced
amount - the percentage of the promotion X 100 (e.g. 50 means 50% off).
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.

applyCatalogSkuDiscountAmount

void applyCatalogSkuDiscountAmount(ShoppingCart shoppingCart,
                                   long ruleId,
                                   Product product,
                                   java.lang.String skuCode,
                                   java.util.Currency currency,
                                   java.lang.String amount)
Reduces the price of a sku by the specified amount.

Parameters:
shoppingCart - the customer's shopping cart
ruleId - the id of the rule executing this action
product - the product containing the SKU to be discounted
skuCode - the SKU code for the sku to be discounted
currency - the Currency of the price to be reduced
amount - the percentage of the promotion X 100 (e.g. 50 means 50% off).

applyCatalogSkuDiscountPercent

void applyCatalogSkuDiscountPercent(ShoppingCart shoppingCart,
                                    long ruleId,
                                    Product product,
                                    java.lang.String skuCode,
                                    java.util.Currency currency,
                                    java.lang.String percent)
Reduces the price of a sku by the specified amount.

Parameters:
shoppingCart - the customer's shopping cart
ruleId - the id of the rule executing this action
product - the product containing the SKU to be discounted
skuCode - the SKU code for the sku to be discounted
currency - the Currency of the price to be reduced
percent - the percentage of the promotion X 100 (e.g. 50 means 50% off).

applyNFreeSkus

void applyNFreeSkus(ShoppingCart shoppingCart,
                    long ruleId,
                    java.lang.String skuCode,
                    int numSkus)
Add N items of a product to the cart at a zero price.

Parameters:
shoppingCart - the shopping cart to have products discounted
ruleId - the id of the rule executing this action
skuCode - the sku code of the sku to be added to the cart
numSkus - the number of items to give for free

applyNthProductDiscountPercent

void applyNthProductDiscountPercent(ShoppingCart shoppingCart,
                                    long ruleId,
                                    long productId,
                                    java.lang.String percent,
                                    int nthItem,
                                    java.lang.String exceptionStr)
Apply a percentage discount to the Nth item of a given product in the cart.

Parameters:
shoppingCart - the shopping cart to have products discounted
ruleId - the id of the rule executing this action
productId - the id of the product to be discounted
percent - the percentage of the promotion X 100 (e.g. 50 means 50% off, 100 means free).
nthItem - the number of items that must be present before one is discounted
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.

applyOrderCategoryDiscountAmount

void applyOrderCategoryDiscountAmount(ShoppingCart shoppingCart,
                                      long ruleId,
                                      long categoryId,
                                      java.lang.String amount,
                                      int maxItems,
                                      java.lang.String exceptionStr)
Apply a discount amount to all items in a particular category in the cart.

Parameters:
shoppingCart - the shopping cart to have items in a category discounted
ruleId - the id of the rule executing this action
categoryId - the id of the category that the promotion applies to
amount - the amount by which the price is to be reduced
maxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.

applyOrderCategoryDiscountPercent

void applyOrderCategoryDiscountPercent(ShoppingCart shoppingCart,
                                       long ruleId,
                                       long categoryId,
                                       java.lang.String percent,
                                       int maxItems,
                                       java.lang.String exceptionStr)
Apply a percentage discount to all items in a particular category in the cart.

Parameters:
shoppingCart - the shopping cart to have items in a category discounted
ruleId - the id of the rule executing this action
categoryId - the id of the category that the promotion applies to
percent - the percentage of the promotion X 100 (e.g. 50 means 50% off).
maxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.

applyOrderDiscountAmount

void applyOrderDiscountAmount(ShoppingCart shoppingCart,
                              long ruleId,
                              java.lang.String amount)
Reduces the subtotal of the shopping cart by the specified amount.

Parameters:
shoppingCart - the shopping cart that the discount is to be applied to
ruleId - the id of the rule executing this action
amount - the amount by which to reduce the subtotal

applyOrderDiscountPercent

void applyOrderDiscountPercent(ShoppingCart shoppingCart,
                               long ruleId,
                               java.lang.String percent)
Reduces the subtotal of the shopping cart by the specified percent.

Parameters:
shoppingCart - the shopping cart that the discount is to be applied to
ruleId - the id of the rule executing this action
percent - the percent by which to reduce the subtotal

applyProductDiscountAmount

void applyProductDiscountAmount(ShoppingCart shoppingCart,
                                long ruleId,
                                long productId,
                                java.lang.String amount,
                                int maxItems,
                                java.lang.String exceptionStr)
Apply a discount amount to a product in the cart.

Parameters:
shoppingCart - the shopping cart to have a discounted
ruleId - the id of the rule executing this action
productId - the id of the product to be discounted
amount - the amount of the discount
maxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.

applyProductDiscountPercent

void applyProductDiscountPercent(ShoppingCart shoppingCart,
                                 long ruleId,
                                 long productId,
                                 java.lang.String percent,
                                 int maxItems,
                                 java.lang.String exceptionStr)
Apply a percentage discount to a product in the cart.

Parameters:
shoppingCart - the shopping cart to have a discounted
ruleId - the id of the rule executing this action
productId - the id of the product to be discounted
percent - the percentage of the promotion X 100 (e.g. 50 means 50% off, 100 means free).
maxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.

applyProductDiscountPercent

void applyProductDiscountPercent(ShoppingCart shoppingCart,
                                 long ruleId,
                                 Product product,
                                 java.util.Currency currency,
                                 java.lang.String percent,
                                 java.lang.String exceptionStr)
Reduces the price of a product by the specified amount.

Parameters:
shoppingCart - the customer's shopping cart
ruleId - the id of the rule executing this action
product - the product to be discounted
currency - the Currency of the price to be reduced
percent - the amount that the price should be reduced
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.

applyShippingDiscountAmount

void applyShippingDiscountAmount(ShoppingCart shoppingCart,
                                 long ruleId,
                                 java.lang.String amount,
                                 long shippingMethodId)
Reduces the shipping cost of the shopping cart by the specified amount. (If the specified shipping method is in use)

Parameters:
shoppingCart - the shopping cart that the shipping discount is to be applied to
ruleId - the id of the rule executing this action
amount - the amount by which to reduce the shipping cost
shippingMethodId - the shipping method that this discount applies to

applyShippingDiscountPercent

void applyShippingDiscountPercent(ShoppingCart shoppingCart,
                                  long ruleId,
                                  java.lang.String percent,
                                  long shippingMethodId)
Reduces the shipping cost of the shopping cart by the specified percent. (If the specified shipping method is in use)

Parameters:
shoppingCart - the shopping cart that the shipping discount is to be applied to
ruleId - the id of the rule executing this action
percent - the percent by which to reduce the shipping cost (String value from 1 to 100)
shippingMethodId - the shipping method that this discount applies to

cartContainsItemsOfCategory

boolean cartContainsItemsOfCategory(ShoppingCart shoppingCart,
                                    long categoryId,
                                    int numItems,
                                    java.lang.String exceptionStr)
Checks if the shopping cart contains the specified quantity of items of the given product.

Parameters:
shoppingCart - the shopping cart to check
categoryId - the category id that must be in the cart
numItems - the minimum quantity of items of the category that must be present
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
Returns:
true if there are quantity items with productId in the cart

cartContainsProduct

boolean cartContainsProduct(ShoppingCart shoppingCart,
                            long productId,
                            int quantity,
                            java.lang.String exceptionStr)
Checks if the shopping cart contains the specified quantity of items of the given product.

Parameters:
shoppingCart - the shopping cart to check
productId - the sku code that must be in the cart
quantity - the minimum quantity of the product that must be present
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
Returns:
true if there are quantity items with productId in the cart

cartContainsSku

boolean cartContainsSku(ShoppingCart shoppingCart,
                        java.lang.String skuCode,
                        int quantity)
Checks if the shopping cart contains the specified quantity of items with the specified sku code.

Parameters:
shoppingCart - the shopping cart to check
skuCode - the sku code that must be in the cart
quantity - the minimum quantity of the sku that must be present
Returns:
true if there are quantity items with skuCode in the cart

cartCurrencyMatches

boolean cartCurrencyMatches(ShoppingCart shoppingCart,
                            java.lang.String currencyCode)
Checks if the currency of a shopping cart matches the specified currency code.

Parameters:
shoppingCart - The shopping cart to check
currencyCode - The currency code, e.g. CAD
Returns:
true if the cart currency code matches the supplied code

cartHasPromoCode

boolean cartHasPromoCode(ShoppingCart shoppingCart,
                         java.lang.String promoCode)
Checks if the shopping cart has the specified promo code entered by the user. This will also notify the cart if the cart if the specified promo code matches the parameter.

Parameters:
shoppingCart - the shopping cart to check for the promo code
promoCode - the promo code to check for.
Returns:
returns true if the shopping cart has the specified promo code

cartSubtotalExceeds

boolean cartSubtotalExceeds(ShoppingCart shoppingCart,
                            java.lang.String amount,
                            java.lang.String exceptionStr)
Checks if the shopping cart subtotal exceeds the specified amount.

Parameters:
shoppingCart - the shopping cart to check
amount - the amount the shopping cart must exceed
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
Returns:
true if the shopping cart subtotal is greater than the specified amount

catalogBrandIs

boolean catalogBrandIs(Product product,
                       boolean isBrand,
                       java.lang.String brandCode,
                       java.lang.String exceptionStr)
Returns true if the given product is/is not of the specified brand.

Parameters:
product - the product whose condition is to be checked
isBrand - set to true to check that the brand is the one with the specified Id, or false to check that it is not the brand with the specified id.
brandCode - the code of the brand to check for
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
Returns:
true if the product is of the specified brand

catalogProductInCategory

boolean catalogProductInCategory(Product product,
                                 boolean isIn,
                                 long categoryUid,
                                 java.lang.String exceptionStr)
Checks if the given product is in the category with the specified categoryID.

Parameters:
product - the product
isIn - set to true to specify that the product is in the category, false to require that it isn't in the category
categoryUid - the id of the category to check if the product is in it
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
Returns:
true if the product is in the category or one of its children.

catalogProductIs

boolean catalogProductIs(Product product,
                         boolean isProduct,
                         long productUid,
                         java.lang.String exceptionStr)
Returns true if the given product is/is not the product with the specified Id.

Parameters:
product - the product whose condition is to be checked
isProduct - set to true to check that the product is the one with the specified Id, or false to check that it is not the product with the specified id.
productUid - the id of the product to check for
exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
Returns:
true if the product is in the category or one of its children.

checkDateRange

boolean checkDateRange(java.lang.String startDateString,
                       java.lang.String endDateString)
Checks that the current date is between the specified dates.

Parameters:
startDateString - the start date represented as a long (milliseconds) in a string. 0 means no start date restriction on the date range.
endDateString - the end date represented as a long (milliseconds) in a string. 0 means no end date. Longs are not supported by Drools so the dates are passed as strings.
Returns:
true if the current date is between the specified dates

customerInGroup

boolean customerInGroup(ShoppingCart shoppingCart,
                        long customerGroup)
Checks if the customer is in the specified customer group.

Parameters:
shoppingCart - the shopping cart containing a reference to the customer
customerGroup - the customer group that the customer must belong to
Returns:
true if the customer belongs to the specified group

isExistingCustomer

boolean isExistingCustomer(ShoppingCart shoppingCart)
Checks if the customer already has an account in the system.

Parameters:
shoppingCart - the shopping cart containing a reference to the customer
Returns:
true if the customer already has an account in the system.

isFirstTimeBuyer

boolean isFirstTimeBuyer(ShoppingCart shoppingCart)
Checks if the customer is a first time buyer. A first time buyer is a customer whose email address has not been used in any existing orders.

Parameters:
shoppingCart - the shopping cart containing a reference to the customer
Returns:
true if the customer is a first time buyer