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 CiviEvent (Moderator: Yashodha Chaku) »
  • Group discounts?
Pages: [1] 2

Author Topic: Group discounts?  (Read 3182 times)

nithya1

  • Guest
Group discounts?
February 26, 2009, 09:18:38 am
Do we have the ability to give group discounts for events yet?
« Last Edit: February 26, 2009, 09:30:56 am by nithya1 »

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: Group discounts?
February 26, 2009, 09:58:12 am

can you elaborate on what you mean? if by group discounts via additional participant feature, not yet. but would be great for you (or someone in the community) to contribute code that implements it

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

nithya1

  • Guest
Re: Group discounts?
February 26, 2009, 10:05:55 am
Quote from: Donald Lobo on February 26, 2009, 09:58:12 am

can you elaborate on what you mean? if by group discounts via additional participant feature,...

lobo

Yes. I meant discounts for additional participants.

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: Group discounts?
February 26, 2009, 10:48:31 am

not implemented currently. would be a good community contribution

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

nithya1

  • Guest
Re: Group discounts?
February 27, 2009, 04:05:48 pm
I made a quick hardcoded fix for this functionality on the file .../CRM/Event/Form/Registration/Confirm.php in the function 'public function buildQuickForm( )' definition. Of course I used it for just one event to which the discount is applied. The proper method would be to add an entry to the database with a value like 'isSpecialDiscount' and get the info for the event from its id. But this is just a temporary fix.

You should also add some info in the 'statusmsg' variable on the .../CRM/Event/Form/Registration/Register.php file to make your users know that all discounts will be applied at the end of the transaction.

It worked great for me and i've tested it multiple times. Use it at your own risk. No guaratees.

I changed the part where it says 

foreach( $this->_params as $k => $v ) {
                if ( is_array( $v ) ) {
                    if ( CRM_Utils_Array::value( 'is_primary', $v ) ) {               
                        $this->set( 'primaryParticipantAmount',$v['amount'] );
                    }       
                    $this->_amount[ $v['amount_level'].' - '. $v['email-5'] ] = $v['amount'];
          $this->_totalAmount = $this->_totalAmount + $v['amount'];
                }
            }

I changed it to the following:

foreach( $this->_params as $k => $v ) {
                if ( is_array( $v ) ) {
                    if ( CRM_Utils_Array::value( 'is_primary', $v ) ) {
                  //modification starts
                  //special discount for additional participants.
                  require_once 'CRM/Event/BAO/EventPage.php';
                  $participantParams = $this->_params;
                  $count = 1;
                  $discountRate = 50; //50% discount
                  //get the count of participants
                  foreach ( $participantParams as $participantNum => $participantValue ) {
                     if ( $participantNum && $participantValue != 'skip') {
                        $count++;
                     }         
                  }
                  //if more than one participant for the event then apply the discount
                  if ( $count > 1 && strstr( $this->_values['event']['event_title'], "Insert Your Event Name" ) ) {
                     $v['amount'] = (100-$discountRate)/100*$v['amount'];
                  }                  
                  //modification ends
                        $this->set( 'primaryParticipantAmount',$v['amount'] );
                    } else {
                  //modification starts
                  //special discount for additional participants.
                  require_once 'CRM/Event/BAO/EventPage.php';
                  $participantParams = $this->_params;
                  $count = 1;
                  $discountRate = 50; //50% discount
                  //get the count of participants
                  foreach ( $participantParams as $participantNum => $participantValue ) {
                     if ( $participantNum && $participantValue != 'skip') {
                        $count++;
                     }         
                  }
                  //if more than one participant for the event then apply the discount
                  if ( $count > 1 && strstr( $this->_values['event']['event_title'], "Insert Your Event Name" ) ) {
                     $v['amount'] = (100-$discountRate)/100*$v['amount'];
                  }                  
                  //modification ends
               }
               
                    //modification starts
if ( $count > 1 && strstr( $this->_values['event']['event_title'], "Insert Your Event Name" ) ) {
                  $this->_amount[ ' After '. $discountRate . '% OFF - '. $v['amount_level']. $v['email-5'] ] = $v['amount'];
                  }
               else {
                  $this->_amount[ $v['amount_level'].' - '. $v['email-5'] ] = $v['amount'];
               }
//modification ends

               $this->_totalAmount = $this->_totalAmount + $v['amount'];
                }
            }



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: Group discounts?
February 28, 2009, 07:46:14 am

