Make required address components configurable
The required address components can be selected in the corresponding profile.
This commit is contained in:
parent
89638a172d
commit
9969c99f70
5 changed files with 63 additions and 9 deletions
|
@ -416,6 +416,20 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
array()
|
||||
);
|
||||
|
||||
$this->add(
|
||||
'select',
|
||||
'required_address_components',
|
||||
E::ts('Required address components'),
|
||||
[
|
||||
'street_address' => E::ts("Street"),
|
||||
'postal_code' => E::ts("Postal Code"),
|
||||
'city' => E::ts("City"),
|
||||
'country' => E::ts("Country"),
|
||||
],
|
||||
FALSE, // is not required
|
||||
['class' => 'crm-select2 huge', 'multiple' => 'multiple']
|
||||
);
|
||||
|
||||
$this->add(
|
||||
'textarea', // field type
|
||||
'custom_field_mapping', // field name
|
||||
|
|
|
@ -226,7 +226,8 @@ class CRM_Twingle_Profile {
|
|||
'membership_type_id',
|
||||
'membership_type_id_recur',
|
||||
'membership_postprocess_call',
|
||||
'newsletter_double_opt_in'
|
||||
'newsletter_double_opt_in',
|
||||
'required_address_components',
|
||||
),
|
||||
// Add payment methods.
|
||||
array_keys(static::paymentInstruments()),
|
||||
|
@ -300,6 +301,12 @@ class CRM_Twingle_Profile {
|
|||
'membership_type_id' => NULL,
|
||||
'membership_type_id_recur' => NULL,
|
||||
'newsletter_double_opt_in' => NULL,
|
||||
'required_address_components' => [
|
||||
'street_address',
|
||||
'postal_code',
|
||||
'city',
|
||||
'country',
|
||||
],
|
||||
)
|
||||
// Add contribution status for all payment methods.
|
||||
+ array_fill_keys(array_map(function($attribute) {
|
||||
|
|
|
@ -335,14 +335,20 @@ function civicrm_api3_twingle_donation_Submit($params) {
|
|||
}
|
||||
}
|
||||
|
||||
// Do not creat a new address if user_country is the only address
|
||||
// parameter. See issue #47
|
||||
if (
|
||||
!array_key_exists('street_address', $params) &&
|
||||
!array_key_exists('postal_code', $params) &&
|
||||
!array_key_exists('city', $params)
|
||||
) {
|
||||
unset($params['country']);
|
||||
// Do not creat a new address if 'country' is the only address
|
||||
// component. See issue #47
|
||||
$required_address_components =
|
||||
$profile->getAttribute('required_address_components');
|
||||
$unset_address_params = False;
|
||||
foreach ($required_address_components as $req) {
|
||||
if (empty($params[$req])) {
|
||||
$unset_address_params = True;
|
||||
}
|
||||
}
|
||||
if ($unset_address_params) {
|
||||
foreach($required_address_components as $req) {
|
||||
unset($params[$req]);
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare parameter mapping for organisation.
|
||||
|
|
|
@ -54,6 +54,12 @@
|
|||
</ul>{/ts}
|
||||
{/htxt}
|
||||
|
||||
{htxt id='id-required_address_components'}
|
||||
<p>{ts domain="de.systopia.twingle"}Select the address components that must be present to create a new address for the contact.{/ts}</p>
|
||||
<p>{ts domain="de.systopia.twingle"}Depending on your XCM settings, the newly transferred address will replace the old one. This behavior may be intentional, as you always want to have the most current address.{/ts}</p>
|
||||
<p>{ts domain="de.systopia.twingle"}<strong>ATTENTION:</strong> In some cases Twingle sends only the country of the user. If no other address components are selected in the required address components, the current user address will be overwritten with an address containing only the country, depending on the XCM settings.{/ts}</p>
|
||||
{/htxt}
|
||||
|
||||
{htxt id='id-custom_field_mapping'}
|
||||
{ts domain="de.systopia.twingle"}<p>Map Twingle custom fields to CiviCRM custom fields using the following format (each assignment in a separate line):</p>
|
||||
<pre>twingle_field_1=custom_123<br />twingle_field_2=custom_789</pre>
|
||||
|
|
|
@ -290,6 +290,27 @@
|
|||
<td class="content">{$form.contribution_source.html}</td>
|
||||
</tr>
|
||||
|
||||
<tr class="crm-section">
|
||||
<td class="label">{$form.required_address_components.label}
|
||||
<a
|
||||
onclick='
|
||||
CRM.help(
|
||||
"{ts domain="de.systopia.twingle"}Required address components{/ts}",
|
||||
{literal}{
|
||||
"id": "id-required_address_components",
|
||||
"file": "CRM\/Twingle\/Form\/Profile"
|
||||
}{/literal}
|
||||
);
|
||||
return false;
|
||||
'
|
||||
href="#"
|
||||
title="{ts domain="de.systopia.twingle"}Help{/ts}"
|
||||
class="helpicon"
|
||||
></a>
|
||||
</td>
|
||||
<td class="content">{$form.required_address_components.html}</td>
|
||||
</tr>
|
||||
|
||||
<tr class="crm-section">
|
||||
<td class="label">
|
||||
{$form.custom_field_mapping.label}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue