Overview of implementing a new low-level promotion element

You can perform a more complex customization of the promotion engine by creating new promotion elements. For example, you might want to create a new adjustment element to assign a new reward type to qualifying orders.

About this task

To create a new low level promotion element, there are 5 steps.

Procedure

  1. Determine what kind of promotion your store requires.
    WebSphere Commerce provides a rich set of default promotion types, including purchase conditions which apply at either the product level or the order level. The rewards target individual catalog entries, the entire order, or the related shipping charges. An additional default promotion type is called purchase with purchase, in which a customer who purchases some catalog entry gets some other catalog entry at a discount. Comparing your requirements against the existing promotion types to determine whether you can reuse elements of the default promotions to simplify your customization. This can save a lot of time compared with implementing something entirely new.
  2. Understand the promotion XML presentation of your new element and build it.
    Refer to the promotionXML example. This promotion XML sample explains the usage of the major XML nodes in one promotion. In addition, the Adding support for a custom promotion type example further explains some of the options available in terms of replacing or customizing the existing nodes.

    Once you understand the XML representation of a the new promotion element;

    1. If possible, find a similar promotion element from the default elements.
    2. Create the new promotion element.
    3. Retrieve the necessary XML from the database.
    4. Replace the node with your own element.
    5. Manually create the custom promotion type in the database.
    6. Test your custom promotion.
  3. Understand where the promotion is persisted and cached.
    Promotion data is mainly stored in the PX_PROMOTION table. Refer to storing custom promotion XML in the database for details about how and where to store the promotion's XML representation. To test a new promotion XML for the customization type, refer to custom promotion types.
  4. Create any necessary custom Java code for your new element.
    This code at the very least will have to manage changing the element to XML and back to strings that are readable in the user interface. You should create your class so that it extends XMLizable. This will inherit some useful methods for converting the promotion element to XML and back. You will also need to provide methods that handle the element's behavior.
  5. Update the user interface as needed.
    This step should be done once you have a promotion XML that represents your business logic. To customize the WebSphere Commerce Accelerator, so that it generates XML according to your requirements, refer to Adding support for a custom promotion type as a guideline.