This is a page template for wordpress that displays woocommerce reports in a custom fashion for a venue that sells tickets.
<?php /*
Template Name: ORDERS Template
*/ ?>
<?php get_header(); ?>
<?php
global $wpdb;
?>
<div class="container">
<div class="sixteen columns pageWrapper">
<?php
/*****************************************************************************************************************************
*************************************VISIONQUEST CUSTOM**************************************************************
****************************************************************************************************************************/
?>
<div id="customers-orders-custom" >
<form id="main" name="main" action="" method="post">
<?php
//THIS JOINS ALL THE TABLES
$SQLQUERYONE = $wpdb->get_results("
SELECT *
FROM wp_woocommerce_order_items
ORDER BY order_item_name ASC
");
// echo "<pre>"; var_dump($SQLQUERYONE); echo "</pre>";
?>
<?php
//OLD BAD ATTEMPT
/*$SQLCUSTOMQUERY = $wpdb->get_results("
SELECT b.order_item_name, b.order_item_type, a.post_id, a.meta_key, a.meta_value
FROM wp_postmeta a, wp_woocommerce_order_items b
WHERE a.post_id=b.order_id
");*/
//echo "<pre>"; var_dump($SQLCUSTOMQUERY); echo "</pre>";
?>
<?php
$CUST_DATA = array();
$shows = array();
$SQLQUERYTWO = array();
foreach( $SQLQUERYONE as $show ) {
$shows[ trim($show->order_item_name) ] = true;
if ( isset( $selected_show ) && $selected_show == $show->order_item_name ) {
array_push( $SQLQUERYTWO, $wpdb->get_results("
SELECT *
FROM wp_postmeta
WHERE post_id = ". $show->order_id ."
") );
}
}
?>
<div class="shows">
<!-- Output dropdown of products from woocommerce (this was the title of our shows for The Loft)-->
<input type="hidden" name="search_type" value="members">
<select id="showsDrop" name="shows">
<option value="name">Shows</option>
<?php
$shows = array_keys( $shows );
foreach( $shows as $show ) {
echo '<option value="'.$show.'">'.$show.'</option>';
}
?>
</select>
</div>
<input id="customers" type="submit" name="script" value="customers" />
</form>
<div class="output"><?php
if ( count( $SQLQUERYTWO ) > 0 ) {
$first_go = true;
echo '<h1>' . $selected_show . '</h1>';
echo '<ul id="customer-order-data">';
foreach ( $SQLQUERYTWO as $data ) {
$previous_id = null;
foreach ( $data as $meta2 ) {
$id = $meta2->post_id;
//$name = $meta->
if ( $id != $previous_id ) {
$previous_id = $id;
if ( ! $first_go ) {
echo '</ul></li>';
}
echo '<li class="customer-element" id="order-id-'. $id .'"><ul id="order-table"><li style=" width: 50% !important;"><strong id="orders-title">ORDER NUMBER:</strong>'. $id . '</li>';
$first_go = false;
}
switch($meta2) {
case ($meta2->meta_key == 'attribute_time'):
echo '<li style=" width: 50% !important;"> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_billing_country'):
break;
case ($meta2->meta_key == '_billing_first_name'):
echo '<li style=" width: 50% !important;"> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_billing_last_name'):
echo '<li style=" width: 50% !important;"> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_billing_company'):
echo '<li> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_billing_email'):
echo '<li style=" width: 50% !important;" > '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_billing_phone'):
echo '<li style=" width: 50% !important;"> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_billing_address_1'):
break;
case ($meta2->meta_key == '_billing_address_2'):
break;
case ($meta2->meta_key == '_billing_city'):
break;
case ($meta2->meta_key == '_billing_state'):
break;
case ($meta2->meta_key == '_billing_postcode'):
break;
case ($meta2->meta_key == '_shipping_country'):
break;
case ($meta2->meta_key == '_shipping_first_name'):
echo '<li> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_shipping_last_name'):
echo '<li> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_shipping_company'):
echo '<li> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_shipping_address_1'):
break;
case ($meta2->meta_key == '_shipping_address_2'):
break;
case ($meta2->meta_key == '_shipping_city'):
break;
case ($meta2->meta_key == '_shipping_state'):
break;
case ($meta2->meta_key == '_shipping_postcode'):
break;
case ($meta2->meta_key == '_order_shipping'):
break;
case ($meta2->meta_key == '_order_discount'):
break;
case ($meta2->meta_key == '_cart_discount'):
break;
case ($meta2->meta_key == '_order_tax'):
break;
case ($meta2->meta_key == '_order_shipping_tax'):
break;
case ($meta2->meta_key == '_order_total'):
echo '<li> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_order_key'):
break;
case ($meta2->meta_key == '_customer_user'):
break;
case ($meta2->meta_key == '_order_currency'):
break;
case ($meta2->meta_key == '_prices_include_tax'):
break;
case ($meta2->meta_key == '_customer_ip_address'):
echo '<li style="width: 100% !important;"> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_customer_user_agent'):
echo '<li style="width: 100% !important;"> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_download_permissions_granted'):
break;
case ($meta2->meta_key == '_recorded_sales'):
break;
case ($meta2->meta_key == '_recorded_coupon_usage_counts'):
break;
case ($meta2->meta_key == '_paid_date'):
echo '<li> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
break;
case ($meta2->meta_key == '_payment_method'):
break;
case ($meta2->meta_key == '_payment_method_title'):
break;
default: {
echo '<li> '. '<strong id="orders-title">' . str_ireplace("_"," ", $meta2->meta_key) . ' </strong> ' . ' | ' . $meta2->meta_value . ' </li>';
}
}//end switch
//echo '<li> '. str_replace($meta2->meta_key) . ' ~~ ' . $meta2->meta_value . ' </li>';
}//end INNER foreach
//echo "<pre>"; var_dump($data); echo "</pre>";
//die();
}
echo '</ul>';
}
?></div>
</div> <!-- END OF customers-orders-custom -->
</div><!-- END OF CONTENT -->
</div>
<?php get_footer(); ?>