nrkar Posted August 13, 2012 Share Posted August 13, 2012 I would be grateful to someone who can help me with the coding for Cart.php file attached herewith. I need to add Tax @7.75% to the SubTotal and the Grand total should appear just below the SubTotal. Total :........ Tax:........... Total Including Tax:............. Thanks in advance... 18839_.php Link to comment https://forums.phpfreaks.com/topic/267001-code-for-adding-tax-to-total-in-cart/ Share on other sites More sharing options...
acidpunk Posted August 13, 2012 Share Posted August 13, 2012 It's 3:15 AM in the morning here, I honestly was going to help you further than give you the formula, but after seeing 1,500 lines of code, i couldn't skim it without passing out. Formula for getting the tax: price*tax/100 $price_of_item = 50; $tax_rate = 7.75; $total_tax = $price_of_item*$tax_rate/100; echo '$$total_tax'; if you go search through cart.php after you find the "$price" variable in that script, you can add $tax variable. Link to comment https://forums.phpfreaks.com/topic/267001-code-for-adding-tax-to-total-in-cart/#findComment-1368919 Share on other sites More sharing options...
acidpunk Posted August 13, 2012 Share Posted August 13, 2012 I started you off on 1, I found the 1st price variable around lines 70 and down. i added a noted "TAX EDIT" i'm sure you can work from there, but If nothings figured out by tomorrow, i shall help you. Just really tired if($option_settings && is_array($option_settings)){ // now we work out what values to add to the shopping cart session array. // we want the name of the product $product_name = $product_settings['name']; // we want it's price, the price of the option that the user selected: $price = $option_settings['price']; //TAX EDIT - you want the tax, well here it is. $tax = $option_settings['tax']; // we see if there is a name of the option that the user selected. if(isset($option_settings['name']) && $option_settings['name'] && $option_settings['name'] != $product_name){ $product_name .= ' - ' . $option_settings['name']; } // and work out the quantity ordered, with a defualt of 1. $quantity = max(1, ((int)$_REQUEST['quantity']) ? (int)$_REQUEST['quantity'] : 1 ); $product_uri = (isset($_REQUEST['url']))?$_REQUEST['url']:''; $new_product = array( // values that are showed to the user in checkout: "name"=>$product_name, "price"=>$price, "tax"=>$tax, "quantity"=>$quantity, "product_uri"=>$product_uri, "product_option"=>$product_option, "product_settings"=>$product_settings, ); Link to comment https://forums.phpfreaks.com/topic/267001-code-for-adding-tax-to-total-in-cart/#findComment-1368920 Share on other sites More sharing options...
nrkar Posted August 19, 2012 Author Share Posted August 19, 2012 Thank you for your help. I have checked it once and could not get the result. I will be rechecking it today and let you know if I am successful. Thanks once again... Link to comment https://forums.phpfreaks.com/topic/267001-code-for-adding-tax-to-total-in-cart/#findComment-1370682 Share on other sites More sharing options...
nrkar Posted August 19, 2012 Author Share Posted August 19, 2012 Hi, I got the following error after adding the code that you have given me. Notice: Undefined index: tax in /home2/appleweb/public_html/ravis/cart.php on line 97 Notice: Undefined variable: price_of_item in /home2/appleweb/public_html/ravis/cart.php on line 99 $$total_tax Warning: Cannot modify header information - headers already sent by (output started at /home2/appleweb/public_html/ravis/cart.php:97) in /home2/appleweb/public_html/ravis/cart.php on line 163 I have attached the file herewith....kindly check it. I can pay a few dollars if you can help me out with this...Thanks 18871_.php Link to comment https://forums.phpfreaks.com/topic/267001-code-for-adding-tax-to-total-in-cart/#findComment-1370694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.