Welcome to Zuora Product Documentation

Explore our rich library of product information

Implement the save rate plan plugin

This task guides you through creating and implementing a custom Save Rate Plan Plugin for the SelectProduct component, including setup, registration, and testing.

This article describes the process of creating a sample custom Save Rate Plan Plugin on the SelectProduct component. The sample plugin does the following:

  • Detect and print the numbers of added, removed, updated, and unedited charge groups.
  • Validate if new charge groups were added on save.
  1. Set up rate plans and the association between the rate plans:
    1. In your Zuora Product Catalog, add a product and a rate plan. Name the rate plan "SomeSampleRatePlan".
    2. Perform a Product Catalog Sync.
  2. Create the plugin class and register the new plugin for the SelectProduct component:
    1. In Salesforce, create a new class, SampleImplementationForOnSavePlugin, using the code below.
    2. Navigate to Zuora Config > Component Registration.
    3. Click Edit for the SelectProduct component.
    4. In the Component Plugins section, for the Save Rate Plan Plugin type, specify SampleImplementationForOnSavePlugin in the Class Name field and click Update.​
  3. Test the newly added plugin:
    1. To test the new plug-in, add the Product and its rate plan, SomeSampleRatePlan, to a quote.
    2. When you click Save in the Product Selector, you will see the following error message: 'You are not allowed to add new rate plans to this Quote.'

Save Rate Plan Plugin Example

global class SampleImplementationForOnSavePlugin implements zqu.SelectProductComponentOptions.ISaveRatePlanPlugin {
  public void onSave(List<zqu.zChargeGroup> addedChargeGroups, List<zqu.zChargeGroup> updatedChargeGroups, List<zqu.zChargeGroup> removedChargeGroups, 
  List<zqu.zChargeGroup> persistedChargeGroups){
    System.debug('zuora - SampleImplementationForOnSavePlugin - onSave executed');
    System.debug('zuora - SampleImplementationForOnSavePlugin - addedChargeGroups.size() : ' + addedChargeGroups.size());
    System.debug('zuora - SampleImplementationForOnSavePlugin - updatedChargeGroups.size() : ' + updatedChargeGroups.size());
    System.debug('zuora - SampleImplementationForOnSavePlugin - removedChargeGroups.size() : ' + removedChargeGroups.size());
    System.debug('zuora - SampleImplementationForOnSavePlugin - persistedChargeGroups.size() : ' + persistedChargeGroups.size());
    // Validate addedChargeGroups
    if(addedChargeGroups.size() > 0){
      throw new SavePluginException('You are not allowed to add new rate plans to this Quote.');
    }
  }
  global class SavePluginException extends Exception {}
}