public class FreeGiftPurchaseCondition extends java.lang.Object implements Condition
FreeGiftPurchaseCondition
is a customized pattern definition
for free gift promotions. This pattern definition assumes that there is only
one group of base products (specified using the BaseItemSelection node) and
one group of gift items (specified using the Gift and GiftQuantity nodes).
There are 2 different strategies to handle the free gift if there is a cross
section between the base products and the gift groups:
XML Snippet for FreeGiftPurchaseCondition:
<PurchaseCondition impl="com.ibm.commerce.marketing.promotion.condition.FreeGiftPurchaseCondition"> <BaseItemSelection> <Quantity>5</Quantity> <FilterChain impl="com.ibm.commerce.marketing.promotion.condition.FilterChain"> <Filter impl="com.ibm.commerce.marketing.promotion.condition.MultiSKUFilter"> <IncludeCatEntryKey> <CatalogEntryKey> <SKU>ABCD-01</SKU> <DN>sample distinguished name</DN> </CatalogEntryKey> </IncludeCatEntryKey> </Filter> </FilterChain> </BaseItemSelection> <GiftQuantity>2</GiftQuantity> <Gift> <CatalogEntryKey> <SKU>DCBA-01</SKU> <DN>sample distinguished name</DN> </CatalogEntryKey> </Gift> <AddStrategy>1</AddStrategy> </PurchaseCondition>
Modifier and Type | Field and Description |
---|---|
static int |
ADD_WHEN_NEEDED
Add gift to the shop cart if shop cart does not contain one
|
static int |
ALWAYS_ADD
Always add gift to the shop cart
|
static java.lang.String |
COPYRIGHT
IBM copyright notice field.
|
static java.lang.String |
TAG_ADD_STRATEGY
XML tag - AddStrategy
|
static java.lang.String |
TAG_MERGE_PATTERN
XML tag - MergePattern
|
Constructor and Description |
---|
FreeGiftPurchaseCondition()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
evaluate(PromotionContext context)
This function finds all the line items that can be targeted by current
promotion and groups them into line item sets.
|
void |
fromXML(org.w3c.dom.Node anXMLNode)
Transforms the XML node into its corresponding real Object.
|
int |
getAddStrategy()
Gets gift add strategy.
|
FilterChain |
getBaseItemFilterChain()
This method returns the base item filter chain in the condition.
|
java.math.BigDecimal |
getBaseItemQuantity()
This method returns the base item quantity in the condition.
|
CatalogEntryKey |
getGiftKey()
This method returns the CatalogEntryKey of the gift item in the
condition.
|
java.math.BigDecimal |
getGiftQuantity()
This method returns the gift quantity in the condition.
|
boolean |
isMergePattern()
Gets the merge pattern flag.
|
void |
setAddStrategy(int aAddStrategy)
Sets the gift add strategy.
|
void |
setBaseItemFilterChain(FilterChain aBaseItemFilters)
This method sets the base item filter chain in the condition to the
passed parameter.
|
void |
setBaseItemQuantity(java.math.BigDecimal aBaseItemQuantity)
This method sets the base item quantity in the condition to the passed
parameter.
|
void |
setGiftKey(CatalogEntryKey aGiftKey)
This method sets the CatalogEntryKey of the gift item in the condition.
|
void |
setGiftQuantity(java.math.BigDecimal aGiftQuantity)
This method sets the gift quantity in the condition to the passed
parameter.
|
void |
setMergePattern(boolean mergePattern)
Sets the merge pattern flag.
|
java.lang.String |
toXML()
Converts the object into its corresponding XML format representation.
|
public static final java.lang.String COPYRIGHT
public static final java.lang.String TAG_ADD_STRATEGY
public static final java.lang.String TAG_MERGE_PATTERN
public static final int ADD_WHEN_NEEDED
public static final int ALWAYS_ADD
public int getAddStrategy()
public void setAddStrategy(int aAddStrategy)
aAddStrategy
- The add strategy to set.public boolean evaluate(PromotionContext context) throws PromotionRuntimeException
If the promotion does not have redemption limits and is not a coupon promotion, the MergePattern flag is used to improve overall performance by merging all matched items into a single pattern and increase the gift quantity according to number of times this promotion can be applied to the current order. If the business requirement needs to track individual redemption information, the MergePattern flag can be turn off by setting its value to false.
evaluate
in interface Condition
context
- PromotionContext
PromotionRuntimeException
- is thrown if the evaluation encounters unexpected
problems.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 FilterChain getBaseItemFilterChain()
public void setBaseItemFilterChain(FilterChain aBaseItemFilters)
aBaseItemFilters
- the filter chain to setpublic java.math.BigDecimal getBaseItemQuantity()
public void setBaseItemQuantity(java.math.BigDecimal aBaseItemQuantity)
aBaseItemQuantity
- the baseItemQuantity to setpublic CatalogEntryKey getGiftKey()
public void setGiftKey(CatalogEntryKey aGiftKey)
aGiftKey
- the giftKey to setpublic java.math.BigDecimal getGiftQuantity()
public void setGiftQuantity(java.math.BigDecimal aGiftQuantity)
aGiftQuantity
- the giftQuantity to setpublic boolean isMergePattern()
public void setMergePattern(boolean mergePattern)
mergePattern
- true or false.