Jump to content

code for adding Tax to Total in cart


nrkar

Recommended Posts

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
Share on other sites

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
Share on other sites

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  :P

 

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.