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

149
Views
Script Php de evento único

Estoy creando un formulario en el que un cajero ingresará una cantidad en dólares. Cuando ingresan ese monto en dólares, se agregarán 100 puntos a su cuenta por cada dólar gastado. Esto se basa en WordPress, por lo que verá que obtengo y actualizo este valor de puntos con update_user_meta(); y get_user_meta(); que están integrados en WordPress.

Verá que tengo un montón de declaraciones if que se activan cuando el usuario alcanza los diferentes niveles de puntos. Mi pregunta es ¿cómo puedo hacer que esas declaraciones solo aparezcan la primera vez que superen el umbral de puntos?

 <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

Usando su código existente, agregaría otra condición a elseif para verificar el total anterior, algo así como

 } elseif($prev_total < 5000 && $now_total > 4999 && $now_total < 7500){

Entonces, la próxima vez que realicen una compra, el valor total anterior estaría dentro de estos límites, por lo que no debería llegar hasta la próxima.

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!