Created
May 19, 2015 05:19
-
-
Save elimn/bf36f50c7ca2a4e50c9e to your computer and use it in GitHub Desktop.
MT | TEC | Get amount of WooCommerce Tickets sold
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 | |
/* | |
* Gets the amount of tickets sold for an event, currently only works with WooCommerce Tickets | |
*/ | |
if ( !function_exists('tribe_events_count_sold_tickets') ) { | |
function tribe_events_count_sold_tickets ( $event = null ) { | |
$count = 0; | |
if ( null === $event = tribe_events_get_event( $event ) || !class_exists('TribeEventsTickets') ) { | |
return 0; | |
} | |
foreach ( TribeEventsTickets::get_all_event_tickets( $event->ID ) as $ticket ) { | |
$count += get_post_meta( $ticket->ID, 'total_sales', true ); | |
} | |
return $count; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment