Creating the XSLT template to transform the promotion XML
Create a custom XSLT template to transform the authoring promotion XML to the runtime promotion XML. This transformation takes place when a business user activates a promotion based on your custom promotion type.
Before you begin
- How promotion data is stored and managed
- Creating and registering the XSL template (this is a lesson in a tutorial that provides a downloadable example of an XSLT template and then explains its contents)
About this task
Typically, you must define a new purchase condition structure for a new promotion type. To
develop a new purchase condition XSLT template, you must use information you gathered in two
previous steps as input, that is:
- The purchase condition section of the runtime promotion XML that you modeled
- The data you determined is required from the Management Center user interface for this particular promotion type
Purchase condition XSLT template | Default promotion type |
CategoryAllItemAmountOffPurchaseConditionTemplate.xsl | Amount off the subtotal of catalog entries from a category |
CategoryAllItemFixedCostPurchaseConditionTemplate.xls | Fixed price on the subtotal of catalog entries from a category |
CategoryAllItemPercentOffPurchaseConditionTemplate.xsl | Percentage off the subtotal of catalog entries from a category |
CategoryFixedCostShippingPurchaseConditionTemplate.xls | Buy catalog entries from category X, get shipping at a fixed price |
CategoryPerItemAmountOffPurchaseConditionTemplate.xsl | Amount off individual catalog entries from a category |
CategoryPerItemFixedCostPurchaseConditionTemplate.xls | Fixed price on individual catalog entries from a category |
CategoryPerItemPercentOffPurchaseConditionTemplate.xsl | Percentage off individual catalog entries from a category |
CategoryPurchaseWithPurchasePercentOffPurchaseConditionTemplate.xls | Buy catalog entries from category X, get a percentage off catalog entry Y |
CategorySameItemPercentOffPurchaseConditionTemplate.xsl | Buy catalog entries from category X, get additional catalog entries from category X at a percentage off |
CategoryWithFreeGiftPurchaseConditionTemplate.xsl | Buy catalog entries from category X, get catalog entry Y free |
MultipleItemsGetYFixedAmountOffPurchaseConditionTemplate.xls | Buy A (and B and C), get an amount off Y |
MultipleItemsGetYPercentOffPurchaseConditionTemplate.xls | Buy A (and B and C), get a percentage off Y |
MultipleItemsPercentOffPurchaseConditionTemplate.xsl | Buy A and B, get a percentage off both |
OrderAmountOffPurchaseConditionTemplate.xsl | Amount off on order |
OrderFixedAmountOffShippingPurchaseConditionTemplate.xsl | Amount off shipping on an order |
OrderFixedCostShippingPurchaseConditionTemplate.xsl | Fixed price for shipping an order |
OrderFreeGiftPurchaseConditionTemplate.xsl | Free gift with an order |
OrderPercentOffPurchaseConditionTemplate.xsl | Percentage off an order |
ProductAllItemAmountOffPurchaseConditionTemplate.xsl | Amount off the subtotal of catalog entries |
ProductAllItemFixedCostPurchaseConditionTemplate.xls | Fixed price on the subtotal of catalog entries |
ProductAllItemPercentOffPurchaseConditionTemplate.xsl | Percentage off the subtotal of catalog entries |
ProductFixedCostShippingPurchaseConditionTemplate.xls | Buy catalog entry X, get shipping at a fixed price |
ProductPerItemAmountOffPurchaseConditionTemplate.xsl | Amount off individual catalog entries |
ProductPerItemFixedCostPurchaseConditionTemplate.xls | Fixed price on individual catalog entries |
ProductPerItemPercentOffPurchaseConditionTemplate.xsl | Percentage off individual catalog entries |
ProductPurchaseWithPurchasePercentOffPurchaseConditionTemplate.xsl | Buy catalog entry X, get percentage off catalog entry Y |
ProductSameItemPercentOffPurchaseConditionTemplate.xsl | Buy catalog entry X, get additional X at a percentage off |
ProductWithFreeGiftPurchaseConditionTemplate.xsl | Buy catalog entry X, get catalog entry Y free |
Procedure
Example
For your custom promotion type, Customers
who purchase
two dining chairs (FULO-01) qualify to purchase a dining table (FULO-02)
at the reduced price of $200, you create a custom XSL template
for the <PurchaseCondition> element called ProductPurchaseWithPurchaseFixedCostPurchaseConditionTemplate.xsl.
It looks like the following sample:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- handles purchase condition -->
<xsl:template name="PurchaseConditionTemplate" match="/">
<PurchaseCondition impl="com.ibm.commerce.marketing.promotion.condition.PurchaseCondition">
<Pattern impl="com.ibm.commerce.marketing.promotion.condition.Pattern">
<Constraint impl="com.ibm.commerce.marketing.promotion.condition.Constraint">
<WeightedRange impl="com.ibm.commerce.marketing.promotion.condition.WeightedRange">
<LowerBound>
<xsl:value-of select="PromotionData/Elements/PurchaseCondition/Purchase/Data/Quantity" />
</LowerBound>
<UpperBound>
<xsl:value-of select="PromotionData/Elements/PurchaseCondition/Purchase/Data/Quantity" />
</UpperBound>
<Weight>1</Weight>
</WeightedRange>
<FilterChain impl="com.ibm.commerce.marketing.promotion.condition.FilterChain">
<Filter impl="com.ibm.commerce.marketing.promotion.condition.MultiSKUFilter">
<xsl:for-each select="PromotionData/Elements/PurchaseCondition/Purchase/IncludeCatalogEntryIdentifier">
<IncludeCatEntryKey>
<xsl:call-template name="CatalogEntryKeyTemplate">
<xsl:with-param name="dn" select="Data/DN" />
<xsl:with-param name="sku" select="Data/SKU" />
</xsl:call-template>
</IncludeCatEntryKey>
</xsl:for-each>
<xsl:for-each select="PromotionData/Elements/PurchaseCondition/Purchase/ExcludeCatalogEntryIdentifier">
<ExcludeCatEntryKey>
<xsl:call-template name="CatalogEntryKeyTemplate">
<xsl:with-param name="dn" select="Data/DN" />
<xsl:with-param name="sku" select="Data/SKU" />
</xsl:call-template>
</ExcludeCatEntryKey>
</xsl:for-each>
</Filter>
</FilterChain>
</Constraint>
<Constraint impl="com.ibm.commerce.marketing.promotion.condition.Constraint">
<WeightedRange impl="com.ibm.commerce.marketing.promotion.condition.WeightedRange">
<LowerBound>
<xsl:value-of select="PromotionData/Elements/PurchaseCondition/Reward/Data/Quantity" />
</LowerBound>
<UpperBound>
<xsl:value-of select="PromotionData/Elements/PurchaseCondition/Reward/Data/Quantity" />
</UpperBound>
<Weight>1</Weight>
</WeightedRange>
<FilterChain impl="com.ibm.commerce.marketing.promotion.condition.FilterChain">
<Filter impl="com.ibm.commerce.marketing.promotion.condition.MultiSKUFilter">
<xsl:for-each select="PromotionData/Elements/PurchaseCondition/Reward/IncludeCatalogEntryIdentifier">
<IncludeCatEntryKey>
<xsl:call-template name="CatalogEntryKeyTemplate">
<xsl:with-param name="dn" select="Data/DN" />
<xsl:with-param name="sku" select="Data/SKU" />
</xsl:call-template>
</IncludeCatEntryKey>
</xsl:for-each>
<xsl:for-each select="PromotionData/Elements/PurchaseCondition/Reward/ExcludeCatalogEntryIdentifier">
<ExcludeCatEntryKey>
<xsl:call-template name="CatalogEntryKeyTemplate">
<xsl:with-param name="dn" select="Data/DN" />
<xsl:with-param name="sku" select="Data/SKU" />
</xsl:call-template>
</ExcludeCatEntryKey>
</xsl:for-each>
</Filter>
</FilterChain>
</Constraint>
</Pattern>
<Distribution impl="com.ibm.commerce.marketing.promotion.reward.Distribution">
<Type>Volume</Type>
<Base>Quantity</Base>
<Currency>
<xsl:value-of select="PromotionData/Elements/PurchaseCondition/Data/Currency" />
</Currency>
<Range impl="com.ibm.commerce.marketing.promotion.reward.DistributionRange">
<LowerBound>1</LowerBound>
<UpperBound>-1</UpperBound>
<LowerBoundIncluded>true</LowerBoundIncluded>
<UpperBoundIncluded>false</UpperBoundIncluded>
<RewardChoice>
<Reward impl="com.ibm.commerce.marketing.promotion.reward.DefaultReward">
<AdjustmentFunction impl="com.ibm.commerce.marketing.promotion.reward.AdjustmentFunction">
<FilterChain impl="com.ibm.commerce.marketing.promotion.condition.FilterChain">
<Filter impl="com.ibm.commerce.marketing.promotion.condition.MultiSKUFilter">
<xsl:for-each select="PromotionData/Elements/PurchaseCondition/Reward/IncludeCatalogEntryIdentifier">
<IncludeCatEntryKey>
<xsl:call-template name="CatalogEntryKeyTemplate">
<xsl:with-param name="dn" select="Data/DN" />
<xsl:with-param name="sku" select="Data/SKU" />
</xsl:call-template>
</IncludeCatEntryKey>
</xsl:for-each>
<xsl:for-each select="PromotionData/Elements/PurchaseCondition/Reward/ExcludeCatalogEntryIdentifier">
<ExcludeCatEntryKey>
<xsl:call-template name="CatalogEntryKeyTemplate">
<xsl:with-param name="dn" select="Data/DN" />
<xsl:with-param name="sku" select="Data/SKU" />
</xsl:call-template>
</ExcludeCatEntryKey>
</xsl:for-each>
</Filter>
</FilterChain>
<Adjustment impl="com.ibm.commerce.marketing.promotion.reward.FixedCostAdjustment">
<FixedCost>
<xsl:value-of select="PromotionData/Elements/PurchaseCondition/Data/FixedCost" />
</FixedCost>
<AdjustmentType>IndividualAffectedItems</AdjustmentType>
<Currency>
<xsl:value-of select="PromotionData/Elements/PurchaseCondition/Data/Currency" />
</Currency>
</Adjustment>
</AdjustmentFunction>
</Reward>
</RewardChoice>
</Range>
<PatternFilter impl="com.ibm.commerce.marketing.promotion.condition.DummyPatternFilter">
</PatternFilter>
</Distribution>
</PurchaseCondition>
</xsl:template>
<!-- handles CatalogEntryKey -->
<xsl:template name="CatalogEntryKeyTemplate">
<xsl:param name="dn" />
<xsl:param name="sku" />
<CatalogEntryKey>
<DN>
<xsl:value-of select="$dn" />
</DN>
<SKU>
<xsl:value-of select="$sku" />
</SKU>
</CatalogEntryKey>
</xsl:template>
</xsl:transform>