com.ibm.commerce.marketing.promotion.reward

Class FreePurchasableGiftAdjustment

  • java.lang.Object
    • com.ibm.commerce.marketing.promotion.reward.FreePurchasableGiftAdjustment
  • All Implemented Interfaces:
    Adjustment, XMLizable, java.io.Serializable, java.lang.Cloneable


    public class FreePurchasableGiftAdjustment
    extends java.lang.Object
    implements Adjustment
    FreePurchasableGiftAdjustment offers a free gift as the reward of a promotion. This class implements the Adjustment interface. It is assumed that the free gift is a regular purchasable item that a shopper could manually add into the shopping cart during the purchase session. This adjustment supports 3 different strategies to handle the free gift:
  • ADD_WHEN_NEEDED (0), which indicates that the free gift is added only when there is no purchased item that is the same as the free gift. If a purchased item in the shopping cart is identical to the free gift, then the promotion gives the purchased item a 100% off discount. This option should only be used when such behavior does not interfere with the overall promotion rule. This option turns an existing purchased item into the free gift, which can affect the promotion qualification in some situations.
  • ALWAYS_ADD (1), which indicates that the system always adds the free gift, regardless whether or not the shopper already has an item that is identical to the free gift within the shopping cart. This is the default implementation option.
  • NEVER_ADD (2), which indicates that the free gift has to be manually added into the cart by the shopper in order to receive a 100% off discount on the item. The following XML Snippet is for this type of Adjustment:
    
       <Adjustment impl="com.ibm.commerce.marketing.promotion.reward.FreePurchasableGiftAdjustment">
            <GiftItem>
                            <CatalogEntryKey>
                            <SKU>SKU-20101088</SKU>
                            <DN>o=Root Organization</DN>
                            </CatalogEntryKey>
            </GiftItem>
            <Quantity>2</Quantity>
            <AddStrategy>2</AddStrategy>
            <!-- wholeOrder or AllAffectedItems or IndividualAffectedItems -->
            <AdjustmentType>AllAffectedItems</AdjustmentType>
      </Adjustment>
    
      
