CIWEMB-389: Reword the frequency column for payment scheme recurring contributions #492
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before
In this previous PR: #473 I improved the recurring contribution view page for recurring contributions that uses payment schemes, so they no longer show unnecessary information such as the "Frequency" and the "Cycle Day", though on the recurring contribution tab the "Frequency" tab still shows the frequency information for such recurring contributions.
After
For any recurring contribution linked to a payment scheme, I now replace the frequency information with the following:
~ Payment Scheme ~
to indicate that this recurring contribution uses a payment scheme.Technical Details
The recurring contribution tab is part of the contribution tab and loads with it, so I:
1- Implemented the
pageRun
hook on the contribution tab.2 - And from the existing template variables I fetch the contact's active and inactive recurring contributions (Civi core stores each in one variable).
3 - And then with a single API call for each I fetch the payment scheme id for these recurring contributions (in case there is any) and store them in new template variable.
4 - Then I use the CiviCRM
.extra.tpl
feature to append new template to the contribution tab, this template contains JS code that reads the values from step 3, and then goes through each frequency column (I can tell that by looking if the column contains the word "Every" which is hardcoded inside the recurring contribution tab template in Civi core) , and then I check if that frequency column belongs to a recurring contribution that is linked to a payment scheme, and if so I replace the value of this column with~ Payment Scheme ~
.