Creating the object template for the new promotion type

Create an object template to define the object structure for the custom promotion type. All promotions defined in the Promotions tool use the same primary object definition. The purpose of the object template is to model the differences between the promotion types. There is one object template for each promotion type. The object template contains all the objects that each promotion type requires.

Before you begin

Review the wcfObjectTemplate class that you must extend:

About this task

Most promotion properties are common for all promotion types. For example, if you compare the user interface for certain properties, such as the redemption limit and the promotion schedule, they typically look the same from one promotion type to the next. On the other hand, the properties of the purchase and reward conditions vary, depending on:
  • Whether the promotion is an order-level, category-level, or catalog-entry-level promotion
  • Whether the discount is a fixed price, a percentage off, an amount off, or a free gift

Create an object template to define the unique properties for your custom promotion type.

Procedure

  1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
  2. Create a directory to store your new promotion element object template.
    You can store the file in a directory structure similar to the following example:
    • WebSphere Commerce Version 7.0.0.0Feature Pack 1LOBTools/WebContent/WEB-INF/src/lzx/your_company_name/promotion/objectDefinitions/promotionTypes/
    • Introduced in Feature Pack 2LOBTools/WebContent/config/your_company_name/promotion/objectDefinitions/promotionTypes
  3. Create a new file for the promotion object template:
    • WebSphere Commerce Version 7.0.0.0Feature Pack 1OpenLaszlo (.lzx) file
    • Introduced in Feature Pack 2Definition (.def) file
  4. Create the promotion object template.
    See the example at the end of this procedure.
  5. WebSphere Commerce Version 7.0.0.0Feature Pack 1Register the template in the PromotionExtensionsLibrary.lzx file.
  6. Complete one of the following steps:
    OptionDescription
    WebSphere Commerce Version 7.0.0.0Feature Pack 1Create an instance of the new template in the promotion primary object definition file WebSphere Commerce Version 7.0.0.0Feature Pack 1The primary object definition file is named PromotionPrimaryObjectDefinition.lzx. This file is stored in the LOBTools/WebContent/WEB-INF/src/lzx/commerce/promotion/ directory.
    Introduced in Feature Pack 2Add the new template definition to the base promotion primary object definition Introduced in Feature Pack 2The base promotion primary object definition is defined in the PromotionPrimaryObjectDefinition.def file. This file is stored in the LOBTools/WebContent/config/commerce/promotion/objectDefinitions directory.

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, the object template looks like the following sample:

WebSphere Commerce Version 7.0.0.0Feature Pack 1

<library>
    <class name="proProductLevelPWPFixedCostDiscountTemplate" 1
        extends="wcfObjectTemplate"
        templateType="ProductLevelPWPFixedCostDiscount" 2
        displayName="Buy X get Y at a fixed cost"
        description="Offers a fixed cost discount on a catalog entry when the order includes some other specified catalog entry">
        <dataset name="template">
            <object objectType="ProductLevelPWPFixedCostPurchaseCondition"> 3
                <object objectType="Purchase"/> 4a
                <object objectType="Reward"/> 4b
             </object>
        </dataset>
    </class>
</library>
Introduced in Feature Pack 2
<Definitions>
   <ObjectTemplate definitionName="proProductLevelPWPFixedCostDiscountTemplate" 1
      templateType="ProductLevelPWPFixedCostDiscount" 2
      displayName="Buy X get Y at a fixed cost"
      description="Offers a fixed cost discount on a catalog entry when the order includes some other specified catalog entry">
      <Xml name="template">
         <object objectType="ProductLevelPWPFixedCostPurchaseCondition"> 3
            <object objectType="Purchase"/> 4a
            <object objectType="Reward"/> 4b
         </object>
      </Xml>
   </ObjectTemplate>
</Definitions>
The following describes the lines with black numbered callouts:
In this example:
  • WebSphere Commerce Version 7.0.0.0Feature Pack 1The code to instantiate this new template to the promotion primary object definition file looks like this:
    
    <class name="proBasePromotionPrimaryObjectDefinition"
          extends="wcfPrimaryObjectDefinition" 	
          isBaseDefinition="true"
          objectType="BasePromotion" . . .>
       .
       .
       <proProductLevelPWPFixedCostDiscountTemplate/>
       .
       .
    </class>
    
  • Introduced in Feature Pack 2The code to add this new template to the promotion primary object definition file looks like this:
    <PrimaryObjectDefinition definitionName="proBasePromotionPrimaryObjectDefinition" 	
       isBaseDefinition="true"...>
          .
          .
          .
       <ObjectTemplate baseDefinitionName="proProductLevelPWPFixedCostDiscountTemplate"/>
       .
       .
    </PrimaryObjectDefinition>