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 ");
$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.

What's the Buzz?

Andy is the consummate professional. He is sharp, creative, highly-skilled, and extremely responsive.  A true WordPress whiz. We are very pleased with our new website.

- Lauren McKibben
Incline Equity Partners