Knowledge Center

Knowledge Center > Commerce > Zuora for Salesforce Development Resources > Zuora for Salesforce Component Library > Zuora for Salesforce Global Components > QuotePreview Component

QuotePreview Component

The QuotePreview component provides Zuora Quotes developers the ability to customize the Order Preview page, which appears when you click Send to Zuora. The QuotePreview component supports:

  • A plug-in to insert a custom sendToZBilling method call.
  • Logic to block Create Order requests if certain validation criteria are not met.
  • Logic to configure the visual attributes of the page, such as section titles, section expand and collapse, button bar location, and an embedded custom notification component.
  • A component body to insert custom Visualforce content.

The following is an example of the user interface built using the QuotePreview component:

OrderPreview.png

The QuotePreview component is available in the Version 6.0 and later of Zuora Quotes.

The QuotePreview component consists of the following:

  • zqu.QuotePreview.component:The Visualforce component containing the configurable Property component and SelectProduct component.
  • zqu.QuotePreviewOptions.cls: An apex class that contains all the configuration options you specified on the QuotePreview component.
  • zqu.QuotePreviewController: An apex class that handles the backend logic and sets up the visual parts of the QuotePreview component. Any page controller embedding the QuotePreview component should extend this controller,

QuotePreview Component Attributes

The QuotePreview component has the following attributes/

Attribute Type Required Description
id String No An identifier that allows the component to be referenced by other components in the page.
options zqu.QuotePreviewOptions N/A

The configuration options for the component.

See the next table for detail.

rendered Boolean No Specifies whether the component is rendered on the page. 
The default value is True.

QuotePreviewOptions Class

QuotePreviewOptions Class Properties

The QuotePreviewOptions class includes the following properties.

Property Type Required? Description
buttonBarLocation String No

The location of the button bar.

Supported values are:

  • top
  • bottom
  • both
createOrderPlugin String No

The fully qualified name of the ICreateOrder plug-in interface used to send the quote to Zuora.

This plug-in is called when the user clicks Submit.

DEFAULT_CREATE_ORDER_PLUGIN static String No Name of the default CreateOrder plug-in
disableCreateButton Boolean No

If True, blocks users from sending the quote to Zuora when a validation fails.

The default is False.

hideButtonBar Boolean No

If True, the button bar does not render.

The default is False.

hideQuoteProperty Boolean No

If True, the quote property component does not render.

The default is False.

hideSelectedProducts Boolean No

If True, the selected products component does not render.

The default is False.

isSelectedProductsCollapsible Boolean No

If True, the page block section containing the selected products is collapsible.

The default is False.

notificationOptions zqu.
NotificationOptions
No Configuration options for the notification component embedded in this component.
previewController zqu.
QuotePreviewController
Yes This reference allows developers to access instance variables of the page controller from within the CreateOrder plug-in.
quoteId String Yes The ID of the quote to preview
quotePropertyTitle String No The title of the quote property component
selectedProductsTitle String No The title of the page block section containing the selected products
VALID_BUTTON_LOCATIONS static SET No The location of the menu buttons. Supported values are:
  • top
  • bottom
  • both

Create Order Plugin

The QuotePreview component provides the Create Order Plugin. The Create Order Plugin is used to send a quote to Zuora. This plug-in is executed when the user clicks Submit on the Order Preview page.

The Create Order plugin interface is defined as:

global zqu.QuotePreviewController.ICreateOrderPlugin

The plugin contains the following interface method:

PageReference CreateOrder (zqu.QuotePreviewController)

See below for a sample code for the Create Order Plugin.

Sample Code

Sample Apex Class

The following is a sample implementation of the Quote Preview controller:

