Retrieving the runtime XML for a Promotion type

You can retrieve the runtime XML for any active promotion in your store from your database. If you are creating a custom promotion type, you can use the runtime XML from an existing promotion type as a model for designing the XML for your new type.

About this task

Runtime promotion XML samples can provide you with a starting point for creating custom promotion types for your store. Use the runtime promotion XML for a promotion type similar to the custom promotion type you are creating. You can retrieve the runtime promotion XML for an existing promotion from your database. The runtime promotion XML is stored in XMLPARAM column of the PX_PROMOTION database table. Ensure that you choose a promotion that is already activated. Until a promotion created in Management Center is activated, only placeholder XML is stored in the XMLPARAM column; this placeholder XML displays as PurchaseCondition impl="com.ibm.commerce.marketing.promotion.condition.AlwaysFalsePurchaseCondition".

To extract the runtime XML for a default promotion type, complete the following steps:

Procedure

  1. Open the Promotions tool.
  2. Create a promotion that is based on an existing promotion type. Select a promotion type that is similar to the custom promotion type you want to create.
    For more information about creating a promotion, see Creating promotions
  3. Activate the new promotion. Activating the promotion generates the runtime XML for this promotion. For more information about activating a promotion, see Activating or deactivating promotions
  4. From the explorer view, click the Promotions directory. The list of available promotions displays in the main work area. In the Promotions list view table, configure the columns to display the Unique ID column. Record the unique ID for the promotion you created.
    For more information about displaying hidden columns, see Using table views
  5. Open a database connection.
  6. Run the following query to retrieve the runtime XML for your promotion:
    Select XMLPARAM from PX_PROMOTION where PX_PROMOTION_ID=yourPromotionUniqueId

    Where yourPromotionUniqueId is the ID you recorded in step 3. The result from your query returns the runtime XML for your promotion. For example, the following code sample is the runtime XML for a promotion that offers a free gift with orders over $2000:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!-- This promotion does the following: Purchase over $2000 USD, receive free gift. -->
    
    <Promotion impl="com.ibm.commerce.marketing.promotion.DefaultPromotion">
    
      <!-- this identifies the promotion -->
      
      <PromotionKey>
        
        <-- Name of the promotion -->
        
        <PromotionName>Free gift with selected orders</PromotionName>
        
        <!-- The store that owns this promotion. Store key is defined as the combination of the 
             DN of the organization that owns this store and a store name --> 
        <StoreKey>
          <DN>ou=elite,o=seller organization,o=root organization</DN>
          <Identifier>Elite</Identifier>
        </StoreKey>
        
        <!-- Versions of a promotion. Statistics are associated with the
             version number,promotions with the same promotion key and version 
             number but different revision are considered different revisions of
             the same promotion.  Promotions with the same key but different 
             version numbers are considered distinct promotions. -->
        
        <Version>1</Version>
        <Revision>3</Revision>
      </PromotionKey>
      
      <!-- Promotions are group by groups, and groups are scoped by store, 
           refer to promotion organization for details on what a group is, its role 
           and the default groups -->
      
      <PromotionGroupKey>
        <GroupName>OrderLevelPromotion</GroupName>
        <StoreKey>
          <DN>ou=elite,o=seller organization,o=root organization</DN>
          <Identifier>Elite</Identifier>
        </StoreKey>
      </PromotionGroupKey>
      
      <!-- Various descriptions of the promotion -->
      
      <TypedNLDescription impl="com.ibm.commerce.marketing.promotion.TypedNLDescription">
        <DefaultLocale>en_US</DefaultLocale>
        <Description locale="en_US" type="admin">Order Discount - Free Gift with orders over $2000 USD</Description>
        <Description locale="en_US" type="long">Spend over $2000 USD and get a free passenger vehicle battery.</Description>
        <Description locale="en_US" type="short">Spend over $2000 USD and get a free gift!</Description>
      </TypedNLDescription>
      
      <!-- Priority of the promotion the higher the more important
      
      <Priority>250</Priority>
      
      <-- Exclusiveness of the promotion. Possible values are:  
          0: not exclusive at all 
          1: exclusive at the group level 
          2: exclusive at a global level 
          3: a backward compatibility mode that mimics the combinability 
             of order level promotions with product level promotions in 
             previous releases 
          4: This promotion can be stacked on top of other promotions in the same promotion group
      -->
          
      <Exclusive>0</Exclusive>
      
      <!-- For future use, always empty for now -->
      
      <ExemptPolicyList/>
      
      <!-- For future use, always empty for now -->
      
      <ExplicitlyAppliedPolicyList/>
      
      <!-- Status of the promotion: 
           0: inactive
           1: active
           2: deleted
           3: suspended 
           4: obsolete
      -->
      
      <Status>1</Status>
      
      <!-- Audit trail, last update time and last person who updated the promotion -->
      <LastUpdate>18-06-2011 15:53:46</LastUpdate>
      <LastUpdateBy>
        <CustomerKey>
          <LogonId>wcsadmin</LogonId>
        </CustomerKey>
      </LastUpdateBy>
      
      <!-- How many times this promotion can be applied to the current order, 
           possible values are:  
           -1:              unlimited
           positive number: the limit 
      -->
      
      <PerOrderLimit>-1</PerOrderLimit>
      
      <!--How many times this promotion can be applied to a shopper, 
          possible values are:  
          -1:              unlimited,
          positive number: the limit 
      
          This value is only valid for a registered shopper, for none registered 
          shoppers there is no way to control how many times a shopper can redeem a 
          promotion. 
      -->
      
      <PerShopperLimit>1</PerShopperLimit>
      
      <!-- How many times this promotion can be redeemed overall.
           Possible values are:
           -1:              unlimited,
           positive number: the limit 
      -->
      <ApplicationLimit>-1</ApplicationLimit>
      
      <TargetSales>0.00000</TargetSales>
      <CorrespondingRBDTypeName>OrderLevelFreeGift</CorrespondingRBDTypeName>
      
      <!-- Schedule information of this promotion -->
      
      <Schedule impl="com.ibm.commerce.marketing.promotion.schedule.PromotionSchedule">
        <DateRange impl="com.ibm.commerce.marketing.promotion.schedule.DateRangeSchedule">
          <Start inclusive="true">01-01-2004 12:00:00</Start>
          <End inclusive="true">31-12-9999 12:00:00</End>
        </DateRange>
        <TimeWithinADay impl="com.ibm.commerce.marketing.promotion.schedule.TimeRangeWithinADaySchedule">
          <Start inclusive="true">00:00:00</Start>
          <End inclusive="true">23:59:59</End>
        </TimeWithinADay>
        <Week impl="com.ibm.commerce.marketing.promotion.schedule.WeekDaySchedule">
          <WeekDay>SUNDAY</WeekDay>
          <WeekDay>MONDAY</WeekDay>
          <WeekDay>TUESDAY</WeekDay>
          <WeekDay>WEDNESDAY</WeekDay>
          <WeekDay>THURSDAY</WeekDay>
          <WeekDay>FRIDAY</WeekDay>
          <WeekDay>SATURDAY</WeekDay>
        </Week>
      </Schedule>
      
      <!-- Type of promotion:
          0: targeted
          1: private, that is, a coupon promotion 
      -->
      <PromotionType>0</PromotionType>
      
      <!-- Whether a code is required to redeem this promotion. -->
      
      <PromotionCodeRequired>false</PromotionCodeRequired>
      
      <!-- When a promotion code is entered, should the target condition be checked -->
      
      <SkipTargetingConditionOnProperPromotionCodeEntered>false</SkipTargetingConditionOnProperPromotionCodeEntered>
      
      <!-- Check the target condition or not -->
      
      <CheckTargetingConditionAtRuntime>true</CheckTargetingConditionAtRuntime>
      
      <!-- Do not change this element -->
      
      <PromotionCodeCondition impl="com.ibm.commerce.marketing.promotion.condition.PromotionCodeCondition"/>
      
      <!-- Targeting condition --> 
      
      <Targeting impl="com.ibm.commerce.marketing.promotion.condition.TargetingCondition">
      </Targeting>
      
      <!-- Custom condition for the promotion can be added here -->
      
      <CustomConditions/>
      
      <!-- This is core of a promotion definition -->
      
      <PurchaseCondition impl="com.ibm.commerce.marketing.promotion.condition.PurchaseCondition">
        
        <!-- Matches the pattern targeted by the current promotion: the following 
             pattern matches the entire order, for details refer to the promotion 
             purchase condition model document 
        -->
        
        <Pattern impl="com.ibm.commerce.marketing.promotion.condition.Pattern">
          
          <!-- A pattern is made up of multiple constraint, each specifying a 
               list of items that make up part of the pattern. There must be no 
               cross-sections between constraints 
          -->
          
          <UniqueConstraints>false</UniqueConstraints>
          <Constraint impl="com.ibm.commerce.marketing.promotion.condition.Constraint">
            
            <!-- Quantity requirement of this constraint -->
            
            <WeightedRange impl="com.ibm.commerce.marketing.promotion.condition.WeightedRange">
              
              <!-- minimum number of item is 1 -->
              
              <LowerBound>1</LowerBound>
              
              <!--  Maximum number of item is not limited  -->
              
              <UpperBound>-1</UpperBound>
              
              <-- Match as many as items that satisfy the criteria defined in the filter chain next
              
              <Weight>1</Weight>
            </WeightedRange>
            
            <!-- Selection criteria -->    
            
            <FilterChain impl="com.ibm.commerce.marketing.promotion.condition.FilterChain">
              
              <!-- Multiple filters can be specified, the are applied in a contiguous fashion, 
                   that is, connected using a logical "and". The dummy filter returns anything 
                   passed to it, it effectively selects anything 
              -->
              
              <Filter impl="com.ibm.commerce.marketing.promotion.condition.DummyFilter"/>
            </FilterChain>
            
            <!-- The combination of the quantity requirement and the filter chain would return 
                 everything present in the shopcart as one big matched pattern 
            -->   
          </Constraint>
        </Pattern>
        
        <!-- Once pattern is matched, rewards are assigned, for details refer to the 
             purchase condition model document 
        -->
        
        <Distribution impl="com.ibm.commerce.marketing.promotion.reward.Distribution">
          
          <!-- A volume based distribution on the spending total is performed, 
               spending total is measure in USD -->
          
          <Type>Volume</Type>
          <Base>Cost</Base>
          <Currency>USD</Currency>
          
          <!-- First range 2000 <= spending -->
          
          <Range impl="com.ibm.commerce.marketing.promotion.reward.DistributionRange">
            <UpperBound>-1</UpperBound>
            <LowerBound>2000</LowerBound>
            <UpperBoundIncluded>false</UpperBoundIncluded>
            <LowerBoundIncluded>true</LowerBoundIncluded>
            
            
            <RewardChoice>
                
                <!-- This reward, if the spending total of ALL matched patterns falls into the range of over 2000 -->
                
              <Reward impl="com.ibm.commerce.marketing.promotion.reward.DefaultReward">
                <AdjustmentFunction impl="com.ibm.commerce.marketing.promotion.reward.AdjustmentFunction">
                  
                  <!--  Reward can be associated with a sub set of the items that make up the pattern,
                        the input of this filter chain will be one matched pattern, and a sub set of 
                        items that make up that pattern is returned and adjustments are associated with 
                        the returned items also known as affected items
                  -->
                  <FilterChain impl="com.ibm.commerce.marketing.promotion.condition.FilterChain">
                    <Filter impl="com.ibm.commerce.marketing.promotion.condition.DummyFilter"/>
                  </FilterChain>
                  
                  <!--  the adjustment  -->
                  <Adjustment impl="com.ibm.commerce.marketing.promotion.reward.DefaultChoiceOfFreeGiftAdjustment">
                    <RewardSpecification impl="com.ibm.commerce.marketing.promotion.choice.gift.FreeGiftSpecification">
                      <MaxQuantity>1</MaxQuantity>
                      <GiftItem impl="com.ibm.commerce.marketing.promotion.choice.gift.CatalogEntryGiftItem"> 
                        <Quantity>1</Quantity>
                        <CatalogEntryKey>
                          <SKU>A0000736</SKU>
                          <DN>ou=elite,o=seller organization,o=root organization</DN>
                        </CatalogEntryKey>
                      </GiftItem>
                    </RewardSpecification>
                    <RewardChoice impl="com.ibm.commerce.marketing.promotion.choice.gift.FreeGiftChoice">
                      <GiftItem impl="com.ibm.commerce.marketing.promotion.choice.gift.CatalogEntryGiftItem">
                        <Quantity>1</Quantity>
                        <CatalogEntryKey>
                          <SKU>A0000736</SKU>
                          <DN>ou=elite,o=seller organization,o=root organization</DN>
                        </CatalogEntryKey>
                      </GiftItem>
                    </RewardChoice>
                    
                    <!-- This adjustment is applied to the entire order, 
                         possible values are: (case insentitive)
                         wholeOrder:  The entire order, that is, $15 dollars off 
                                      an entire order
                         AllAffectedItems: Affected items returned by the filter 
                                       chain defined above, that is, $15  dollars 
                                       off all of the affected items as a whole.
                         IndividualAffectedItems: Adjustments are applied to 
                                       affected items individually, that is, $15 
                                       dollars off each and every affected item.
                    -->
                    <AdjustmentType>AllAffectedItems</AdjustmentType>
                  </Adjustment>
                </AdjustmentFunction>
                <RewardPolicy>ALL</RewardPolicy>
              </Reward>
            </RewardChoice>
          </Range>
          <PatternFilter impl="com.ibm.commerce.marketing.promotion.condition.DummyPatternFilter"/>
        </Distribution>
      </PurchaseCondition>
    </Promotion>
  7. Copy the data from your result and paste it in a document. Save this document as an XML document. You can preview this document in a Web browser for readability.