Image Image Image Image Image
Scroll to Top

To Top

getshopped

Getshopped – Add more details to sales CSV

I have previously showed I added shipping columns to the sales logs page in a getshopped (Wp-Ecommerce) installation. This was fine but now we need that data to show up in the csv download.

Here’s how to do it-

Open wp-content/plugins/wp-e-commerce/wpsc-admin/ajax-and-init.php and find the function wpsc_purchase_log_csv();

Find this-

$headers = ""Purchase ID","Purchase Total","; //capture the headers

And replace it with this-

$headers = "Purchase ID, Item Price, Item Shipping, Item Total,"; //capture the headers

A few lines under that you will find the beginning of the foreach loop, which looks like this-

foreach ( (array)$data as $purchase ) {

Right after that add this-

              $purch_item_price = $purchase['totalprice'];

              $price_wo_shipping = $purch_item_price - (float)preg_replace('/[^0-9.]/', '', $purchase['base_shipping']);

And then below that should be this-

            $form_headers = '';
            $output .= """ . $purchase['id'] . "","; //Purchase ID
            $output .= """ . $purchase['totalprice'] . "","; //Purchase Total

Replace it with this-

            $form_headers = '';
            $output .= """ . $purchase['id'] . "","; //Purchase ID
            $output .= """ . $price_wo_shipping . "","; //Item w/o shipping
            $output .= """ . $purchase['base_shipping'] . "","; //Shipping
            $output .= """ . $purchase['totalprice'] . "","; //Purchase Total

 

And you’re done!

Have fun!

 

Comments

  1. You just saved me having to find an alternative e-commerce plugin… THANK YOU!

    • fish

      woo hoo!

Submit a Comment