Advertisement
BakerMan

WT1.0.1 tpl tag to obtain ticket products for an event

May 13th, 2013
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. /**
  2.  * Returns an array of all WooTicket products associated with the event.
  3.  *
  4.  * @param null $post_id
  5.  * @return array
  6.  */
  7. function get_wooticket_products($post_id = null) {
  8.     global $wpdb;
  9.     $id = TribeEvents::postIdHelper($post_id);
  10.     $products = array();
  11.  
  12.     $product_ids = $wpdb->get_col($wpdb->prepare(
  13.         "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d",
  14.         '_tribe_wooticket_for_event', $id
  15.     ));
  16.  
  17.     if ($product_ids) foreach ($product_ids as $id)
  18.         $products[] = new WC_Product_Simple($id);
  19.  
  20.     return $products;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement