Results 1 to 5 of 5

Thread: Adding tax and build fee in php

  1. #1
    Join Date
    Jun 2006
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Adding tax and build fee in php

    Hello all, im trying to build a website where you can build your own computer. The site is at: http://www.oharanetworks.com/jcr/build/4000/
    Im trying to add a sales tax and a 30% build fee onto all of the items in the array. Right now im doing this myself and putting the final value in the array but I know there is an easier way, because that is very time consuming. The entire code is here, sorry but it is a lot, too big to paste in here:
    http://www.oharanetworks.com/script.txt

    I know what your saying: Why did he do it like this? But this script works flawlessly, I have almost perfected it, but I wanted to add on a final sales tax and build fee on the final price, I dont know how to calculate that in php. Either you could do it for every individual item, or at the end have it calculate it for everything not sure, but please help. Please help me with what I need to get done though, please dont tell me what I should and should not do with either sections of the code that are not related. Thanks, this is the second time ive had to rewrite this.

  2. #2
    Join Date
    Jun 2006
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Rounding

    Nevermind, I just added in a couple of functions and solved it, now my problem is with rounding. I cant figure out how to get it to round my tax value. Here are my two functions:

    Code:
    function tax($items) {
        $html .= "" . total($items) * .0725 . "";
      return $html;
    }
    function formatItemList($items) {
      $si = getSelectedItems($items);
      $rt = 0;
      $html = '<table style="text-align:right; border-left:1px solid; border-right:1px solid; border-top:1px solid; border-bottom:1px solid;"><tr><th width="737">Item</th><th width="79">Price</th><th width="84">Running Total</th></tr>';
      for($i = 0; $i < count($si); ++$i)
        $html .= "<tr><td>" . $si[$i]['name'] . "</td><td>\$" . toCurrency($si[$i]['price']) . "</td><td>\$" . toCurrency($rt += $si[$i]['price']) . "</tr>";
    	$html .= "<tr><td>Tax:</td><td>\$"round(tax($items),2)"</td><td></tr>";
        $html .= "<tr><td>JCR Gaming Systems Build Fee:</td><td>\$" . jcrbuildfee($items) . "</td><td></tr>";
      $html .= "<tr><td></td></tr><tr><td></td></tr><tr><td><b>Total:</b></td><td>\$" . finaltotal($items) . "</td></tr></table>";
      return $html;
    }
    The tax function gives me a tax, but with like 5 decimal places afterwards, I have tried incorporating the round function into it but it wont work. Please help, thx.

  3. #3
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Nevermind, I just added in a couple of functions and solved it
    good for u
    Please don't mind me. I am just posting a lot of nonsense.

  4. #4
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    You might try echoing javascript into the PHP for the additional costs.

  5. #5
    Join Date
    Jun 2006
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks but I just need to know what's wrong with the rounding code posted above? I dont know why it doesn't work. Please help Thnks

Bookmarks

Posting Permissions

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