Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active April 5, 2018 12:24
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 joshfeck/777cc126964a25c15962f2c14aa3eb82 to your computer and use it in GitHub Desktop.
Save joshfeck/777cc126964a25c15962f2c14aa3eb82 to your computer and use it in GitHub Desktop.
First example: Show home many tickets have sold of total available below dates. Second example: Show home many tickets have sold of total available below the ticket selector.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'AHEE_event_details_after_event_date', 'ee_print_number_of_tickets_after_dates', 10 );
function ee_print_number_of_tickets_after_dates( $post ) {
$event = $post->EE_Event;
if ( $event instanceof EE_Event ) {
if ( ! $event->is_sold_out() && $event->is_upcoming() ) {
//get total approved registrations count
$spots_taken = EEM_Registration::instance()->count(array(
array(
'EVT_ID' => $event->ID(),
'STS_ID' => EEM_Registration::status_id_approved,
),
), 'REG_ID', true);
$html = '<div class="total-tickets">';
$html .= $spots_taken;
$html .= ' sold of ';
$html .= $event->total_available_spaces();
$html .= ' total available</div>';
echo $html;
}
}
}
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', 'ee_print_number_of_tickets', 10, 2 );
function ee_print_number_of_tickets( $EVT_ID, $event ) {
if ( $event instanceof EE_Event ) {
if ( ! $event->is_sold_out() && $event->is_upcoming() ) {
//get total approved registrations count
$spots_taken = EEM_Registration::instance()->count(array(
array(
'EVT_ID' => $EVT_ID,
'STS_ID' => EEM_Registration::status_id_approved,
),
), 'REG_ID', true);
$html = '<div class="total-tickets">';
$html .= $spots_taken;
$html .= ' sold of ';
$html .= $event->total_available_spaces();
$html .= ' total available</div>';
echo $html;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment