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:
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>
Modifier and Type | Field and Description |
---|---|
static int |
ADD_WHEN_NEEDED
Add free gift to the shop cart if shop cart does not contain one
|
static int |
ALWAYS_ADD
Always add free gift to the shop cart
|
static java.lang.String |
COPYRIGHT
IBM copyright notice field.
|
static int |
NEVER_ADD
Never add the free gift to the shop cart, free gift must already be present
|
ALL_AFFECTED_ITEMS, INDIVIDUAL_AFFECTED_ITEMS, WHOLE_ORDER
Constructor and Description |
---|
FreePurchasableGiftAdjustment()
Constructor for FreePurchasableGiftAdjustment.
|
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.
|
public static final java.lang.String COPYRIGHT
public static final int ADD_WHEN_NEEDED
public static final int ALWAYS_ADD
public static final int NEVER_ADD
public FreePurchasableGiftAdjustment()
public CatalogEntryKey getFreeGift()
CatalogEntryKey
CatalogEntryKey of the free giftpublic java.lang.Integer getNumOfGiftItems()
public void setFreeGift(CatalogEntryKey catEntry)
catEntry
- The CatalogEntryKey of the free giftpublic void setNumOfGiftItems(java.lang.Integer numOfItems)
numOfItems
- Quantity of Free Gift items to be given as discountpublic java.lang.Integer getAdjustmentType()
Adjustment
getAdjustmentType
in interface Adjustment
WHOLE_ORDER
, ALL_AFFECTED_ITEMS
or INDIVIDUAL_AFFECTED_ITEMS
.Adjustment.getAdjustmentType()
public void setAdjustmentType(java.lang.Integer aAdjustmentType)
Adjustment
WHOLE_ORDER
, ALL_AFFECTED_ITEMS
or INDIVIDUAL_AFFECTED_ITEMS
.setAdjustmentType
in interface Adjustment
Adjustment.setAdjustmentType(Integer)
public java.lang.String toXML() throws XMLizationException
XMLizable
toXML
in interface XMLizable
XMLizationException
- when this process failsXMLizable.toXML()
public void fromXML(org.w3c.dom.Node anXMLNode) throws DeXMLizationException
XMLizable
fromXML
in interface XMLizable
anXMLNode
- The node that represents an XMLizable objectDeXMLizationException
- when this process failsXMLizable.fromXML(Node)
public java.lang.Object clone()
CloneNotSupportedException
is thrown.clone
in interface Adjustment
clone
in class java.lang.Object
Object.clone()
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
Adjustment
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
.apply
in interface Adjustment
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.PromotionRuntimeException
- when the computation encounters a problem.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)
public int getAddStrategy()
public void setAddStrategy(int aAddStrategy)
aAddStrategy
- The add strategy to set.