From b07810a88e2804f5fbc4f8c1c2abf57d19fc8b74 Mon Sep 17 00:00:00 2001 From: Malin Date: Fri, 23 Jan 2026 18:38:49 +0100 Subject: [PATCH] Sort by predicted conversion change, no-data products last eCommerce priority: conversions drive revenue - Products with highest predicted conversion increase shown first - Products without Google insight data moved to end of list Co-Authored-By: Claude Opus 4.5 --- admin/class-informatiq-sp-admin.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/admin/class-informatiq-sp-admin.php b/admin/class-informatiq-sp-admin.php index 5ba71f45..005777de 100644 --- a/admin/class-informatiq-sp-admin.php +++ b/admin/class-informatiq-sp-admin.php @@ -922,11 +922,23 @@ class Informatiq_SP_Admin { ); } - // Sort by potential gain (highest first). + // Sort by predicted conversion change (highest first), products without data last. usort( $comparison, function( $a, $b ) { - $gain_a = $a['potential_gain'] ?? 0; - $gain_b = $b['potential_gain'] ?? 0; - return $gain_b <=> $gain_a; + // Products without insight data go to the end. + if ( ! $a['has_insight'] && $b['has_insight'] ) { + return 1; + } + if ( $a['has_insight'] && ! $b['has_insight'] ) { + return -1; + } + if ( ! $a['has_insight'] && ! $b['has_insight'] ) { + return 0; + } + + // Sort by predicted conversion change (highest first). + $conv_a = $a['predicted_conversions_change'] ?? -999; + $conv_b = $b['predicted_conversions_change'] ?? -999; + return $conv_b <=> $conv_a; } ); wp_send_json_success( array(