WC_Report_Customers::customers_vs_guests()
Output customers vs guests chart.
Contents
Description Description
Source Source
File: includes/admin/reports/class-wc-report-customers.php
public function customers_vs_guests() { $customer_order_totals = $this->get_order_report_data( array( 'data' => array( 'ID' => array( 'type' => 'post_data', 'function' => 'COUNT', 'name' => 'total_orders', ), ), 'where_meta' => array( array( 'meta_key' => '_customer_user', 'meta_value' => '0', 'operator' => '>', ), ), 'filter_range' => true, ) ); $guest_order_totals = $this->get_order_report_data( array( 'data' => array( 'ID' => array( 'type' => 'post_data', 'function' => 'COUNT', 'name' => 'total_orders', ), ), 'where_meta' => array( array( 'meta_key' => '_customer_user', 'meta_value' => '0', 'operator' => '=', ), ), 'filter_range' => true, ) ); ?> <div class="chart-container"> <div class="chart-placeholder customers_vs_guests pie-chart" style="height:200px"></div> <ul class="pie-chart-legend"> <li style="border-color: <?php echo esc_attr( $this->chart_colours['customers'] ); ?>"><?php esc_html_e( 'Customer sales', 'woocommerce' ); ?></li> <li style="border-color: <?php echo esc_attr( $this->chart_colours['guests'] ); ?>"><?php esc_html_e( 'Guest sales', 'woocommerce' ); ?></li> </ul> </div> <script type="text/javascript"> jQuery(function(){ jQuery.plot( jQuery('.chart-placeholder.customers_vs_guests'), [ { label: '<?php esc_html_e( 'Customer orders', 'woocommerce' ); ?>', data: "<?php echo esc_html( $customer_order_totals->total_orders ); ?>", color: '<?php echo esc_html( $this->chart_colours['customers'] ); ?>' }, { label: '<?php esc_html_e( 'Guest orders', 'woocommerce' ); ?>', data: "<?php echo esc_html( $guest_order_totals->total_orders ); ?>", color: '<?php echo esc_html( $this->chart_colours['guests'] ); ?>' } ], { grid: { hoverable: true }, series: { pie: { show: true, radius: 1, innerRadius: 0.6, label: { show: false } }, enable_tooltip: true, append_tooltip: "<?php echo esc_html( ' ' . __( 'orders', 'woocommerce' ) ); ?>", }, legend: { show: false } } ); jQuery('.chart-placeholder.customers_vs_guests').resize(); }); </script> <?php }