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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • civi event discount
Pages: [1]

Author Topic: civi event discount  (Read 1853 times)

jeevajoy

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4
  • CMS version: joomal 1.6
  • MySQL version: 5
  • PHP version: 5
civi event discount
December 22, 2011, 03:52:43 pm
hello there,

I tried to create the event discount for members by checking with their email. I adapted the civievent discount module.
I managed to create the discount based on the membership type. It shows the discounted amount in the register page but when i go tp the confirm page it doesn't show the discounted amount instead it shows the original amount.

Here is my code. Anyone pls help.



function civicrm_event_discount_civicrm_buildAmount($pageType, &$form,&$amount) {

                           
   
    if($pageType == 'event' && $_GET["email"]!='' )   {

      require_once 'api/v2/Contact.php';
      require_once 'api/v2/Membership.php';
 
     
     
      $email= $_GET["email"];
      //$email="smithchris@redimail.org"; //currrent_membership=0
      //$email="kristina_rizova@jurysinns.com";   //currrent_membership=1 
     
         $params = array( 'email' => $email);
         $contacts=&civicrm_contact_get( $params );
                 
        foreach($contacts as $key=>$value){     
        $contactId= $key;
          }   

          $params1= array('contact_id' =>$contactId);     
          $membership=&civicrm_contact_memberships_get( $params1 );
        //print_r($membership);exit;
         
        foreach($membership[$contactId] as $k=>$v){         
        $memId=$k;
       
               
        $statusid = $membership[$contactId][$memId]['status_id'];
                                                                              
         $parmas2=  array ('id' =>$statusid );
         $results=civicrm_membership_status_get($parmas2);
         
          //print_r($results);exit;
          $current=$results[$statusid]['is_current_member'];
          }
           
         
          $defaults['email-5'] = $email;             
          $form->setDefaults( $defaults );
         
         
           
           $codes = _get_discounts();
           //print_r($codes);exit;
     
       
           
           foreach ($codes as $k1=>$v1) {
           $var =$codes[$k1]['memberships'];
           $n=unserialize($var);
            //print_r($n);
               if((array_search($statusid,$n)==$statusid)){
               $disamount = $codes[$k1]['amount'];
                $disamounttype = $codes[$k1]['amount_type'];
                   $discountPercent= $disamount;
               }
             }
             
            //print_r($form); exit;
          $feeblock = & $amount;   
          //print_r($feeblock);exit;   
     

           
         if($current==1)  { 
           if($disamounttype == 'M' )  {
               foreach ( $feeblock as $amountId => $amountInfo ) { 
                $feeblock[$amountId]['value'] = $feeblock[$amountId]['value'] -
                    ceil( $discountPercent);
                $feeblock[$amountId]['label'] = $feeblock[$amountId]['label'] .
                    "\t - with {$discountPercent} discount ";
                    //print_r( $feeblock[$amountId]['value']); exit;
                }               
             }
             else{             
              foreach ( $feeblock as $amountId => $amountInfo ) {
                $feeblock[$amountId]['value'] = $feeblock[$amountId]['value'] -
                    ceil($feeblock[$amountId]['value'] * $discountPercent / 100);
                $feeblock[$amountId]['label'] = $feeblock[$amountId]['label'] .
                    "\t - with {$discountPercent} discount ";
                    }
                  }
                 
               } 
               
        else {
        $msg="Sorry! No Discount. You are not a Member";
        $form->assign('Not',$msg);         
       
      }             
                 
    }
   }
   
   
 
   

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: civi event discount
December 22, 2011, 07:19:23 pm
Have you checked: http://drupal.org/project/civievent_discount

Kurund
Found this reply helpful? Support CiviCRM

jeevajoy

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4
  • CMS version: joomal 1.6
  • MySQL version: 5
  • PHP version: 5
Re: civi event discount
December 23, 2011, 02:02:56 am
yes i adapted that module

jeevajoy

  • I’m new here
  • *
  • Posts: 18
  • Karma: 0
  • CiviCRM version: 4
  • CMS version: joomal 1.6
  • MySQL version: 5
  • PHP version: 5
Re: civi event discount
December 28, 2011, 01:46:18 am
civievent discout module gives discount for additional particpants also. I dont want that. Does anybody know how to disable it.
« Last Edit: December 28, 2011, 07:14:41 am by jeevajoy »

bdanza

  • I post frequently
  • ***
  • Posts: 135
  • Karma: 3
  • CiviCRM version: 3.4.6
  • CMS version: Joomla 1.5, Drupal 6.2x
Re: civi event discount
March 15, 2012, 05:53:15 am
Any word on whether event discount will make it into core in one of the future releases? or if someone will upgrade it for drupal 7?

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: civi event discount
March 15, 2012, 06:52:04 am

there is an MIH for this here:

http://civicrm.org/participate/mih#cmsagnostic

Please contribute and help make it happen in 4.2

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

bdanza

  • I post frequently
  • ***
  • Posts: 135
  • Karma: 3
  • CiviCRM version: 3.4.6
  • CMS version: Joomla 1.5, Drupal 6.2x
Re: civi event discount
March 15, 2012, 06:52:41 am
Already contributed, thanks Lobo!

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: civi event discount
March 15, 2012, 07:03:51 am

Cool. thanx a lot, much appreciated :)

lobo
« Last Edit: March 15, 2012, 07:20:17 am by Donald 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

mclyde

  • I post frequently
  • ***
  • Posts: 171
  • Karma: 3
    • International Society for Bayesian Analysis
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 6.x
  • MySQL version: 5.136
  • PHP version: 5.2.16
Re: civi event discount
May 01, 2012, 07:50:52 pm
Will this

 
Quote
http://civicrm.org/participate/mih#cmsagnostic

  Please contribute and help make it happen in 4.2

work with D6?  If so I'll see what we can do to support the rest!

Merlise
Merlise Clyde

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: civi event discount
May 01, 2012, 07:53:04 pm

yes it would. jay mcgraw actually just deployed it on a D6 site and found a bug (which was then fixed in svn)

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

mclyde

  • I post frequently
  • ***
  • Posts: 171
  • Karma: 3
    • International Society for Bayesian Analysis
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 6.x
  • MySQL version: 5.136
  • PHP version: 5.2.16
Re: civi event discount
May 01, 2012, 10:07:37 pm
Thanks!  I'll try it on our devel site (on 4.1.2)  and see if we can get some funding for the MIH initative.  Still have until July before launching our next conference :-)

best,
Merlise
Merlise Clyde

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • civi event discount

This forum was archived on 2017-11-26.