Enabling interim fix JR50130

Interim fix JR50130 provides the ability to change the behavior of promotion discounts.

When you use the "buy catalog entries from category X and get additional catalog entries from category X at percentage off" promotion, by default, the promotion is applied to the highest priced qualifying item remaining in the cart. If you want to change the behavior to apply the promotion to the lowest priced item, then install and enable this interim fix.

Before you begin

Ensure that the latest cumulative interim fix is installed:

Install the interim fix for JR50130.

Procedure

  1. Open your custom promotion component configuration file (for example, WC_eardir\xml\config\com.ibm.commerce.promotion-ext\wc-admin-component.xml)
    Note: Create a custom configuration file if it does not exist. For information about how to create a custom configuration file, use the following topic as a reference, Changing properties in the marketing component configuration file (wc-admin-component.xml). When you follow the steps, replace the term marketing with the term promotion.
  2. Add the following attribute to the custom configuration file:
    ApplyPromotionOnLowestPricedOrderItemsFirst=true
  3. Update the WC_installdir/wc.ear/xml/config/com.ibm.commerce.promotion/template/CategorySameItemPercentOffPurchaseConditionTemplate.xsl template with customizations to use the new feature.
    The following sample is a code snippet of new constraints to make the promotion apply to the least expensive item. Add the following constraints to the CategorySameItemPercentOffPurchaseConditionTemplate.xsl file.
    <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/Data/BaseQuantity" />
    		</LowerBound>
    		<UpperBound>
    			<xsl:value-of select="PromotionData/Elements/PurchaseCondition/Data/BaseQuantity" />
    		</UpperBound>
    		<Weight>1</Weight>
    	</WeightedRange>
    	<FilterChain impl="com.ibm.commerce.marketing.promotion.condition.FilterChain">
    		<Filter impl="com.ibm.commerce.marketing.promotion.condition.CategoryFilter">
    			<xsl:for-each select="PromotionData/Elements/PurchaseCondition/IncludeCategoryIdentifier">
    				<IncludeCategory>
    					<xsl:call-template name="CategoryKeyTemplate">
    						<xsl:with-param name="dn" select="Data/DN" />
    						<xsl:with-param name="name" select="Data/Name" />
    					</xsl:call-template>
    				</IncludeCategory>
    			</xsl:for-each>
    			<xsl:for-each select="PromotionData/Elements/PurchaseCondition/ExcludeCategoryIdentifier">
    				<ExcludeCategory>
    					<xsl:call-template name="CategoryKeyTemplate">
    						<xsl:with-param name="dn" select="Data/DN" />
    						<xsl:with-param name="name" select="Data/Name" />
    					</xsl:call-template>
    				</ExcludeCategory>
    			</xsl:for-each>
    		</Filter>
    		<xsl:choose>
    			<xsl:when test="PromotionData/Elements/PurchaseCondition/ExcludeCatalogEntryIdentifier">
    			<!-- Only populate when there are exclude items -->
    				<Filter impl="com.ibm.commerce.marketing.promotion.condition.MultiSKUFilter">
    					<xsl:for-each select="PromotionData/Elements/PurchaseCondition/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>
    			</xsl:when>
    		</xsl:choose>
    		<xsl:choose>
    			<xsl:when test="PromotionData/Elements/PurchaseCondition/CatalogEntryAttributeRule">
    			<!-- Only populate when there are attributes -->
    				<Filter	impl="com.ibm.commerce.marketing.promotion.condition.CatalogEntryAttributeFilter">
    					<AssociatedLanguage><xsl:value-of select="PromotionData/Elements/PurchaseCondition/Data/Language" />
                                       </AssociatedLanguage>
    					<CaseSensitive>false</CaseSensitive>
    					<SupportAttributeWithNoAssociatedLanguage>true</SupportAttributeWithNoAssociatedLanguage>
    					<xsl:for-each select="PromotionData/Elements/PurchaseCondition/CatalogEntryAttributeRule">
    						<xsl:call-template name="CatalogEntryAttributeRuleTemplate">
    							<xsl:with-param name="attributeRule" select="." />
    						</xsl:call-template>	
    					</xsl:for-each>					
    				</Filter>
    			</xsl:when>
    		</xsl:choose>
    		<xsl:choose>
    			<xsl:when test="PromotionData/Elements/PurchaseCondition/IncludePaymentTypeIdentifier">
    				<xsl:choose>
    					<xsl:when test="PromotionData/Elements/PurchaseCondition/IncludePaymentTypeIdentifier/Data/PaymentType != 'Any'">
    						<Filter impl="com.ibm.commerce.marketing.promotion.condition.PaymentTypeFilter">
    							<IncludePaymentType>
    								<PaymentMethodName><xsl:value-of 
    select="PromotionData/Elements/PurchaseCondition/IncludePaymentTypeIdentifier/Data/PaymentType" />
                                                            </PaymentMethodName>
    							</IncludePaymentType>
    						</Filter>
    					</xsl:when>
    				</xsl:choose>						
    			</xsl:when>
    		</xsl:choose>						
    		<Filter impl="com.ibm.commerce.marketing.promotion.condition.ItemSortingFilter">
    			<SortingMethod>PriceHighToLow</SortingMethod>
    			<SplitMethod>SplitEndToStart</SplitMethod>    	
    		</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/Data/RewardQuantity" />
    		</LowerBound>
    		<UpperBound>
    			<xsl:value-of select="PromotionData/Elements/PurchaseCondition/Data/RewardQuantity" />
    		</UpperBound>
    		<Weight>1</Weight>
    	</WeightedRange>
    	<FilterChain impl="com.ibm.commerce.marketing.promotion.condition.FilterChain">
    		<Filter impl="com.ibm.commerce.marketing.promotion.condition.CategoryFilter">
    			<xsl:for-each select="PromotionData/Elements/PurchaseCondition/IncludeCategoryIdentifier">
    				<IncludeCategory>
    					<xsl:call-template name="CategoryKeyTemplate">
    						<xsl:with-param name="dn" select="Data/DN" />
    						<xsl:with-param name="name" select="Data/Name" />
    					</xsl:call-template>
    				</IncludeCategory>
    			</xsl:for-each>
    			<xsl:for-each select="PromotionData/Elements/PurchaseCondition/ExcludeCategoryIdentifier">
    				<ExcludeCategory>
    					<xsl:call-template name="CategoryKeyTemplate">
    						<xsl:with-param name="dn" select="Data/DN" />
    						<xsl:with-param name="name" select="Data/Name" />
    					</xsl:call-template>
    				</ExcludeCategory>
    			</xsl:for-each>
    		</Filter>
    		<xsl:choose>
    			<xsl:when test="PromotionData/Elements/PurchaseCondition/ExcludeCatalogEntryIdentifier">
    			<!-- Only populate when there are exclude items -->
    				<Filter impl="com.ibm.commerce.marketing.promotion.condition.MultiSKUFilter">
    					<xsl:for-each select="PromotionData/Elements/PurchaseCondition/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>
    			</xsl:when>
    		</xsl:choose>
    		<xsl:choose>
    			<xsl:when test="PromotionData/Elements/PurchaseCondition/CatalogEntryAttributeRule">
    			<!-- Only populate when there are attributes -->
    				<Filter
    					impl="com.ibm.commerce.marketing.promotion.condition.CatalogEntryAttributeFilter">
    					<AssociatedLanguage><xsl:value-of select="PromotionData/Elements/PurchaseCondition/Data/Language" />
                                       </AssociatedLanguage>
    					<CaseSensitive>false</CaseSensitive>
    					<SupportAttributeWithNoAssociatedLanguage>true</SupportAttributeWithNoAssociatedLanguage>
    					<xsl:for-each select="PromotionData/Elements/PurchaseCondition/CatalogEntryAttributeRule">
    						<xsl:call-template name="CatalogEntryAttributeRuleTemplate">
    							<xsl:with-param name="attributeRule" select="." />
    						</xsl:call-template>	
    					</xsl:for-each>					
    				</Filter>
    			</xsl:when>
    		</xsl:choose>
    		<xsl:choose>
    			<xsl:when test="PromotionData/Elements/PurchaseCondition/IncludePaymentTypeIdentifier">
    				<xsl:choose>
    					<xsl:when test="PromotionData/Elements/PurchaseCondition/IncludePaymentTypeIdentifier/Data/PaymentType != 'Any'">
    						<Filter impl="com.ibm.commerce.marketing.promotion.condition.PaymentTypeFilter">
    							<IncludePaymentType>
    								<PaymentMethodName><xsl:value-of
    select="PromotionData/Elements/PurchaseCondition/IncludePaymentTypeIdentifier/Data/PaymentType" />
    								</PaymentMethodName>
    							</IncludePaymentType>
    						</Filter>
    					</xsl:when>
    				</xsl:choose>						
    			</xsl:when>
    		</xsl:choose>	
    		<Filter impl="com.ibm.commerce.marketing.promotion.condition.ItemSortingFilter">
    			<SortingMethod>PriceLowToHigh</SortingMethod>        	
    		</Filter>								
    	</FilterChain>
    </Constraint>	
    />
  4. Deploy the CategorySameItemPercentOffPurchaseConditionTemplate.xsl file.
  5. Restart your WebSphere Commerce server.
  6. Optional: If there are existing buy catalog entries from category X and get additional catalog entries from category X at percentage off promotions, you need to deactivate the promotions and reactivate before the changes take effect.