Show Update button for all products with insight data
- Removed margin check from manual update display - Update button now shows for ALL products that have Google price suggestions - Margin setting only applies to automatic updates (protection against auto price drops) - Full manual control: user decides whether to accept each suggestion Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -902,31 +902,12 @@ class Informatiq_SP_Admin {
|
||||
$suggested_price = $insight['suggested_price'] ?? null;
|
||||
$potential_gain = null;
|
||||
$percent_diff = null;
|
||||
$should_update = false;
|
||||
|
||||
// Get minimum margin setting.
|
||||
$min_margin = (float) get_option( 'informatiq_sp_minimum_margin', 10 );
|
||||
|
||||
if ( $suggested_price && $local_price_incl_tax ) {
|
||||
$potential_gain = round( $suggested_price - $local_price_incl_tax, 2 );
|
||||
|
||||
// Calculate percentage difference.
|
||||
$percent_diff = round( ( ( $suggested_price - $local_price_incl_tax ) / $local_price_incl_tax ) * 100, 1 );
|
||||
|
||||
// Calculate minimum allowed price (current price - margin%).
|
||||
$min_allowed_price = $local_price_incl_tax * ( 1 - ( $min_margin / 100 ) );
|
||||
|
||||
// Only suggest update if:
|
||||
// 1. Google recommends a different price (more than 0.05 diff)
|
||||
// 2. Suggested price is above our minimum allowed price
|
||||
$should_update = abs( $potential_gain ) > 0.05 && $suggested_price >= $min_allowed_price;
|
||||
|
||||
// If suggested is below minimum, cap it.
|
||||
if ( $suggested_price < $min_allowed_price ) {
|
||||
$suggested_price = round( $min_allowed_price, 2 );
|
||||
$potential_gain = round( $suggested_price - $local_price_incl_tax, 2 );
|
||||
$percent_diff = round( ( ( $suggested_price - $local_price_incl_tax ) / $local_price_incl_tax ) * 100, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
$comparison[] = array(
|
||||
@@ -943,7 +924,6 @@ class Informatiq_SP_Admin {
|
||||
'predicted_clicks_change' => $insight['predicted_clicks_change'] ?? null,
|
||||
'predicted_conversions_change' => $insight['predicted_conversions_change'] ?? null,
|
||||
'has_insight' => ! empty( $insight ),
|
||||
'should_update' => $should_update,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user