Skip to content

Instantly share code, notes, and snippets.

Created November 20, 2014 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8630272906cc46642199 to your computer and use it in GitHub Desktop.
Save anonymous/8630272906cc46642199 to your computer and use it in GitHub Desktop.
workshop_attendee_info($id)
// This is all I have so far. I can cycle through the items of the order
// and pick out the id's of products that ARE tickets, but I need to
// get the event ID from the ticket item somehow so I can display event info
function workshop_attendee_info($id)
{
$order = new WC_Order($id);
$items = $order->get_items();
$tickets = array();
$info = "";
foreach ( $items as $item_id => $item )
{
$product_id = $item['product_id'];
$product = get_product($product_id);
$terms = wp_get_post_terms( $product_id, 'product_cat' );
$categories = [];
if(!is_wp_error($terms))
{
foreach ( $terms as $term )
{
$categories[] = $term->slug;
}
if ( in_array( 'ti', $categories ) )
{
// $tickets[] = new_ticket_object();
}
}
}
if(count($tickets) > 0)
{
$info = "<tr><td valign='top' width='100%' colspan='2'><h3>Workshop Attendees</h3>";
// Loop through tickets, adding needed meta to $info
$info .= "</td></tr>";
}
return $info;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment