function mission_sales_tracker() { // Get total completed sales amount global $wpdb; $total_sales = $wpdb->get_var(" SELECT SUM(meta_value) FROM {$wpdb->postmeta} WHERE meta_key = '_order_total' AND post_id IN ( SELECT ID FROM {$wpdb->posts} WHERE post_type = 'shop_order' AND post_status = 'wc-completed' ) "); if (!$total_sales) { $total_sales = 0; } $target = 1000000; // ₹10 Lakh target // Date calculation $start_date = strtotime("2025-01-01"); // change if needed $end_date = strtotime("2025-12-31"); $today = time(); $days_left = max(0, ceil(($end_date - $today) / 86400)); $progress = min(100, round(($total_sales / $target) * 100, 2)); return "
Total Sales: ₹" . number_format($total_sales) . "
Target: ₹" . number_format($target) . "
Days Remaining: {$days_left}
Progress: {$progress}%