Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2011
    Posts
    113
    Thanks
    9
    Thanked 1 Time in 1 Post

    [Help] ----------- Taking a % off a price ---------

    Hello Coding Forums,

    I need help. I have made a coupon code system which will take of the designated amount off their purchase.

    PHP Code:
    if ($_POST['coupon'] == $coupon) {
     
    $percent_off 15;
     
    $price $price //math here to get 15% off of the price

    How would I do this?

    Regards,
    Vern

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Trivial mathematics.
    Code:
    $price *= (100 - $percent_off) / 100;
    I could absolutely swear we've answered this question for you already.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •