IBM WCS - Promotions - Steps to create a custom promotion type

 

Interface or UI ( Command Center ) - Step 1 through Step 4


Step 1 

Find the CMC ( Management Center ) promotion interface that best matches your need.

a. Login to Management Center.
b. Select the Store.
c. Click Management Center -> Promotions
d. Click File -> New -> Promotion
e. Select individual Promotion Type and Check the Purchase Condition and Reward section upon selecting the promotion type.
f. Identify the promotion type whose interface matches your need.

Step 2 

Find the following open laszlo (.lzx) files for the promotion type.

a. Open LOBTools Project
b. Go to Web Content -> WEB-INF -> src -> lzx -> commerce -> promotion

c. Open objectDefinition -> elements to see the list of Object Definitions for different project types.
d. Open  objectDefinition -> promotionTypes to see list of templates.
e. Open propertyViews -> promotionTypes to view properties.

These three files makes the Open Laszlo interface ( command center -> promotions -> Purchase Condition and Reward section) for each promotion type.

Identify the three files for the interface you want and make their copies with different names for your new interface.

Step 3

Make changes in .lzx files as per interface need you have.

Open template lzx file and make the following change  for a different promotion type.

templateType="ProductLevelNewBuyXGetYFree"

Moreover change the condition lzx reference to point to the new Object definition.

<dataset name="template">
            <object objectType="ProductLevelNewBuyXGetYFreePurchaseCondition" />
        </dataset>   


Step 4 

Right click the .lzx template and build OpenLaszlo project. This will create the Command Center promotion interface for the new promotion type.

Promotion Template - Step 5 through 6


Step 5 

Open

/WebSphereCommerceServerConfig/xml/config/com.ibm.commerce.promotion/com.ibm.commerce.promotion.facade.server.config.PromotionComponentConfigurationImpl.xml

and add a new entry in the configuration file

<promotionTypeConfiguration name="ProductLevelNewBuyXGetYFree" >
        <param key="purchaseConditionTemplate" value="NewProductWithFreeGiftPurchaseConditionTemplate.xsl"/>
        <param key="basePromotionTemplate" value="DefaultBasePromotionTemplate.xsl"/>
        <param key="customConditionTemplate" value="DefaultCustomConditionsTemplate.xsl"/>
        <param key="targetingConditionTemplate" value="DefaultTargetingConditionTemplate.xsl"/>
        <param key="promotionGroup" value="ProductLevelPromotion"/>
        <param key="calculationCodeDisplayLevel" value="0"/>
    </promotionTypeConfiguration>

with pointing the new interface to a new xsl file.

Step 6

Find the most appropriate xsl out of the many xsl available at

/WebSphereCommerceServerConfig/xml/config/com.ibm.commerce.promotion/template

Make changes in the identified template and make a new copy of it and name it as NewProductWithFreeGiftPurchaseConditionTemplate.xsl
as specified in PromotionComponentConfigurationImpl.xml in Step 4.

So now we have created the interface and xslt for promotion xml creation. Test by creating a new promotion using the new promotion type and hence check the entry within PX_PROMOTION table. Check the xml for the new promotion using below sql.

select XMLPARAM from PX_PROMOTION where rownum < 2 order by PX_PROMOTION_ID Desc;

This xml is the combination of xsl template stuffed with values from the new promotion created within command center. If you need any changes in the promotion XML , make appropriate changes in the respective xsl.

If your promotion type combines one of the default promotion conditions with a reward from a different default promotion, such as "buy 3 of item A, get free shipping using the express shipping method", which combines an item level purchase condition and a shipping level reward, you can build your own promotion by merging the purchase condition from the "Product Level Percentage Off" promotion type, and the reward from the "Discounted Shipping" promotion. 

Sample template with explanation - Buy X Get Y Free