Last active
September 8, 2016 20:23
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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