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 »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • How to configure a contribution page for specific contact subtype
Pages: [1]

Author Topic: How to configure a contribution page for specific contact subtype  (Read 1159 times)

dsdart

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
  • CiviCRM version: 4.4
  • CMS version: Drupal 7.25
  • MySQL version: 5.1.41
  • PHP version: 5.3.1
How to configure a contribution page for specific contact subtype
January 17, 2012, 04:29:44 pm
I can't find the answer to this anywhere, so I am hoping someone here can enlighten me.  We have 2 specific contact subtypes for organization - schools and businesses.  When I create the contribution page for member dues for businesses (schools sign up differently), the contacts are given the contact type of organization.   How do I configure the contribution page so that they will become type "business"?

thanks

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: How to configure a contribution page for specific contact subtype
January 17, 2012, 05:09:33 pm

Can you attach a profile which is of type business to the contribution page? If that does not work, u'll need to do the below via a hook

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

dsdart

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
  • CiviCRM version: 4.4
  • CMS version: Drupal 7.25
  • MySQL version: 5.1.41
  • PHP version: 5.3.1
Re: How to configure a contribution page for specific contact subtype
January 18, 2012, 08:09:38 am
I don't see how to make a profile of type business.  I had previously tried adding custom data of type business to the "on behalf of organization", and it was on the contribution form, but did not show up on the view contact page.


dsdart

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
  • CiviCRM version: 4.4
  • CMS version: Drupal 7.25
  • MySQL version: 5.1.41
  • PHP version: 5.3.1
Re: How to configure a contribution page for specific contact subtype
January 18, 2012, 01:05:05 pm
I'm trying to use a hook to add my contact_sub_type into the civicrm_contact table, but I am running into some issues.  I am using a postProcess hook with the formname and profileId, but because of the confirmation page ("Please verify the information below carefully" ...), the record doesn't exists until after the continue button is pushed. 

So I thought about using CRM_Core_DAO::objectExists, but that looks like it takes the record number (daoId)?  Am I reading it wrong?

Is my train moving along the wrong track here?  Is there a better way to accomplish this?

thanks again!

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: How to configure a contribution page for specific contact subtype
January 18, 2012, 02:16:37 pm

did not understand your train of thought completely, but

use the postProcess hook on the confirm page where the objects are created

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

dsdart

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
  • CiviCRM version: 4.4
  • CMS version: Drupal 7.25
  • MySQL version: 5.1.41
  • PHP version: 5.3.1
Re: How to configure a contribution page for specific contact subtype
January 18, 2012, 03:26:26 pm
Maybe I am confused what object I am trying to update in the postProcess hook.  I thought I needed to update the database.

Also, how do I get the name of the confirmation page?  I've tried echo and drupal_set_message.  The only way I got the name before is to add "die" after the echo as in this thread - http://forum.civicrm.org/index.php/topic,23006.msg96828.html#msg96828 and that's not going to work to get the name of the confirmation page.

I saw your link to an architecture page on another thread, but clicking it goes to the main page, so I am in the dark as to how the page names are created.

dsdart

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 3
  • CiviCRM version: 4.4
  • CMS version: Drupal 7.25
  • MySQL version: 5.1.41
  • PHP version: 5.3.1
Re: How to configure a contribution page for specific contact subtype
January 24, 2012, 01:13:28 pm
For anybody that stumbles upon this thread, here is what I came up with in a Drupal custom module named civi_hooks:

function civi_hooks_civicrm_postProcess( $formName, &$form )
{
   if (is_a( $form, 'CRM_Contribute_Form_Contribution_Confirm')) {
        $id = $form->getVar( '_id' );
      if ($id == 3) {  // the contrib page id number
         $email = $form->_params['onbehalf']['email-3'];
         $orgname = $form->_params['onbehalf']['organization_name'];
   
         // The org name may not be unique, so get the id from the email table
         $query = "SELECT contact_id FROM civicrm_email WHERE email = %1";
         $params = array( 1 => array( $email, 'String' ));
         $dao = CRM_Core_DAO::executeQuery( $query, $params );
         
         while ( $dao->fetch( ) ) {
            if ( empty( $dao->contact_id ) ) {
               continue;
            }
                  // might be the same as the user so check display_name too
            $query = "UPDATE civicrm_contact SET contact_sub_type = %1 WHERE id = %2 AND display_name = %3";
            $params = array( 1 => array( "Business", 'String' ),
                        2 => array( $dao->contact_id, 'Integer' ),
                        3 => array( $orgname, 'String' ) );
            CRM_Core_DAO::executeQuery( $query, $params );
         }
      }
   }
}

If anybody has suggestions on how to improve this, please post them.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • How to configure a contribution page for specific contact subtype

This forum was archived on 2017-11-26.