Last active
April 5, 2018 12:24
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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