Skip to content

Instantly share code, notes, and snippets.

@sidharrell
Last active December 26, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidharrell/7163075 to your computer and use it in GitHub Desktop.
Save sidharrell/7163075 to your computer and use it in GitHub Desktop.
apply coupon code to primary attendee only
function apply_coupon_to_primary_attendee_only ($ext_att_data_source) {
global $wpdb;
$attendee = $wpdb->get_row('SELECT * FROM ' . EVENTS_ATTENDEE_TABLE . ' WHERE id=' . $ext_att_data_source['attendee_id'], ARRAY_A);
if ($attendee['is_primary'] != 1) {
$wpdb->update(EVENTS_ATTENDEE_TABLE,
array('final_price'=>$attendee['orig_price']),
array('id'=>$attendee['id']),
array('%f'),
array('%d'));
}
}
add_action('action_hook_espresso_save_attendee_data', 'apply_coupon_to_primary_attendee_only');
// bug in 3.1.36.1.P. need to change line 572 of includes/process-registration/add_attendees_to_db.php from
// $ext_att_data_source['attendee_id'] = $attendee_id;
// to:
$ext_att_data_source['attendee_id'] = $ext_attendee_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment