/** * Take any Billing and Shipping Contacts and link the to the Opportunity * * @param Quote $quote * @param Opportunity $opp */ protected function linkQuoteContactsToOpportunity(Quote $quote, Opportunity $opp) { // @codeCoverageIgnoreStart global $app_list_strings; // @codeCoverageIgnoreEnd //opportunity_relationship_type_dom $quote->load_relationship('shipping_contacts'); $quote->load_relationship('billing_contacts'); $ids = array_merge($quote->shipping_contacts->get(), $quote->billing_contacts->get()); $ids = array_unique($ids); $default_role = isset($app_list_strings['opportunity_relationship_type_dom']['Other']) ? 'Other' : ''; if (!empty($ids)) { $opp->load_relationship('contacts'); foreach ($ids as $id) { $opp->contacts->add($id, array('contact_role' => $default_role)); } } }