Knowledge Center

Knowledge Center > Commerce > Zuora for Salesforce Development Resources > Zuora for Salesforce Component Library > Zuora for Salesforce Global Classes > Quote Class

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.

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
Id Id (Product2) n/a The Id of the product. For read only.
chargeGroup zqu.zChargeGroup Required The charge group of the QuoteProduct.
type zqu.QuoteProduct.ProductType Enum n/a

Supported values are:

  • Standalone
  • Bundle

For read only.

childProducts List <ChildQuoteProduct > n/a For read only.
productGroups List <QuoteProductGroup > n/a

The list of product groups on this quote rate plan.

For read only.

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.
snapshotProductRatePlanOption zqu__ProductRatePlanOption__c An instance of the zqu__ProductRatePlanOption__c for this quote child product.
snapshotChargeOptions Map
<Id, zqu__ProductRatePlanChargeOption__c>
An instance of the zqu__ProductRatePlanChargeOption__c for this quote child product.

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.

Sample Code

Code Example 1

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

Quote quote = Quote.getInstance('Q1');

// Retrieve a copy of the quote products
List<QuoteProduct> quoteProducts = quote.getQuoteProducts(); 

// User selects "Speedy" plan of "Vehicle Diagnostics"
quoteProducts[0].zChargeGroups[1].selected = true;

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

Code Example 2

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

Quote quote = new Quote.getInstance(quoteId);
zqu__Quote__c quoteObject = quote.getSObject();
quoteObject.StartDate__c = Date.Today();
quote.save();

Code Example 3

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

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();

amendmentQuote.deleteProducts(quoteProductsToDelete);
amendmentQuote.addProducts(quoteProductsToAdd);

// Creates/updates/deletes Quote Charge Detail records 
// based on changes made to quoteProducts
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 clonedQuote = existingQuote.cloneQuote(options);

//save the cloned quote
zqu.Quote clonedQuote = clonedQuoteResp.clonedQuote;
clonedQuote.buildAndSave();

 

Last modified
18:36, 6 Sep 2016

Tags

This page has no custom tags.

Classifications

(not set)