Implement a guided selling flow plugin
This task guides you through creating a custom Guided Selling Flow Plugin for the SelectProduct component, displaying flows based on quote types.
This article describes the process of creating a sample custom Guided Selling Flow Plugin on the SelectProduct component. The sample plug-in displays the corresponding Guided Selling Flows based on the quote type, New Subscription or Amendment/Renewal.
- create a new plugin and register.
- Navigate to Zuora Config > Guided Product Selectors.
- Create Guided Selling Flows, New Service Flow and Amend Service Flow. Save the flows.
- Create a new class, GuidedSellingFlowPluginImpl, using the code below.
- Navigate to Zuora Config > Component Registration.
- Click Edit for the SelectProduct component.
- In the Component Plugins section, for the Guided Selling Flow Plugin type, specify GuidedSellingFlowPluginImpl in the Class Name field.
- Click Update.
- test the new plug-in
- Create a quote for New Subscription.
- When you get to the Choose Product and Charges step, you see the Guided Selling Flows whose label starts with "New"..
@isTest
public class GuidedSellingFlowPluginImplTest {
@isTest
static void testGetFlows() {
Account acc = new Account(name='Test Account');
insert acc;
Contact billTo = new Contact(FirstName = 'BillToFName', LastName =
'BillToLName');
billTo.accountId = acc.Id;
Contact soldTo = new Contact(FirstName = 'SoldToFName', LastName =
'SoldToLName');
soldTo.accountId = acc.Id;
Contact[] contacts = new List<Contact>{ billTo, soldTo };
insert contacts;
zqu__Quote__c quote = new zqu__Quote__c();
quote.Name = 'test quote';
quote.zqu__Account__c = acc.Id;
quote.zqu__SubscriptionType__c = 'New Subscription';
insert quote;
zqu__GuidedSellingFlow__c flow = new zqu__GuidedSellingFlow__c();
flow.Name = 'New Flow';
flow.zqu__IncludeInProductSelector__c = true;
insert flow;
GuidedSellingFlowPluginImpl gsfp = new GuidedSellingFlowPluginImpl();
gsfp.getFlows(quote.Id);
}
}Test Class for Guided Selling Flow Plugin
The following is a APEX test class code sample for Guided Selling Flow Plugin. You can use the test class to achieve code coverage on the plugin in Salesforce.@isTest
public class GuidedSellingFlowPluginImplTest {
@isTest
static void testGetFlows() {
Account acc = new Account(name='Test Account');
insert acc;
Contact billTo = new Contact(FirstName = 'BillToFName', LastName =
'BillToLName');
billTo.accountId = acc.Id;
Contact soldTo = new Contact(FirstName = 'SoldToFName', LastName =
'SoldToLName');
soldTo.accountId = acc.Id;
Contact[] contacts = new List<Contact>{ billTo, soldTo };
insert contacts;
zqu__Quote__c quote = new zqu__Quote__c();
quote.Name = 'test quote';
quote.zqu__Account__c = acc.Id;
quote.zqu__SubscriptionType__c = 'New Subscription';
insert quote;
zqu__GuidedSellingFlow__c flow = new zqu__GuidedSellingFlow__c();
flow.Name = 'New Flow';
flow.zqu__IncludeInProductSelector__c = true;
insert flow;
GuidedSellingFlowPluginImpl gsfp = new GuidedSellingFlowPluginImpl();
gsfp.getFlows(quote.Id);
}
}