Thanx for taking the initiative to do this, much appreciated :)

this gives me some ideas on how to tailor a hook that allows discounting just before the confirmation step. I think in addition to the amount, we'll want the hook to return a couple of messages so we can inform the user that a discount has been applied and the amount / percentage of discount.

I suspect we can make this change in 2.2 due to this

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

nithya1

  • Guest
Re: Group discounts?
March 01, 2009, 09:39:13 am
Yes. I think it will be good idea.  :)

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: Group discounts?
March 01, 2009, 12:09:25 pm

http://issues.civicrm.org/jira/browse/CRM-4182

a first version of the implementation has been checked in :)

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

polestar

  • I post frequently
  • ***
  • Posts: 162
  • Karma: 11
    • Target Integration
Re: Group discounts?
July 06, 2009, 04:53:34 am
Hi Lobo,

Did this went live ever? Seems like didn't from the Jira status.

Thanks
Rohit
CiviCRM - Installation & Support | Virtual Private Servers (VPS) with Joomla/Drupal and CiviCRM | SugarCRM & vTiger CRM Installation and Support
Target Integration | www.targetintegration.com
Subscribe to Knowledgement - Your guide to effective business | http://www.knowledgement.ie

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: Group discounts?
July 06, 2009, 06:25:36 am

yes it did. check: http://civicrm.org/node/566

the jira issue is marked as closed with some comments? so not sure how/why u interpreted it the way u did

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

polestar

  • I post frequently
  • ***
  • Posts: 162
  • Karma: 11
    • Target Integration
Re: Group discounts?
July 06, 2009, 06:59:36 am
Thanks Lobo. As I see from http://issues.civicrm.org/jira/browse/CRM-4182 the issue has a status "In Verification" correct me if I am reading it incorrectly.
Thanks
Rohit
CiviCRM - Installation & Support | Virtual Private Servers (VPS) with Joomla/Drupal and CiviCRM | SugarCRM & vTiger CRM Installation and Support
Target Integration | www.targetintegration.com
Subscribe to Knowledgement - Your guide to effective business | http://www.knowledgement.ie

benjeewest

  • Guest
Re: Group discounts?
August 17, 2009, 02:44:54 pm
Hi there,

I'm fairly new to CiviCRM, and am not really familiar with how the development process works- could somebody possibly confirm if this feature has made it into any existing version of CiviCRM?

I noticed that at http://civicrm.org/node/518 it mentions that 2.2 beta 4 included a

'New hook to discount event fees when a user is registering multiple participants (e.g. you get a 5% discount for each additional person you register)'

I'm currently running 2.2.7 Standalone, and there doesn't seem to be any evidence of this feature in the backend?

If anyone can point me in the right direction or let me know what the status of this feature is, I'd be massively grateful.

Thanks a lot,

>Ben

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: Group discounts?
August 17, 2009, 05:16:36 pm

Yes that is present in 2.2.x. We use this hook to implement discounting for events on civicrm.org :) (just used it today!)

note that implementing a hook requires writing PHP code etc

check: http://civicrm.org/node/566

for more details on the discount 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

benjeewest

  • Guest
Re: Group discounts?
August 18, 2009, 01:33:54 am
Hi Lobo,

Many thanks for your speedy reply. I noticed that the doc you linked to refers to Drupal quite a bit- I'm running standalone, is there any documentation out there about how hooks can be implemented in standalone (if indeed, they can be?).

I think I may be a little out of my depth here, though will give it a try- are there any plans to include this in the core at some stage?

Many 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: Group discounts?
August 18, 2009, 07:04:59 am

the format is pretty much identical to that of drupal. so 99% of that post applies. a couple of changes

1. put all your code in a file civicrmHooks.php and place that in the civicrm_root directory

2. standalone/joomla can only have one implementation of a hook, the function needs to be prefixed with standalone (or joomla)

so: standalone_civicrm_buildForm( .. )

etc

3. no plans to include it in core in the short term. I suspect it will get into core at some point

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

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Group discounts?

This forum was archived on 2017-11-26.