fix: depleted items urgency — use buyCount/useCount from internal history to assign medium/low
This commit is contained in:
+13
-4
@@ -7658,11 +7658,20 @@ function smartShopping(PDO $db): void {
|
|||||||
$reasons[] = 'Esaurito';
|
$reasons[] = 'Esaurito';
|
||||||
$score += 30;
|
$score += 30;
|
||||||
} else {
|
} else {
|
||||||
// Product is depleted. Even without a proven usage pattern, always
|
// Product is depleted. Use internal history variables to set urgency:
|
||||||
// show at minimum 'low' so the user can restock it.
|
// bought ≥2 times → medium (proven restock item), once → low (might want it),
|
||||||
$urgency = 'low';
|
// never bought (manually added) → low.
|
||||||
$reasons[] = 'Esaurito';
|
$reasons[] = 'Esaurito';
|
||||||
$score += 15;
|
if ($buyCount >= 2) {
|
||||||
|
$urgency = 'medium';
|
||||||
|
$score += 45;
|
||||||
|
} elseif ($buyCount >= 1 || $useCount >= 2) {
|
||||||
|
$urgency = 'low';
|
||||||
|
$score += 25;
|
||||||
|
} else {
|
||||||
|
$urgency = 'low';
|
||||||
|
$score += 10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user