CiviCRM Community > Developer Discussion
civi event discount
jeevajoy:
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:
Have you checked: http://drupal.org/project/civievent_discount
Kurund
jeevajoy:
yes i adapted that module
jeevajoy:
civievent discout module gives discount for additional particpants also. I dont want that. Does anybody know how to disable it.
bdanza:
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?
Navigation
[0] Message Index
[#] Next page
Go to full version