See Also:
Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean apply(LineItemSet targeted, java.math.BigDecimal targetedAmount, int targetedAmountTypes, LineItemSet affected, java.util.Vector affectedVector, java.util.Vector adjustmentVector, PromotionContext context)
      This method evaluates the targeted order items to see if they fulfill the conditions of this adjustment ( for example, if the quantity of the order items falls into one of the ranges of the adjustment).
      java.lang.Object clone()
      Returns null if the CloneNotSupportedException is thrown.
      void fromXML(org.w3c.dom.Node anXMLNode)
      Transforms the XML node into its corresponding real Object.
      int getAddStrategy()
      Gets add strategy.
      java.lang.Integer getAdjustmentType()
      This method gets the type of Adjustment.
      CatalogEntryKey getFreeGift()
      This method gets the Free Gift item.
      java.lang.Integer getNumOfGiftItems()
      This method gets the quantity of Free Gift items to be given as discount.
      void setAddStrategy(int aAddStrategy)
      Sets the add strategy.
      void setAdjustmentType(java.lang.Integer aAdjustmentType)
      This method sets the type of Adjustment.
      void setFreeGift(CatalogEntryKey catEntry)
      This method sets the Free Gift item.
      void setNumOfGiftItems(java.lang.Integer numOfItems)
      This method sets the quantity of Free Gift items to be given as discount.
      java.lang.String toXML()
      Converts the object into its corresponding XML format representation.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • ADD_WHEN_NEEDED

        public static final int ADD_WHEN_NEEDED
        Add free gift to the shop cart if shop cart does not contain one
        See Also:
        Constant Field Values
      • ALWAYS_ADD

        public static final int ALWAYS_ADD
        Always add free gift to the shop cart
        See Also:
        Constant Field Values
      • NEVER_ADD

        public static final int NEVER_ADD
        Never add the free gift to the shop cart, free gift must already be present
        See Also:
        Constant Field Values
    • Constructor Detail

      • FreePurchasableGiftAdjustment

        public FreePurchasableGiftAdjustment()
        Constructor for FreePurchasableGiftAdjustment.
    • Method Detail

      • getFreeGift

        public CatalogEntryKey getFreeGift()
        This method gets the Free Gift item.
        Returns:
        CatalogEntryKey CatalogEntryKey of the free gift
      • getNumOfGiftItems

        public java.lang.Integer getNumOfGiftItems()
        This method gets the quantity of Free Gift items to be given as discount.
        Returns:
        java.lang.Integer Quantity of Free Gift items to be given as discount
      • setFreeGift

        public void setFreeGift(CatalogEntryKey catEntry)
        This method sets the Free Gift item.
        Parameters:
        catEntry - The CatalogEntryKey of the free gift
      • setNumOfGiftItems

        public void setNumOfGiftItems(java.lang.Integer numOfItems)
        This method sets the quantity of Free Gift items to be given as discount.
        Parameters:
        numOfItems - Quantity of Free Gift items to be given as discount
      • getAdjustmentType

        public java.lang.Integer getAdjustmentType()
        Description copied from interface: Adjustment
        This method gets the type of Adjustment. An adjustment can be of the following types: for the whole Order, for All the Affected Items, or for Individual Affected Items.
        Specified by:
        getAdjustmentType in interface Adjustment
        Returns:
        one of the defined constants of WHOLE_ORDER, ALL_AFFECTED_ITEMS or INDIVIDUAL_AFFECTED_ITEMS.
        See Also:
        Adjustment.getAdjustmentType()
      • setAdjustmentType

        public void setAdjustmentType(java.lang.Integer aAdjustmentType)
        Description copied from interface: Adjustment
        This method sets the type of Adjustment. An adjustment can be of the following types for whole Order, for All Affected Items, and for Individual Affected Items. Set adjustmentType to one of the defined constants of WHOLE_ORDER, ALL_AFFECTED_ITEMS or INDIVIDUAL_AFFECTED_ITEMS.
        Specified by:
        setAdjustmentType in interface Adjustment
        See Also:
        Adjustment.setAdjustmentType(Integer)
      • clone

        public java.lang.Object clone()
        Returns null if the CloneNotSupportedException is thrown.
        Specified by:
        clone in interface Adjustment
        Overrides:
        clone in class java.lang.Object
        See Also:
        Object.clone()
      • apply

        public boolean apply(LineItemSet targeted,
                             java.math.BigDecimal targetedAmount,
                             int targetedAmountTypes,
                             LineItemSet affected,
                             java.util.Vector affectedVector,
                             java.util.Vector adjustmentVector,
                             PromotionContext context)
                      throws PromotionRuntimeException
        Description copied from interface: Adjustment
        This method evaluates the targeted order items to see if they fulfill the conditions of this adjustment ( for example, if the quantity of the order items falls into one of the ranges of the adjustment). Depending upon if and what conditions are fulfilled, an Adjustment object is added to the adjustmentVector Vector object passed as a parameter. The affectedVector Vector object passed as a parameter is updated by adding the affected order items. This method is called in the invoke(LineItemSet, BigDecimal, int, Vector, Vector, PromotionContext) method of AdjustmentFunction.
        Specified by:
        apply in interface Adjustment
        Parameters:
        targeted - The targeted order items. This is a set of order items (or portions of order items) that are used to qualify for the promotion of which this adjustment is a part.
        affected - The affected order items. This is a set of order items, identified by the promotion, to which this adjustment will be attached.
        affectedVector - A Vector which contains the affected LineItemSets.
        adjustmentVector - A Vector which contains the Adjustment objects.
        context - The PromotionContext object which may be used to build the Adjustment to add to the adjustmentVector parameter.
        Returns:
        A boolean value indicating whether the conditions of the adjustment were fulfilled successfully or not. A true value indicates that the conditions of the adjustment were fulfilled successully, otherwise a false value is returned.
        Throws:
        PromotionRuntimeException - when the computation encounters a problem.
        See Also:
        com.ibm.commerce.marketing.promotion.reward.Adjustment#apply(com.ibm.commerce.marketing.promotion.runtime.LineItemSet, com.ibm.commerce.marketing.promotion.runtime.LineItemSet, com.ibm.commerce.marketing.promotion.runtime.PromotionContext)
      • getAddStrategy

        public int getAddStrategy()
        Gets add strategy. Possible values are 0 : ADD_WHEN_NEEDED, 1: ALWAYS_ADD, 2: NEVER_ADD.
        Returns:
        the add strategy
      • setAddStrategy

        public void setAddStrategy(int aAddStrategy)
        Sets the add strategy. Possible values are 0 : ADD_WHEN_NEEDED, 1: ALWAYS_ADD, 2: NEVER_ADD.
        Parameters:
        aAddStrategy - The add strategy to set.