/**
* FooEvents – display all orders and Attendees details
*/
add_action(“admin_init”, “ct_display_report5″);
function ct_display_report5()
{
if (!current_user_can(‘administrator’)) {
return false;
}
if (!isset($_GET[‘ct_display_report5’])) {
return false;
}
ct_get_events_data();
}
function ct_get_events_data($flat_data = false)
{
$html = ”;
$html .= ‘
‘;
$orders_from_date = isset($_GET[‘orders_from’]) ? $_GET[‘orders_from’] : ”;
$html .= ‘
$html .= ‘
$download_csv_url = ‘/wp-admin/?ct_custom_download_123=yes’;
if ($orders_from_date) {
$download_csv_url = ‘/wp-admin/?ct_custom_download_123=yes&orders_from=’ . $orders_from_date;
$title = ‘Orders from: ‘ . $orders_from_date;
$download_csv_text = ‘? Export orders’;
$more_text = ‘To generate CSV file with orders from ‘ . $orders_from_date . ‘ click here:’;
} else {
$title = ‘Orders all-time’;
$download_csv_text = ‘? Export orders’;
$more_text = ‘To generate CSV file with ALL orders click here:’;
}
$html .= ‘
‘ . $title . ‘
‘;
$html .= ‘
‘ . $more_text . ‘
‘ . $download_csv_text . ‘
‘;
$html .= ‘
‘;
$html .= ‘
Filters
‘;
$html .= ‘
‘;
$html .= ‘
‘;
// compose data
$csv_data = array();
$columnsNames = array();
$args = array(
‘limit’ => -1,
‘orderby’ => ‘date’,
‘order’ => ‘DESC’,
);
if ($orders_from_date) {
$args[‘date_created’] = ‘>’ . (strtotime($orders_from_date));
}
$query = new WC_Order_Query($args);
$orders = $query->get_orders();
$counter = 0;
$attendeeCounter = 0;
foreach ($orders as $order) {
$counter++;
$html .= ‘
$html .= ”;$html .= ”;
$html .= ”;
$html .= ”;
$html .= ”;
$html .= ‘
‘ . $counter . ‘. | ‘; $html .= ”; $order_items = $order->get_items(); $html .= ‘ Order details:‘ . ‘ ‘; Billing:‘ . ‘ ‘; |
‘; $html .= ‘Additional Fields:‘ . ‘ ‘; $data3 = ”; $data3 .= ‘Title: ‘ . $order->get_meta(‘additional_contact_title’) . ‘ ‘; $data3 .= ‘First Name: ‘ . $order->get_meta(‘additional_contact_first_name’) . ‘ ‘; $data3 .= ‘Last Name: ‘ . $order->get_meta(‘additional_contact_last_name’) . ‘ ‘; $data3 .= ‘Registration E-mail: ‘ . $order->get_meta(‘additional_contact_email’) . ‘ ‘; $data3 .= ‘E-mail who will receive on-site alerts: ‘ . $order->get_meta(‘additional_contact_alert’) . ‘ ‘; $data3 .= ‘Job Title: ‘ . $order->get_meta(‘additional_contact_position’) . ‘ ‘; $data3 .= ‘Phone: ‘ . $order->get_meta(‘additional_contact_phone’) . ‘ ‘; $html .= $data3; $html .= ‘ ‘; |
‘; $details = $order->get_meta(‘WooCommerceEventsOrderTickets’); $html .= ‘Attendees: ‘; |
‘;
$html .= ‘
‘;
}
$html .= ‘
‘;
$html .= ‘
‘;
if ($flat_data) {
return array($csv_data, $columnsNames);
}
echo $html;
die(“end”);
}