Advertisement
brook-tribe

tribe_get_wooticket_amount()

Feb 13th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. // Returns the amount of active WooCommerce tickets for this event
  2. // Mostly useful for detecting if an event has tickets. Returns 0 for those.
  3. function tribe_get_wooticket_amount( $event_id = null ) {
  4.  
  5.     if ( is_object( $event_id ) )
  6.         $event_id = $event_id->ID;
  7.     if ( $event_id === null )
  8.         $event_id = get_the_ID();
  9.  
  10.     $query = new WP_Query( array( 'post_type'      => 'product',
  11.         'meta_key'       => '_tribe_wooticket_for_event',
  12.         'meta_value'     => $event_id,
  13.         'meta_compare'   => '=',
  14.         'posts_per_page' => - 1,
  15.         'fields'         => 'ids',
  16.         'post_status'    => 'publish', ) );
  17.  
  18.     return count($query->posts);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement