"Contribution Source" profile field has no effect on new contribution
Overview
Profiles allow inclusion of the "Contributions :: Contribution Source" on contribution pages, but any value entered therein is disregarded when saving a new contribution.
Steps to reproduce (on dmaster.demo.civicrm.org)
Reproduction steps
- Start with the Name and Address profile, and add to this profile the field "Contributions :: Contribution Source"
- Add this profile to a Contribution Page, e.g., "Help Support CiviCRM!"
- Open the Contribution Page, and fill in the form to submit an online contribution; for the Contribution Source field, enter a testable value such as "test source".
- Submit the contribution
- Find the contribution in CiviCRM, and open it; examine the value of the "Source" field.
Current behaviour
- The "Source" field reads "Online Contribution: Help Support CiviCRM!"
Expected behaviour
- The "Source" field should read "test source"
Environment information
The above repro steps were performed today on dmaster.demo.civicrm.org.
Comments
Testing on local dev indicates that a PR like this would produce the expected behavior:
diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php
index a9e84fa..8bbb2c5 100644
--- a/CRM/Contribute/BAO/Contribution/Utils.php
+++ b/CRM/Contribute/BAO/Contribution/Utils.php
@@ -83,6 +83,9 @@ class CRM_Contribute_BAO_Contribution_Utils {
$form->_values['amount'] = $form->_params['amount'];
}
+ if (isset($paymentParams['contribution_source'])) {
+ $paymentParams['source'] = $paymentParams['contribution_source'];
+ }
if ($isPaymentTransaction) {
$contributionParams = [
'id' => $paymentParams['contribution_id'] ?? NULL,
@@ -142,9 +145,6 @@ class CRM_Contribute_BAO_Contribution_Utils {
$paymentParams['contributionID'] = $contribution->id;
$paymentParams['contributionPageID'] = $contribution->contribution_page_id;
- if (isset($paymentParams['contribution_source'])) {
- $paymentParams['source'] = $paymentParams['contribution_source'];
- }
if (!empty($form->_params['is_recur']) && $contribution->contribution_recur_id) {
$paymentParams['contributionRecurID'] = $contribution->contribution_recur_id;