compucorp / uk.co.compucorp.membershipextras

Membership Extras for CiviCRM
Other
5 stars 8 forks source link

CIWEMB-389: Reword the frequency column for payment scheme recurring contributions #492

Closed omarabuhussein closed 1 year ago

omarabuhussein commented 1 year ago

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.

2023-08-08 19_02_21-gfsfd dfssd _ compuclient22sspv3

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.

2023-08-08 18_49_33-gfsfd dfssd _ compuclient22sspv3

2023-08-08 18_51_28-fdfdsfds fdsfsd _ compuclient22sspv3

2023-08-08 18_51_51-fdfdsfds fdsfsd _ compuclient22sspv3

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 ~.