Skip to content

Instantly share code, notes, and snippets.

@cliffordp
Last active September 8, 2016 20:23
Show Gist options
  • Save cliffordp/acfc3cac546ba0849a222c8eee8160ca to your computer and use it in GitHub Desktop.
Save cliffordp/acfc3cac546ba0849a222c8eee8160ca to your computer and use it in GitHub Desktop.
Event Tickets Plus: Add phone column to front-end attendees report -- WooCommerce tickets
<?php
// Event Tickets Plus: Add phone column to front-end attendees report
// WooCommerce tickets
// by Nico on August 23, 2016
// Tribe, inject phone column header
function tribe_inject_phone_column( $columns ) {
// bail if no tickets column present
if ( ! array_key_exists( 'ticket', $columns ) ) return $columns;
return array_merge( $columns, array( 'phone' => 'Phone' ) );
}
add_filter( 'manage__columns', 'tribe_inject_phone_column' );
// Tribe, inject phone column value
function tribe_inject_phone( $value, $item, $column ) {
if ( 'phone' == $column && 'woo' == $item['provider_slug'] ) {
if ( ! class_exists( 'WC_Order' ) ) return '';
$order = new WC_Order( $item['order_id'] );
$billing = $order->get_address( 'billing' );
$value = $billing['phone'];
}
return $value;
}
add_filter( 'tribe_events_tickets_attendees_table_column', 'tribe_inject_phone', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment