ID == \'\') { header(\"Location: https://www.artisanfurniture.net/login/\"); } else { $currentPage = \'https://\' . $_SERVER[\'HTTP_HOST\'] . $_SERVER[\'REQUEST_URI\']; ?> 0 AND wp_users.ID = $user->ID \"; $orderQuery = \" SELECT *, cast(meta_value as UNSIGNED ) as totalOrders FROM wp_usermeta LEFT JOIN wp_users on wp_usermeta.user_id = wp_users.ID WHERE meta_key = \'_order_count\' AND meta_value > 0 AND wp_users.ID = $user->ID \"; /* Total Purchase */ $customerPurchaseQuery = \"SELECT Month(post_date) as pDate, Date(post_date) as postMonth, COUNT(*) AS countx FROM wp_posts where post_type = \'shop_order\' AND Date(post_date) > curdate() - interval (dayofmonth(curdate()) - 1) day - interval 1 month AND post_author = $user->ID GROUP BY pDate\"; $customer_orders = $wpdb->get_results($customerPurchaseQuery, ARRAY_A); $customerPurchaseMonths = []; $customerPurchaseAmount = []; $totalPurchase = 0; $totalOrders = 0; foreach( $customer_orders as $order ) { $orderMonth = Date( \'m\', strtotime($order[\'postMonth\']) ); $orderMonthDataQuery = \"select *, meta_value from wp_posts left join wp_woocommerce_order_items on wp_woocommerce_order_items.order_id = wp_posts.id left join wp_woocommerce_order_itemmeta on wp_woocommerce_order_itemmeta.order_item_id = wp_woocommerce_order_items.order_item_id where Month(post_date) = $orderMonth and order_item_type = \'line_item\' AND Date(post_date) > curdate() - interval (dayofmonth(curdate()) - 1) day - interval 1 month and meta_key = \'_line_total\' and post_author = $user->ID\"; $orderMonthData = $wpdb->get_results($orderMonthDataQuery, ARRAY_A); $monthTotal = 0; $orderMonthCount = 0; $totalOrders += $order[\'countx\']; foreach( $orderMonthData as $monthData ) { $itemAmount = number_format($monthData[ \'meta_value\' ],2); $monthTotal += $itemAmount; $totalPurchase += number_format($itemAmount,2); $orderMonthCount++; } $customerPurchaseMonths [] = Date( \'M Y\', strtotime($order[\'postMonth\']) ); $customerPurchaseAmount [] = $monthTotal; } $totalPurchase = number_format($totalPurchase,2); if( $totalPurchase > 0 ) { $averageSales = $totalPurchase/$orderMonthCount; } else { $averageSales = 0; } /*$wpdb->get_results( \"SELECT AVG( net_total ) as total FROM wp_wc_order_stats LEFT JOIN wp_users on wp_users.ID = wp_wc_order_stats.customer_id where customer_id > 0 AND wp_users.ID = $user->ID\" );*/ $totalTickets = $wpdb->get_results( \"SELECT *, count( wp_users.ID ) as totalTickets FROM wp_wpsc_ticket LEFT JOIN wp_users on wp_wpsc_ticket.customer_email = wp_users.user_email AND wp_wpsc_ticket.customer_email = wp_users.user_email AND wp_users.ID = $user->ID group by wp_users.ID \" ); foreach( $totalTickets as $ticketRow ) { if( $ticketRow->user_email == $user->user_email ) { $totalTickets = $ticketRow->totalTickets; } } $totalTickets = is_array( $totalTickets) ? 0 : $totalTickets ; $reorderItems = []; $reorderValues= []; $reorderBackground = []; $reorderQuery = \"select order_item_name, count(order_id) as reorder from wp_posts left join wp_woocommerce_order_items on wp_woocommerce_order_items.order_id = wp_posts.id and order_item_type = \'line_item\' and post_author = $user->ID AND Date(post_date) > curdate() - interval (dayofmonth(curdate()) - 1) day - interval 1 month group by order_id order by reorder desc limit 10\"; $reorderData = $wpdb->get_results($reorderQuery, ARRAY_A); foreach( $reorderData as $reorder ) { if( strlen( $reorder[ \'order_item_name\' ] ) > 0 ) { $reorderItems[] = substr($reorder[ \'order_item_name\' ], 0, 10).\'...\'; $reorderValues[] = $reorder[ \'reorder\' ]; $reorderBackground[] = \'white\'; } } $topSellingItems = []; $topSellingValues = []; $topSellingQuery = \"SELECT *, count( meta_id ) as cityCount FROM wp_postmeta inner join wp_posts on wp_posts.ID = wp_postmeta.post_id WHERE meta_key = \'_shipping_city\' AND meta_value IS NOT NULL AND meta_value \'\' and post_author = $user->ID AND Date(post_date) > curdate() - interval (dayofmonth(curdate()) - 1) day - interval 1 month group by post_author order by cityCount desc limit 10\"; $topSellingData = $wpdb->get_results($topSellingQuery, ARRAY_A); foreach( $topSellingData as $topSelling ) { $topSellingItems[] = $topSelling[ \'meta_value\' ]; $topSellingValues[] = $topSelling[ \'cityCount\' ]; } ?>

Name

user_nicename?> |


Company

Company |


Address

ID, \'billing_address_1\', true ); $address_2 = get_user_meta( $current_user->ID, \'billing_address_2\', true ); $city = get_user_meta( $current_user->ID, \'billing_city\', true ); $postcode = get_user_meta( $current_user->ID, \'billing_postcode\', true ); echo $address_1 . \" \"; echo $address_2 . \" \"; echo $city . \" \"; echo $postcode . \" | \"; ?>


Registered on

user_registered ) )?>

30 Days Statics

Total Purchase

TOTAL ORDERS

AVERAGE SALES

TICKETS RAISED

Total Purchase

<!----> 0 ) { ?>

No data to show.

Re-Order Frequency

0 ) { ?>

No data to show.

Top Seller

0 ) { ?>

No data to show.

Top Selling Zones

0 ) { ?>

No data to show.

get_results( \"SELECT GROUP_CONCAT(DISTINCT id SEPARATOR \',\') as orders, post_date FROM wp_posts WHERE MONTH(post_date) = MONTH(CURRENT_DATE()) AND YEAR(post_date) = YEAR(CURRENT_DATE()) GROUP BY post_date \" ); $tt = 1000; ?>
Shopping Cart
Scroll to Top