WP e-commerce: how to add columns to csv order export

To add price without shipping and shipping costs to the csv order export file, replace the code of wp-e-commerce/wpsc-admin/ajax-and-init.php (version 3.8.8.2 of WP e-commerce) from line 422 to line 431 with the following code:

$headers = ""Purchase ID","Purchase Total","Purchase without Shipping","Shipping","; //capture the headers
$headers2 =""Payment Gateway",";
$headers2 .=""Payment Status","Purchase Date",";

$output = '';

foreach ( (array)$data as $purchase ) {
$purch_item_price = $purchase['totalprice'];
$price_wo_shipping = $purch_item_price – (float)preg_replace('/[^0-9.]/', '', $purchase['base_shipping']);
$form_headers = '';
$output .= """ . $purchase['id'] . "","; //Purchase ID
$output .= """ . $purchase['totalprice'] . "","; //Purchase Total
$output .= """ . $price_wo_shipping . "","; //Item w/o shipping
$output .= """ . $purchase['base_shipping'] . "","; //Shipping

If you're using the country/region plugin and want also to display the region you can use the following code instead:

$headers = ""Purchase ID","Purchase Total","Purchase without Shipping","Shipping","Region","; //capture the headers
$headers2 =""Payment Gateway",";
$headers2 .=""Payment Status","Purchase Date",";

$output = '';

foreach ( (array)$data as $purchase ) {
$purch_item_price = $purchase['totalprice'];
$price_wo_shipping = $purch_item_price – (float)preg_replace('/[^0-9.]/', '', $purchase['base_shipping']);
$region = wpsc_get_region($purchase['billing_region']);
$form_headers = '';
$output .= """ . $purchase['id'] . "","; //Purchase ID
$output .= """ . $purchase['totalprice'] . "","; //Purchase Total
$output .= """ . $price_wo_shipping . "","; //Item w/o shipping
$output .= """ . $purchase['base_shipping'] . "","; //Shipping
$output .= """ . $region . "","; //region

Advertisements

About me

I share as I learn
This entry was posted in tutoriais and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s