com.konakart.blif
Interface PromotionMgrIf

All Known Implementing Classes:
PromotionMgr

public interface PromotionMgrIf

PromotionMgrIf Interface which an implementation of this manager must adhere to.


Method Summary
 int checkCoupon(java.lang.String couponCode)
          This method is used to verify whether a coupon code actually exists and if it does, whether the coupon is still active.
 Promotion[] getAllPromotions()
          Returns an array of all active promotions
 int getPromotionIdForGiftCertificate(OrderProductIf op)
          Get the promotion id for an order product object containing a gift certificate.
 Promotion[] getPromotions(java.lang.String orderTotalCode, Order order)
          We return all active promotions for the orderTotalCode passed in as a parameter.
 ProductIf[] getPromotionsPerProducts(java.lang.String sessionId, int customerId, ProductIf[] products, PromotionIf[] promotions, java.lang.String[] couponCodes, PromotionOptionsIf options)
          This method is used to calculate a discount on individual products so that the discount can be displayed without having to add the product to the cart.
The method receives an array of products and returns an array of products with attached PromotionResult objects that contain the results of one or more of the promotions passed in as a parameter.
 int insertCoupon(CouponIf coupon, int promotionId)
          Insert a coupon and associate it with the promotion referenced by promotionId.
 void refreshConfigs()
          Refresh the configuration of the Promotion manager
 void updatePromotionUsage(Order order)
          If the order has any associated coupons we iterate through the coupons and increment the timesUsed attribute.
 

Method Detail

getPromotions

Promotion[] getPromotions(java.lang.String orderTotalCode,
                          Order order)
                          throws java.lang.Exception
We return all active promotions for the orderTotalCode passed in as a parameter. The promotion may only apply for a subset of the products within the order so we return this information as an attribute of the Promotion object.

Parameters:
orderTotalCode -
order -
Returns:
An array of promotion objects
Throws:
java.lang.Exception

updatePromotionUsage

void updatePromotionUsage(Order order)
                          throws org.apache.torque.TorqueException,
                                 com.workingdogs.village.DataSetException
If the order has any associated coupons we iterate through the coupons and increment the timesUsed attribute. If the order has any associated promotions that were linked to the customer directly through the promotion_to_customer table, then we retrieve these records and increment the timesUsed attribute.

Parameters:
order -
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getPromotionIdForGiftCertificate

int getPromotionIdForGiftCertificate(OrderProductIf op)
                                     throws KKException,
                                            org.apache.torque.TorqueException,
                                            com.workingdogs.village.DataSetException
Get the promotion id for an order product object containing a gift certificate. A negative id is returned if a promotion doesn't exist.

Parameters:
op -
Returns:
Returns the id of the promotion or -1 if a promotion doesn't exist.
Throws:
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

insertCoupon

int insertCoupon(CouponIf coupon,
                 int promotionId)
                 throws java.lang.Exception
Insert a coupon and associate it with the promotion referenced by promotionId. If the promotionId is a negative number then no association is done.

Parameters:
coupon -
promotionId -
Returns:
Returns the coupon Id
Throws:
java.lang.Exception

checkCoupon

int checkCoupon(java.lang.String couponCode)
                throws com.workingdogs.village.DataSetException,
                       org.apache.torque.TorqueException
This method is used to verify whether a coupon code actually exists and if it does, whether the coupon is still active. Valid return values for this method are: Even if the coupon exists and is active, it won't actually do anything if it isn't connected to a valid promotion and any rules associated with the promotion are also satisfied. However, this method may still be used to at least warn a customer that he may have mistyped the coupon code or that it is no longer valid.

Parameters:
couponCode - The coupon code
Returns:
Returns an integer
Throws:
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException

getAllPromotions

Promotion[] getAllPromotions()
                             throws java.lang.Exception
Returns an array of all active promotions

Returns:
Returns an array of all active promotions
Throws:
java.lang.Exception

getPromotionsPerProducts

ProductIf[] getPromotionsPerProducts(java.lang.String sessionId,
                                     int customerId,
                                     ProductIf[] products,
                                     PromotionIf[] promotions,
                                     java.lang.String[] couponCodes,
                                     PromotionOptionsIf options)
                                     throws java.lang.Exception
This method is used to calculate a discount on individual products so that the discount can be displayed without having to add the product to the cart.
The method receives an array of products and returns an array of products with attached PromotionResult objects that contain the results of one or more of the promotions passed in as a parameter. The PromotionResult contains the value of the discount, whether it is an amount or a percentage discount and also information regarding the promotion it applies to. If a product has an array of ProductQuantity objects (one for each SKU) each one of these may have an array of PromotionResult objects since a promotion may only apply to one product configuration and not to another (i.e. blue shirt and not red shirt).
The PromotionOptions object can be configured so that the values of the promotions for a product are subtracted from the product price. The options allow you to set rules that determine whether in this case the promotions need to be cumulative or whether the largest or smallest should be chosen. The calculation is only made for products with a single array of PromotionResult objects. It is not calculated for products that have an array of PromotionResult objects for each ProductQuantity.

Parameters:
sessionId - Only used if the customer is logged in. Otherwise set to null.
customerId - If the sessionId is set to null then the customerId should contain the id of the temporary user which is a negative number. The temporary user id can be used for evaluating expression rules.
products - An array of products to be processed
promotions - The promotions which will be applied to the products if all rules are matched.
couponCodes - Coupon codes to use. If none of the promotions require coupons, it should be set to null
options - An object containing information to configure the calculation for applying one or more promotion results to the product price.
Returns:
Returns the same array of products passed in as a parameter with attached PromotionResult objects if applicable
Throws:
java.lang.Exception

refreshConfigs

void refreshConfigs()
                    throws java.lang.Exception
Refresh the configuration of the Promotion manager

Throws:
java.lang.Exception


Copyright © 2011 DS Data Systems UK Ltd.