Skip to content

Commit

Permalink
Merge pull request #1 from MarcMichalsky/patch_the_patch
Browse files Browse the repository at this point in the history
Add upgrade method
  • Loading branch information
mariav0 authored Jun 5, 2023
2 parents f7612b3 + 02a8bb7 commit c1ae661
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions CRM/Twingle/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,29 @@ public function upgrade_5140() {

return TRUE;
}

/**
* Add the "generic" payment instrument with default values to all profiles
* to avoid "Payment method could not be matched to existing payment
* instrument." error.
*
* @return TRUE on success
* @throws Exception
*/
public function upgrade_5150() {
$this->ctx->log->info('Add "generic" payment instrument to all profiles.');

$profiles = CRM_Twingle_Profile::getProfiles();
if ($profiles) {
foreach ($profiles as $profile) {
if (!$profile->getAttribute('pi_generic', False)) {
$profile->setAttribute('pi_generic', 1);
$profile->setAttribute('pi_generic_status', 1);
$profile->saveProfile();
}
}
}

return TRUE;
}
}

0 comments on commit c1ae661

Please sign in to comment.