Advertisement
malikperang2

Discount

Oct 5th, 2015
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. <?php
  2. $item_price = 60.00;
  3. $quantity = 2;
  4.  
  5. //sum total
  6. $total_price = $item_price * $quantity;
  7.  
  8. //check discount
  9. if ($total_price >= 100 ) {
  10.     //calculate 10% discount
  11.     $subtotal = $total_price * 0.10;
  12.  
  13.     //calculate total after discount
  14.     $total_price_after_discount = $total_price - $subtotal;
  15.  
  16.     echo 'Harga selepas diskaun :' . $total_price_after_discount;
  17.  
  18. }else{
  19.     echo 'Tiada diskaun harga:' . $total_price;
  20. }
  21.  
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement