Although selected contact has an address in his profile (But No Billing address). It would be useful to have a tick box saying "same as home/primary address", admin doesn't need to type in all the info again. Can anyone suggest how to do it in a quick way?
-
CiviCRM thinks you need a street address because some credit card companies require it; if your CC processor is one of those (I've never hit one myself), then omitting the values might fail submission.– Chris BurgessAug 6, 2015 at 11:16
-
Thanks. But my point is how to prefill the address & name info in the billing block. As we can see from the form street address is mandatory filed for paypal pro.– TapashAug 6, 2015 at 11:22
2 Answers
What version are you on - I just checked a 4.6.6 site & a contact with a home address (only) is getting the prefill - although if you change processor that form is not prefilling. (there is an open ticket about that )
-
Thanks Eileen, I am on 4.6.6. and you are correct it prefills the name & address data if I go from person's profile > Contribution > Submit Credit card contribution. it works, Even that person only has home/primary address & NO billing address. However it does not work if used the link from the left CREATE NEW> Contribution> Contribution (credit Card). Bug may be!!??– TapashAug 6, 2015 at 11:26
-
can you also please post the link of that open ticket you are talking about?– TapashAug 6, 2015 at 11:54
You can remove the requirement of those fields using hook_civicrm_buildForm()
- see CiviCRM hook reference
Here's an example from a couple of years ago, although this was written for user-facing forms:
/**
* Implements hook_civicrm_buildForm().
*/
function example_civicrm_buildForm($formName, &$form) {
switch ($formName) {
case 'CRM_Contribute_Form_Contribution_Main':
$fields_not_required = array(
'billing_first_name',
'billing_middle_name',
'billing_last_name',
'billing_street_address-5',
'billing_city-5',
'billing_state_province_id-5',
'billing_postal_code-5',
'billing_country_id-5',
);
foreach ($fields_not_required as $field) {
$form->_paymentFields[$field]['is_required'] = FALSE;
}
break;
}
}
-
sorry, if my question was not clear. I am not trying to avoid entering the address data, rather want to prefill from the existing address of contact profile.– TapashAug 6, 2015 at 11:28
-
The code above doesn't do what you want then, but perhaps you could build on it to pre-fill the data as you desire instead of changing the field's required setting. Aug 6, 2015 at 12:19