Skip to content

Instantly share code, notes, and snippets.

@dbarkley
Created March 18, 2014 11:04
Show Gist options
  • Save dbarkley/9617943 to your computer and use it in GitHub Desktop.
Save dbarkley/9617943 to your computer and use it in GitHub Desktop.
function custom_espresso_ticket_links($registration_id, $attendee_id, $txn_id, $email = FALSE) {
global $wpdb;
$sql = "SELECT * FROM " . EVENTS_ATTENDEE_TABLE;
if (espresso_is_primary_attendee($attendee_id) != true) {
$sql .= " WHERE id = '" . $attendee_id . "' ";
} else {
$sql .= " WHERE txn_id = '" . $txn_id . "' ";
}
//echo $sql;
$attendees = $wpdb->get_results($sql);
$ticket_link = '';
if ($wpdb->num_rows > 0) {
$break = '<br />';
$group = $wpdb->num_rows > 1 ? sprintf(__('Tickets Purchased (%s):', 'event_espresso'), $wpdb->num_rows).$break : __('Download/Print Ticket:', 'event_espresso').$break;
foreach ($attendees as $attendee) {
$event_query = $wpdb->get_results("SELECT * FROM wp_events_detail WHERE id = $attendee->event_id");
$event = $event_query[0];
$event_name = $event->event_name;
$ticket_url = get_option('siteurl') . "/?download_ticket=true&amp;id=" . $attendee->id . "&amp;r_id=" . $attendee->registration_id;
if (function_exists('espresso_ticket_launch')) {
$ticket_url = espresso_ticket_url($attendee->id, $attendee->registration_id);
}
$ticket_link .= '<a href="' . $ticket_url . '" target="_blank">' . $event_name . ": ". $attendee->price_option . '</a>' . $break;
}
if ($email == TRUE){
$text = '<p>' . $group . $ticket_link .'</p>';
}else{
$text = $ticket_link;
}
return $text;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment