Skip to main content

Quote Class

Zuora

Quote Class

This article describes the Quote class, its global methods, and related classes. Use the classes and global methods to programmatically implement bundling.

The Quote class is available in the Versions 7.0 and later of Zuora Quotes.

Quote Class Global Methods

Use the global methods to support bundling in Zuora Quotes. 

Return Type Method Description
Quote buildAndSave()

Inserts the quote into the database, creates Quote Charge Detail records and populates quoteProducts.

For the new subscription quotes with a new billing account being created, you need to set the AccountId field to null before calling the buildAndSave method. 

Check the billingAccountId field in the URL parameter in your NewQuoteController.cls. If this field is present and has a value then just call buildAndSave; otherwise add the below line in prior to calling the buildAndSave method.

this.quote.zquZuora__AccountId__c = null;.

Available in Zuora Quotes V. 7.3+.

QuoteCloneResponse Quote.cloneQuote
(CloneQuoteOptions cloneOptions)

Clones a single quote.

In the cloneOptions, you can specify whether or not to clone the Product structure associated with the quote. You can clone the products only for the New Subscription quotes.

Custom fields are cloned. See Clone a Quote for cloning custom fields.

The cloned Quote class instance is not saved. You must use the Quote.buildAndSave method to initially save the cloned Quote.

If the bundling is enabled, this method also clones any bundles associated with the quote.

Available in Zuora Quotes V. 7.3+.

Quote createNewInstance
(zqu__Quote__c quoteSObject)

Creates a new Quote instance from a zqu__Quote__c SObject instance.

Available in Zuora Quotes V. 7.3+.

Quote Quote.getNewInstance() 

Creates a new instance of the Quote object and commits it to the database using default values from Zuora Config.

This method is NOT supported in 7.2 and later versions of Zuora Quotes.

Quote Quote.getInstance(Id quoteId)  Returns an instance of the existing Quote object.
zqu__Quote__c Quote.getSObject() Returns the zqu__Quote__c SObject.
Id Quote.getId() Returns the Id of the zqu__Quote__c SObject.
List <QuoteProduct>  Quote.getAddedQuoteProducts( ) Returns the quote products that have been added to this quote since the last save call.
List <QuoteProduct> 
 
Quote.getUpdatedQuoteProducts( ) Returns the quote products that have been updated since the last save call.
List <QuoteProduct> 
 
Quote.getDeletedQuoteProducts( ) Returns the quote products that have been removed from this quote since the last save call.
List <QuoteProduct> 
 
Quote.getOriginalQuoteProducts( ) Returns all other quote products that have not been changed since the last save call.
List <QuoteProduct>  Quote.getQuoteProducts( ) Loads a list of existing quote products that have already been saved to the database for this quote. 
List <QuoteProduct>  Quote.addQuoteProducts
(List <Product> products)
Adds products as QuoteProducts. This method doesn't commit to database.
List <QuoteProduct > Quote.updateQuoteProducts
(List <QuoteProduct> products)
Marks a list of Quote products for update.
List <QuoteProduct > Quote.deleteQuoteProducts
(List <QuoteProduct> products)
Marks a list of Quote products for delete.
List <QuoteProduct > Quote.save()

Checks for changes to the QuoteProducts and commits the changes to database.

Quote set
(String fieldName, Object fieldValue)

Sets value on the quote sObject.

Available in Zuora Quotes V. 7.3+.

CloneQuoteOptions Class

The CloneQuoteOptions class contains an input parameter to the Quote.cloneQuote global method.

Property Type Description
shouldCloneProducts Boolean Indicates whether or not to clone the Product structure associated with the quote. This is only applicable to New Subscription Quotes.

QuoteCloneResponse Class

The QuoteCloneResponse class returned by the cloneQuote method has the following properties.

You must use the Quote.buildAndSave method to initially save a cloned quote.

Property Type Description
clonedQuote zqu.Quote

The in-memory Quote class instance. 

The zqu__Quote__c object and other associated objects in the Product structure have not yet been saved to the database.

errorMessage String Contains the first error encountered when attempting to clone the quote
isSuccess Boolean Indicates whether or not the quote was cloned successfully

QuoteProduct Class

The QuoteProduct class has the following properties.

Property Type Required? Description
chargeGroup zqu.zChargeGroup Required The charge group of the QuoteProduct.
childProducts List<zqu.ChildQuoteProduct > n/a For read only.
Id Id (Product2) n/a The Id of the product. For read only.
productGroups List<zqu.QuoteProductGroup > n/a

The list of product groups on this quote rate plan.

For read only.

productName String    
ratePlanActions List<zqu.zChargeGroup>   A list of all existing future actions on the Quote Product.
ratePlanActionsToBeAdded List<zqu.zChargeGroup>   A list of actions that will be added to the Quote Product.
ratePlanActionsToBeDeleted List<zqu.zChargeGroup>   A list of actions that need to be removed.
ratePlanActionsToBeUpdated List<zqu.zChargeGroup>   A list of actions that need to be updated.
type zqu.QuoteProduct.ProductType n/a  

 

