CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Location type questions
Pages: [1]

Author Topic: Location type questions  (Read 2916 times)

TLange

  • I’m new here
  • *
  • Posts: 20
  • Karma: 0
  • President of California Clean Money Campaign
    • California Clean Money Campaign
Location type questions
December 17, 2009, 02:15:20 pm
The normal CiviContribute forms use the Billing location for the address, understandably.  But it doesn't store that info in the Home address.  This causes a problem when the default for new individuals within CiviCRM is the Home address, because if somebody is already in the database and has a home address their home address won't be updated by CiviContribute and then we unnecessarily have two different addresses for each contact.

Is there a way to make CiviContribute contribution pages also update their Home location, in addition to the Billing address, without having to gather any more info from the user?  I.e. just have it set the Home location AND the Billing location to the same address, which we're willing to assume?

The only other option seems to be for us to always use the Billing address as the primary address, but the Location Types panel doesn't seem to let you edit the Billing location type and make it be the default address.

Thanks,

- Trent

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Location type questions
December 18, 2009, 03:13:21 am
Quote
Is there a way to make CiviContribute contribution pages also update their Home location, in addition to the Billing address, without having to gather any more info from the user?  I.e. just have it set the Home location AND the Billing location to the same address, which we're willing to assume?

You can implement this using Hook mechanism and CiviCRM Location api's

Quote
The only other option seems to be for us to always use the Billing address as the primary address, but the Location Types panel doesn't seem to let you edit the Billing location type and make it be the default address.

This would be easier solution.

Kurund
Found this reply helpful? Support CiviCRM

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Location type questions
December 18, 2009, 07:16:43 am

we do agree that the home/billing is a bit messed up and needs to be fixed

would be great if you can step up and start investigating it / figuring out the code changes and implement a patch. we can help u out on IRC

alternatively if you are not a developer you can hire one or sponsor the core team to do so (i estimate its a 30-50 hour issue)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

TLange

  • I’m new here
  • *
  • Posts: 20
  • Karma: 0
  • President of California Clean Money Campaign
    • California Clean Money Campaign
Re: Location type questions
December 19, 2009, 11:23:39 am
Thanks for the replies.  Is there an "easy" way to make the Billing location type editable on the Location Types panel so that we can set it to be the default address, or alternatively just setting it to be the default address?  Or is there some fundamental reason in the code now that setting Billing to be the default location would be a problem?

- Trent

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Location type questions
December 19, 2009, 11:58:51 am
You can set Billing location type as default location type. Check http://drupal.demo.civicrm.org/civicrm/admin/locationType&reset=1. Just edit Billing and set it as default.

HTh
Kurund
Found this reply helpful? Support CiviCRM

TLange

  • I’m new here
  • *
  • Posts: 20
  • Karma: 0
  • President of California Clean Money Campaign
    • California Clean Money Campaign
Re: Location type questions
December 20, 2009, 07:56:11 am
I tried that, but there is no option to Edit (nor Disable or Delete for that matter) the Billing field.  Every other Location Type (Home, Main, Other, and Work) do have that option.

This is true both in our CiviCRM 3.0.2 installation and in the 3.0 demo site.  How can we change/fix that so we can edit Billing and set it to the default?

- Trent

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Location type questions
December 20, 2009, 11:19:13 am
Right currently through UI you cannot set billing location as default. I guess only way update it is via sql.

Kurund
Found this reply helpful? Support CiviCRM

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: Location type questions
June 24, 2010, 09:35:06 pm
You might have worked around this already, but here's some code I knocked up today for similar situation -

Code: [Select]
/**
 * Implementation of hook_civicrm_pre()
 *
 * @see http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification
 * @see http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmpre
 *
 * @param string operation CiviCRM will perform (view, create, edit, delete)
 * @param string name of object type (Individual, Household, Organization, ...)
 * @param the object ID, if available
 * @param the parameters used for object creation / edit
 *
 */
function mymodule_civicrm_civicrm_pre( $op, $objectName, $objectId, &$objectRef ) {
  switch ( $op ) {
    case 'edit' :
      switch ( $objectName ) {
        case 'Individual' :
          // Contribution forms store email updates against billing address. We want this to be
          // stored in the Home address as well.
          $addresses = array( 'email', 'address' ) ;
          foreach ( $addresses as $addressType ) {
            if ( isset( $objectRef[$addressType] ) && sizeof( $objectRef[$addressType] == 1 ) ) {
              $locationTypes = CRM_Core_PseudoConstant::locationType( ) ;
              $address = reset($objectRef[$addressType]) ; // like array_shift() but without modifying
              if ( $locationTypes[$address['location_type_id']] == 'Billing' ) {
                if ( $locationTypeId = array_search('Home', $locationTypes) ) {
                  $homeAddress = array_merge($address, array( 'location_type_id' => $locationTypeId ));
                  $objectRef[$addressType][] = $homeAddress ;
                }
              }
            }
          }
          break ;
      }
  }
}
@xurizaemon ● www.fuzion.co.nz

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Location type questions

This forum was archived on 2017-11-26.