I'm building a form that a cashier will enter a dollar amount into. When they enter that dollar amount it will add 100 points to their account for every dollar spent. This is built on WordPress so you'll see I'm getting and updating this point value with update_user_meta(); and get_user_meta(); which are built into WordPress.
You'll see I have a bunch of if statements that fire when the user hits the different point levels. My question is how can I make those statements only appear the very first time they've gone over the point threshold?
<form method="post" action="">
$<input type="text" name="value">
<input type="submit">
</form>
<?php
$prev_total = get_user_meta(get_current_user_id(), mycred_default, true);
$add_total = (floor($_POST['value']) * 100);
$now_total = $prev_total + $add_total;
update_user_meta(get_current_user_id(), mycred_default, $now_total);
echo get_user_meta(get_current_user_id(), mycred_default, true);
if($now_total > 0 && $now_total < 2501){
echo "<h2>Customer Get's A Free Small Cup or Cone of Custard: Next Level 5000 Points.</h2>";
} elseif($now_total > 4999 && $now_total < 7500){
echo "<h2>Customer Get's A Free Medium Gelato: Next Level 7500 Points.</h2>";
} elseif($now_total > 7499 && $now_total < 10000){
echo "<h2>Customer Get's A Free Brownie Blackout: Next Level 10,000 Points.</h2>";
} elseif($now_total > 9999 && $now_total < 15000){
echo "<h2>Customer Get's A Free Large Milk Shake: Next Level 15,000 Points.</h2>";
} elseif($now_total > 14999 && $now_total < 20000){
echo "<h2>Customer Get's A Free Pint of Custard: Next Level 20,000 Points.</h2>";
} elseif($now_total > 19999 && $now_total < 25000){
echo "<h2>Customer Get's A Free Pint of Custard: Next Level 25,000 Points.</h2>";
} elseif($now_total > 24999 && $now_total < 35000){
echo "<h2>Customer Get's A Free Round of Mini Golf: Next Level 35,000 Points.</h2>";
} elseif($now_total > 34999 && $now_total < 45000){
echo "<h2>Customer Get's A Free Small Custard Cake: Next Level 45,000 Points.</h2>";
} elseif($now_total > 44999 && $now_total < 50000){
echo "<h2>Customer Get's 20 Free Batting Cage Tokens: Next Level 50,000 Points.</h2>";
} elseif($now_total >= 50000){
echo "<h2>Customer Get's 20 Free Batting Cage Tokens & 20 Free Batting Cage Tokens.</h2>";
$now_total = 0;
}
?>
Using your existing code I would add another condition to the elseif's to check the previous total - something like
} elseif($prev_total < 5000 && $now_total > 4999 && $now_total < 7500){
So the next time they make a purchase the previous total value would be within these limits so it shouldn't hit until the next one.