Skip to content
Snippets Groups Projects
Commit d509d40b authored by mattwire's avatar mattwire
Browse files

Update beginChangeSubscriptionAmount() function

parent d5a529aa
No related branches found
No related tags found
No related merge requests found
......@@ -503,25 +503,19 @@ trait CRM_Core_Payment_MJWTrait {
* ];
*/
$propertyBag = PropertyBag::cast($params);
$propertyBag->setContributionRecurID($params['id']);
$propertyBag->setContributionRecurID($params['contributionRecurID'] ?? $params['id']);
$propertyBag->setIsRecur(TRUE);
// @fixme We can't use $propertyBag->setRecurInstallments until https://github.com/civicrm/civicrm-core/pull/21517 is merged
// Use $propertyBag->has('recurInstallments') ? $propertyBag->getRecurInstallments() : 0; in code as workaround
// if (empty($params['installments'])) {
// $propertyBag->setRecurInstallments(0);
// }
$existingRecur = ContributionRecur::get(FALSE)
->addWhere('is_test', 'IN', [TRUE, FALSE])
->addWhere('id', '=', $propertyBag->getContributionRecurID())
->execute()
->first();
// @fixme: https://github.com/civicrm/civicrm-core/pull/21517
if (!$propertyBag->has('recurInstallments') && !empty($existingRecur['installments'])) {
$propertyBag->setRecurInstallments($existingRecur['installments']);
}
$propertyBag->setRecurInstallments($existingRecur['installments'] ?? 0);
$propertyBag->setRecurFrequencyInterval($existingRecur['frequency_interval']);
$propertyBag->setRecurFrequencyUnit($existingRecur['frequency_unit']);
$propertyBag->setCurrency($params['currency'] ?? $existingRecur['currency']);
$propertyBag->setCustomProperty('error_url', $this->getErrorUrl($propertyBag));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment