Advertisement
BakerMan

Add to Cart Ticket Links (WT 1.0.1)

May 9th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. /**
  2.  * This emulates a private method from the WooTickets class, therefore should not be considered
  3.  * future proof.
  4.  *
  5.  * @param $event_id
  6.  * @return array
  7.  */
  8. function get_wootickets_ids( $event_id ) {
  9.     if ( is_object( $event_id ) )
  10.         $event_id = $event_id->ID;
  11.  
  12.     $query = new WP_Query( array( 'post_type'      => 'product',
  13.         'meta_key'       => '_tribe_wooticket_for_event',
  14.         'meta_value'     => $event_id,
  15.         'meta_compare'   => '=',
  16.         'posts_per_page' => - 1,
  17.         'fields'         => 'ids',
  18.         'post_status'    => 'publish', ) );
  19.  
  20.     return $query->posts;
  21. }
  22.  
  23.  
  24. function add_to_cart_wooticket_btns() {
  25.     $tickets = get_wootickets_ids(get_the_ID());
  26.  
  27.     foreach ($tickets as $ticket_id)
  28.         echo '<a href="'.do_shortcode('[add_to_cart_url id="'.$ticket_id.'"]').'"> Add to Cart </a>';
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement