[#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 FALSE, // is not required
array('class' => 'crm-select2 huge') 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( $this->add(
'text', // field type 'text', // field type

View file

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

View file

@ -41,22 +41,23 @@ The *default* profile is used whenever the plugin cannot match the Twingle
project ID from any other profile. Therefore the default profile will be used project ID from any other profile. Therefore the default profile will be used
for all newly created Twingle projects. for all newly created Twingle projects.
| Label | Description | | Label | Description |
|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |---------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Profile name | Internal name, used inside the extension. | | Profile name | Internal name, used inside the extension. |
| Project IDs | Twingle project IDs. Separate multiple IDs with commas. | | 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. | | Location type | Specify how the address data sent by the form should be categorised in CiviCRM. The list is based on your CiviCRM configuration. |
| Location type for organisations | Specify how the address data sent by the form should be categorised in CiviCRM for organisational donations. The list is based on your CiviCRM configuration. | | Location type for organisations | Specify how the address data sent by the form should be categorised in CiviCRM for organisational donations. The list is based on your CiviCRM configuration. |
| Financial type | Specify which financial type incoming one-time donations should be recorded with in CiviCRM. The list is based on your CiviCRM configuration. | | Financial type | Specify which financial type incoming one-time donations should be recorded with in CiviCRM. The list is based on your CiviCRM configuration. |
| Financial type (recurring) | Specify which financial type incoming recurring donations should be recorded with in CiviCRM. The list is based on your CiviCRM configuration. | | Financial type (recurring) | Specify which financial type incoming recurring donations should be recorded with in CiviCRM. The list is based on your CiviCRM configuration. |
| CiviSEPA creditor | When enabled to integrate with CiviSEPA, specify the CiviSEPA creditor to use. | | CiviSEPA creditor | When enabled to integrate with CiviSEPA, specify the CiviSEPA creditor to use. |
| Gender options | Specify which CiviCRM gender option the incoming Twingle gender value should be mapped to. The list is based on your CiviCRM configuration. | | Gender options | Specify which CiviCRM gender option the incoming Twingle gender value should be mapped to. The list is based on your CiviCRM configuration. |
| Record *Payment method* as | Specifiy the payment methods mapping for incoming donations for each Twingle payment method. | | 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. | | 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. | | 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. |
| Contribution source | The configured value will be set as the "Source" field for the contribution. | | 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. |
| 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. | | 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. |
## API documentation ## API documentation

View file

@ -648,7 +648,13 @@ function civicrm_api3_twingle_donation_Submit($params) {
} }
// Create membership if a membership type is configured within the profile. // 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( $membership = civicrm_api3('Membership', 'create', array(
'contact_id' => $contact_id, 'contact_id' => $contact_id,
'membership_type_id' => $membership_type_id, 'membership_type_id' => $membership_type_id,

View file

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