WP-E-Commerce Add Tax to Receipt

Wordpress How-To's,WordPress Plugins

Interested in adding the sales tax to your WP-e-Commerce receipts? It wasn’t as easy as I had thought. They don’t record the total tax for each order, so we need to add it up ourselves and add it to both the email receipt and the transaction details screen.

The first thing you need to do is open the “transaction-result_functions.php” file from the wp-e-commerce plugin. Then search for “$product_list_html.= $row[‘quantity’].” –  “. $product_data[‘name’].stripslashes($variation_list ).”  “. $message_price .”\n\r”;”

Then add this code right after that –

$region = $purchase_log['billing_region'];
$region_results = mysql_query("SELECT * FROM `wp_wpsc_region_tax` WHERE `id` = 
$region ");
while($r=mysql_fetch_array($region_results))
{
$tax_rate = $r['tax'];
}
$product_id[] = $product_data['id'];
$tax_percent = $tax_rate * .01;
$message_price_clean = str_replace("$","",$message_price);
$tax_sub_total = $message_price_clean * $tax_percent;
$tax_total[] = $tax_sub_total;

Then find this line – $product_list_html.= “Your Purchase No.: “.$purchase_log[‘id’].”\n\n\r”; and add this

$tax_total = array_sum($tax_total);
$tax_total = round($tax_total, 2);
$product_list_html.= "Tax: $" .$tax_total ."\n\r";
$product_list.= "Tax: $" .$tax_total ."\n\r";

This will add a tax line to both the email receipt and the transaction details screen, after a customer has a made a purchase. If it’s from a region where sales doesn’t apply, the tax will be zero.

Leave a Reply

Your email address will not be published. Required fields are marked *

What's the Buzz?

Andy is a true professional who is one of the most capable people I have ever worked with. His enthusiasm for his job is impressive and his ability to adapt and evolve to a new task is incredible. He is one of those rare people who you can tell where you want to get to and he can engineer the path there for you and give you extra choices along the way. His ability to learn new skills, willingness to continue to grow and expand is astounding. He’s also very skilled at what he does now and has a great eye for design and usability, blending form and function with class. And he’s fun to spend time with.

- Claire Devereux Thompson
Sterling Advertising