Skip to content

Instantly share code, notes, and snippets.

@elimn
Created May 19, 2015 05:19
Show Gist options
  • Save elimn/bf36f50c7ca2a4e50c9e to your computer and use it in GitHub Desktop.
Save elimn/bf36f50c7ca2a4e50c9e to your computer and use it in GitHub Desktop.
MT | TEC | Get amount of WooCommerce Tickets sold
<?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