I wrote this class that will trigger after an opportunity gets created but the class doesn't let me save as it comes up with a following error:
Loop must iterate over a collection type: Opportunity
The class goes as follows:
public with sharing class ClassSetPricebook {
public static void pbSet(Opportunity listOpportunity){
ID ehpb = '01s20000000D23DF';
ID euyp = '01s20000000dsfga';
ID sp = '01s2000000051234DA';
ID eu = '01s12000000U21fUIS';
List<Opportunity> opps = [SELECT Id, Name, Quote_Bill_To__c FROM Opportunity Where id =: ApexPages.currentPage().getParameters().get('id') ];
Id billid = null;
Id qubito = opps[0].Quote_Bill_To__c;
CreateQuoteBillTo__c[] quotedet = [SELECT Id, BillToCode__c FROM CreateQuoteBillTo__c where Id = :qubito LIMIT 1];
System.debug('Opportunity Quote Bill to iD: ' + ' ' + opps[0].Quote_Bill_To__c );
System.debug('Bill to code number: ' + ' ' + quotedet.get(0).BillToCode__c );
if(!quotedet.isEmpty() && quotedet.size()>0){
billid = quotedet.get(0).BillToCode__c;
}
for(Opportunity o : listOpportunity) {
if (billid == '822109') {
o.Pricebook2Id = ehpb;
}
else if (billid == '57124') {
o.Pricebook2Id = euyp;
}
}
}
}
the error is at line 22 where the for loop starts, does anyone know how to solve this issue?