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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 ) {
|
usort( $comparison, function( $a, $b ) {
|
||||||
$gain_a = $a['potential_gain'] ?? 0;
|
// Products without insight data go to the end.
|
||||||
$gain_b = $b['potential_gain'] ?? 0;
|
if ( ! $a['has_insight'] && $b['has_insight'] ) {
|
||||||
return $gain_b <=> $gain_a;
|
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(
|
wp_send_json_success( array(
|
||||||
|
|||||||
Reference in New Issue
Block a user