[#5] Add a setting for differentiating membership types depending on donation rhythm

This commit is contained in:
Jens Schuppe 2020-01-22 12:51:15 +01:00
parent cd7c7e7d12
commit bc9baea6f2
5 changed files with 38 additions and 17 deletions

View file

@ -325,6 +325,14 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
FALSE, // is not required
array('class' => 'crm-select2 huge')
);
$this->add(
'select', // field type
'membership_type_id_recur', // field name
E::ts('Create membership of type (recurring)'), // field label
array('' => E::ts('- none -')) + static::getMembershipTypes(), // list of options
FALSE, // is not required
array('class' => 'crm-select2 huge')
);
$this->add(
'text', // field type

View file

@ -214,6 +214,7 @@ class CRM_Twingle_Profile {
'contribution_source',
'custom_field_mapping',
'membership_type_id',
'membership_type_id_recur',
),
// Add payment methods.
array_keys(static::paymentInstruments()),
@ -283,6 +284,7 @@ class CRM_Twingle_Profile {
'contribution_source' => NULL,
'custom_field_mapping' => NULL,
'membership_type_id' => NULL,
'membership_type_id_recur' => NULL,
)
// Add contribution status for all payment methods.
+ array_fill_keys(array_map(function($attribute) {

View file

@ -42,7 +42,7 @@ project ID from any other profile. Therefore the default profile will be used
for all newly created Twingle projects.
| Label | Description |
|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|---------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Profile name | Internal name, used inside the extension. |
| Project IDs | Twingle project IDs. Separate multiple IDs with commas. |
| Location type | Specify how the address data sent by the form should be categorised in CiviCRM. The list is based on your CiviCRM configuration. |
@ -54,7 +54,8 @@ for all newly created Twingle projects.
| Record *Payment method* as | Specifiy the payment methods mapping for incoming donations for each Twingle payment method. |
| Sign up for groups | Whenever the donor checked the newsletter/postal mailing/donation receipt checkbox on the Twingle form, the contact will be added to the groups listed here. |
| Assign donation to campaign | The donation will be assigned to the selected campaign. If a campaign ID is being submitted using the `campaign_id` parameter, this setting will be overridden with the submitted value. |
| Create membership of type | A membership of the selected type will be created for the Individual contact. If no membership type is selected, no membership will be created. |
| Create membership of type | A membership of the selected type will be created for the Individual contact for incoming one-time donations. If no membership type is selected, no membership will be created. |
| Create membership of type (recurring) | A membership of the selected type will be created for the Individual contact for incoming recurring donations. If no membership type is selected, no membership will be created. |
| Contribution source | The configured value will be set as the "Source" field for the contribution. |
| Custom field mapping | Additional field values may be set to CiviCRM custom fields using a mapping. See the option's help text for the exact format. |

View file

@ -648,7 +648,13 @@ function civicrm_api3_twingle_donation_Submit($params) {
}
// Create membership if a membership type is configured within the profile.
if (!empty($membership_type_id = $profile->getAttribute('membership_type_id'))) {
if ($params['donation_rhythm'] != 'one_time') {
$membership_type_id = $profile->getAttribute('membership_type_id_recur');
}
else {
$membership_type_id = $profile->getAttribute('membership_type_id');
}
if (!empty($membership_type_id)) {
$membership = civicrm_api3('Membership', 'create', array(
'contact_id' => $contact_id,
'membership_type_id' => $membership_type_id,

View file

@ -211,6 +211,10 @@
<td class="label">{$form.membership_type_id.label}</td>
<td class="content">{$form.membership_type_id.html}</td>
</tr>
<tr class="crm-section">
<td class="label">{$form.membership_type_id_recur.label}</td>
<td class="content">{$form.membership_type_id_recur.html}</td>
</tr>
<tr class="crm-section">
<td class="label">{$form.contribution_source.label}</td>