public with sharing class CustomQuotePreviewSample extends zqu.QuotePreviewController {
  /*CLASS VARIABLES*/
  public static final String BLANK_CONTACT_ERROR_MESSAGE = 'A quote must have a valid bill to contact and sold to contact to be sent to Zuora. Click Go Back to return to the quote\'s detail page';
  public static final String QUOTE_SUBMIT_SUCCESS = 'Quote was successfully submitted to Zuora!';

  /*INSTANCE VARIABLES*/
  // Configuration options for quote preview component
  public zqu.QuotePreviewOptions previewOptions {
    get;
    set;
  }
  // Configuration options for notification component within quote preview component
  public zqu.NotificationOptions notificationOptions {
    get;
    set;
  }
  // Handler to the quote object
  private zqu__Quote__c quote {
    get;
    set;
  }
  // Constructor
  public CustomQuotePreviewSample(ApexPages.StandardController stdController) {
    // Ensure that the BillTo/SoldTo contacts are accessible
    if (!Test.isRunningTest()) stdController.addFields(new List < String > {
      'zqu__BillToContact__c', 'zqu__ElectronicPaymentMethodId__c', 'zqu__Opportunity__r.AccountId', 'zqu__SoldToContact__c', 'zqu__ZuoraAccountID__c'
    });
    // Get quote object
    quote = (zqu__Quote__c) stdController.getRecord();
    // Initialize preview options
    previewOptions = new zqu.QuotePreviewOptions();
    // Pass quote id to the preview options
    previewOptions.quoteId = stdController.getId();
    // Set display options
    previewOptions.buttonBarLocation = 'top';
    previewOptions.quotePropertyTitle = 'Quote Details';
    previewOptions.selectedProductsTitle = 'Selected Products and Rate Plans';
    previewOptions.isSelectedProductsCollapsible = true;
    // Set preview controller and CreateOrderPlugin
    previewOptions.previewController = this;
    previewOptions.createOrderPlugin = 'CustomQuotePreviewSample.CreateOrderPlugin';
    // Initialize the notification options
    notificationOptions = new zqu.NotificationOptions();

    // If the quote is missing a Bill To Contact or Sold To Contact, disable the create order button
    // and display a popup message for the error
    if (quote.zqu__BillToContact__c == null || quote.zqu__SoldToContact__c == null) {
      previewOptions.disableCreateButton = true;
      notificationOptions.failureBody = BLANK_CONTACT_ERROR_MESSAGE;
      notificationOptions.isPopup = true;
      notificationOptions.backAction = 'toQuoteDetail();';
    }
    // Set configuration options for notification component within quote preview component
    previewOptions.notificationOptions = notificationOptions;
  }
  // Method to return to quote's detail page from notification popup
  public PageReference toQuoteDetail() {
    return new PageReference('/' + quote.Id);
  }
  // Plugin implementation of ICreateOrder interface
  public class CreateOrderPlugin implements ICreateOrderPlugin {
    public PageReference CreateOrder(zqu.QuotePreviewController qpc) {
      // Cast plugin instance
      CustomQuotePreviewSample previewController = (CustomQuotePreviewSample) qpc;
      //Retrieve quote object from outer controller
      zqu__Quote__c quote = previewController.quote;
      if (quote == null) return null;
      // Retrieve config information
      Map < String, Object > zqconfig = zqu.zQuoteUtil.getZuoraConfigInformation();
      List < zqu.zQuoteUtil.ZBillingQuoteCollection > quotes = new List < zqu.zQuoteUtil.ZBillingQuoteCollection > ();
      zqu.zQuoteUtil.ZBillingQuoteCollection quoteCol = new zqu.zQuoteUtil.ZBillingQuoteCollection();
      // Set Account ID on collection
      if (String.isNotEmpty(quote.zqu__Opportunity__r.AccountId)) {
        quoteCol.sfdcAccountId = quote.zqu__Opportunity__r.AccountId;
      }
      quoteCol.zAccountId = String.isEmpty(quote.zqu__ZuoraAccountId__c) ? 'new' : quote.zqu__ZuoraAccountId__c;
      quoteCol.quoteRequests = new List < zqu.zQuoteUtil.ZBillingQuoteRequest > ();
      zqu.zQuoteUtil.ZBillingQuoteRequest req = new zqu.zQuoteUtil.ZBillingQuoteRequest();
      req.sfdcQuoteId = quote.Id;
      //Set the payment method id on request from the quote if not null
      if (String.isNotBlank(quote.zqu__ElectronicPaymentMethodID__c)) {
        req.paymentMethodId = quote.zqu__ElectronicPaymentMethodID__c;
      }
      //Set generate invoice flag on request
      req.generateInvoice = (Boolean) zqconfig.get('Generate_Invoice__c');
      //Set process payments flag on the request
      Boolean processPayment = (Boolean) zqconfig.get('Process_Payments__c') == null ? false : (Boolean) zqconfig.get('Process_Payments__c');
      req.processPayment = processPayment && String.isNotBlank(quote.zqu__ZuoraAccountID__c);
      quoteCol.quoteRequests.add(req);
      quotes.add(quoteCol);
      //Send request
      List < zqu.zQuoteUtil.zBillingResult > results = Test.isRunningTest() ?
        new List < zqu.zQuoteUtil.zBillingResult > {CustomQuotePreviewSampleTest.testZBillingResult} :
        zqu.zQuoteUtil.sendToZBilling(quotes);
      //Display results using popup notification component
      previewController.notificationOptions.isPopup = true;
      //If zBillingResult was successful, navigate to Subscription Confirmation page. If not, display error message on current page
      for (zqu.zQuoteUtil.zBillingResult result: results) {
        if (result.success) {
          //Enable popup notification with OK button redirecting to quote detail page
          previewController.notificationOptions.continueAction = 'hidePopupNotification();displayStatusModal();toQuoteDetail();';
          previewController.notificationOptions.backAction = '';
          //Post confirmation message
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, QUOTE_SUBMIT_SUCCESS));
        }
        else {
          //Enable popup notification with cancel button only
          previewController.notificationOptions.continueAction = '';
          previewController.notificationOptions.backAction = 'hidePopupNotification();displayStatusModal();toQuoteDetail();';
          //Post error message
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, result.message));
        }
      }
      //Stay on current page
      return null;
    }
  }
}

Sample Visualforce Page

The following is a sample Visualforce page for Quote Preview:

<apex:page showHeader="true" sidebar="false" standardController="zqu__Quote__c" extensions="CustomQuotePreviewSample" >
    <apex:form >
        <zqu:QuotePreview options="{!previewOptions}" >
            Custom content placed in the component body like this will be rendered beneath the Select Products component!
        </zqu:QuotePreview >
        <!-- Action function to return to quote detail page from popup notification component -->
        <apex:actionFunction name="toQuoteDetail" action="{!toQuoteDetail}" />
    </apex:form>
</apex:page>
Last modified
14:09, 5 Oct 2016

Tags

This page has no custom tags.

Classifications

(not set)