-1, 'status' => 'completed', // You can customize the order status )); // Prepare data for the chart $labels = array(); $avgOrderValueData = array(); foreach ($orders as $order) { $order_date = $order->get_date_completed() ? $order->get_date_completed()->format('Y-m-d') : $order->get_date_created()->format('Y-m-d'); $labels[] = $order_date; $avgOrderValueData[] = $order->get_total() / $order->get_item_count(); // Average Order Value } // Chart configuration $chart_config = array( 'type' => 'bar', 'data' => array( 'labels' => $labels, 'datasets' => array( array( 'label' => 'Avg Order Value', 'data' => $avgOrderValueData, 'backgroundColor' => 'rgba(255, 205, 86, 0.2)', 'borderColor' => 'rgba(255, 205, 86, 1)', 'borderWidth' => 2, ), ), ), 'options' => array( 'scales' => array( 'y' => array( 'beginAtZero' => true, ), ), ), ); // Print the chart script ?> [woocommerce_avg_order_value_chart]