Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Single Event Php Script

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;

}
?>
over 4 years ago · Santiago Trujillo
1 answers
Answer question

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.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!