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 top notch programmer with a great eye for design, style and balance. When I out source web development projects, I look for qualified and competent programmers that can understand the big picture, add value throughout entire process, and pays close attention to the details – Andy fits the bill.

Andy is well-versed in web development using various programming languages and CMS platforms. Andy is able to deliver a flawless website based on the creative vision and project requirements. He is able to do it on time and on budget.

I highly recommended Andy as a web developer and give him four stars on his professionalism.

- John LeDonne
LeDonne Creative