The QuoteProduct class has the following methods.

Return Type Method Description
void addRatePlanActions (List<zqu.zChargeGroup>) Sets the future actions for the current quote product.
void deleteRatePlanActions (List<zqu.zChargeGroup>) Removes some of the future actions for the current quote product.
void updateRatePlanActions (List<zqu.zChargeGroup>) Updates information on the future dated actions.

ChildQuoteProduct Class

The ChildQuoteProduct class extends the QuoteProduct class and has the following properties in addition to the properties inherited from the QuoteProduct class. All properties are for read only.

Property Type Description
productOptionType 

zqu.ChildQuoteProduct.OptionType

The following values are supported:

  • INCLUDED
  • REQUIRED
  • RECOMMENDED
  • OPTIONAL
snapshotProductOption zqu__ProductOption__c

An instance of the zqu__ProductOption__c for this quote child product.

Deprecated as of Zuora Quotes Version 7.3.

snapshotProductRatePlanOption zqu__ProductRatePlanOption__c

An instance of the zqu__ProductRatePlanOption__c for this quote child product.

Deprecated as of Zuora Quotes Version 7.3.

snapshotChargeOptions Map
<Id, zqu__ProductRatePlanChargeOption__c>

An instance of the zqu__ProductRatePlanChargeOption__c for this quote child product.

Deprecated as of Zuora Quotes Version 7.3.

QuoteProductGroup Class

The QuoteProductGroup class has the following properties. All properties are for read only.

Property Type Description
childQuoteProducts List <ChildQuoteProduct > For read only.
productGroupId Id (zqu__ProductGroup__c) Id of the ProductOptionGroup__c SObject.
minOption Integer Minimum number of options required in the product group.
maxOption Integer Maximum number of options allowed in the product group.
name String Name of this product group.
snapshotProductGroup zqu__ProductOptionGroup__c

An instance of the zqu__ProductOptionGroup__c SObject for this quote product group.

Deprecated as of Zuora Quotes Version 7.3.

Sample Code

Code Example 1

The following sample code shows a high level example of adding a bundle to a quote.

//Get an existing quote by Id
zqu.Quote currentQuote = zqu.Quote.getInstance('<quoteId>');

//Add products to the Quote
List<zqu.Product> productsToAdd = zqu.Product.loadProductsWithChildren(new List<Id>{'product1Id', 'product2Id'});
List<zqu.QuoteProduct> addedProducts = currentQuote.addQuoteProducts(productsToAdd);

//Commit the products to the database
currentQuote.save();

Code Example 2

The following code snippet retrieves the quote object and sets the start date on the quote.

//Get an existing quote by Id
zqu.Quote currentQuote = zqu.Quote.getInstance('<quoteId>');

//Get the SObject for the Quote
zqu__Quote__c quoteSObject = currentQuote.getSObject();
quoteSObject.zqu__StartDate__c = Date.today();

//Commit the quote to the database
currentQuote.save();

Code Example 3

The following sample code creates an amendment quote in Zuora Quotes V. 7.3+.

//Create a new Quote
zqu__Quote__c quoteSObject = new zqu__Quote__c();
quoteSObject.zqu__SubscriptionType__c = 'Amend Subscription';
quoteSObject.zqu__ZuoraAccountId__c =
   ApexPages.currentPage().getParameters().get('existingAccountId');
quoteSObject.zqu__ExistSubscriptionId__c =
   ApexPages.currentPage().getParameters().get('existingSubscriptionId');
  
zqu.Quote amendmentQuote = zqu.Quote.createNewInstance(quoteSObject);
 
// Quote and Quote Charge Details inserted to database here
amendmentQuote.buildAndSave();
 
 //Add products to the Quote
List<zqu.Product> productsToAdd = zqu.Product.loadProductsWithChildren(new List<Id>{'product1Id', 'product2Id'});
List<zqu.QuoteProduct> addedProducts = amendmentQuote.addQuoteProducts(productsToAdd);
 
// Creates/updates/deletes Quote Charge Detail records
// based on changes made to the Quote Products
amendmentQuote.save();

Code Example 4

The following code snippet clones a quote in Zuora Quotes V. 7.3+.

//Load an existing quote
zqu.Quote existingQuote = zqu.Quote.getInstance(quoteId);

//populate the clone options
zqu.CloneQuoteOptions options = new zqu.CloneQuoteOptions();
options.shouldCloneProducts = true;

//clone the quote
zqu.QuoteCloneResponse cloneResponse = existingQuote.cloneQuote(options);

//save the cloned quote
if (cloneResponse.isSuccess) {
    zqu.Quote clonedQuote = cloneResponse.clonedQuote;
    clonedQuote.buildAndSave();
}