BakerMan

Add "Sold Out" to title in list view (WooTickets 3.0)

Jul 23rd, 2013
697
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. /**
  2.  * This solution adds a piece of text reading "Sold out!" just after the event title
  3.  * in list view.
  4.  *
  5.  * @uses tribe_has_wootickets()
  6.  * @see http://pastebin.com/hPS9nwft
  7.  *
  8.  * @uses get_wooticket_products()
  9.  * @see http://pastebin.com/csuqeikG
  10.  */
  11. function wootickets_list_view_sold_out() {
  12.     global $post;
  13.  
  14.     if (TribeEvents::POSTTYPE !== $post->post_type) return;
  15.     if (!tribe_has_wootickets($post->ID)) return;
  16.  
  17.     $tickets = get_wooticket_products($post->ID);
  18.     $stock = 0;
  19.  
  20.     foreach ($tickets as $ticket)
  21.         $stock += $ticket->get_stock_quantity();
  22.  
  23.     if (0 === $stock) echo '<span class="wootickets-sold-out"> Sold out! </span>';
  24. }
  25.  
  26. // Hook up so it fires during the event list loop
  27. add_action('tribe_events_after_the_event_title', 'wootickets_list_view_sold_out');
Advertisement
Add Comment
Please, Sign In to add comment