In this previous PR: https://github.com/compucorp/uk.co.compucorp.membershipextras/pull/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 ~.
Hence that I fetch the payment scheme ids for the recurring contributions in the same order CiviCRM core shows them in the recurring contribution tab, so there is no need to index the payment scheme ids by their recurring contribution ids and then check for the id in the JS code.
Before
In this previous PR: https://github.com/compucorp/uk.co.compucorp.membershipextras/pull/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 ~
.