Add column to WP-Ecommerce Purchase Logs

I recently needed to extend the columns of the WPSC purchase logs dashboard page to add a custom column “invoice number”.
I found some hints to use the filter wpsc_manage_purchase_logs_columns which looks quite suitable but found out this has been removed in favor of the WordPress core functions
https://github.com/leewillis77/WP-e-Commerce/commit/76267fbb870230f4da6aeb095d02d17c610b75db

A great article by Claudio Simeone pointed me the right direction.

 

And finally here is the result

I used the code in a plugin, but I’ve rewritten the functions to be used in your themes functions.php

/***********************************
define the new column
***********************************/
function addPurchaseLogColumnHead( $columns ){
$columns['invoicenumber']=__('Invoice Number','haetshopstyling');
return $columns;
}
add_filter( 'manage_dashboard_page_wpsc-purchase-logs_columns', 'addPurchaseLogColumnHead') );

/***********************************
add content to the new column
***********************************/
function addPurchaseLogColumnContent( $default, $column_name, $item ){
    if($column_name=='invoicenumber'){
        echo getInvoiceNumber($item->id);
    }
}
add_filter( 'wpsc_manage_purchase_logs_custom_column', 'addPurchaseLogColumnContent',10,3 );

This is the result in your WPSC sales log

Custom column in wpsc sales log

10 Responses to “Add column to WP-Ecommerce Purchase Logs”

  1. Pete

    Hi there,

    Thanks for posting this. I tried implementing this to display the Order Notes – tried a number of variations but it seem to want to display

    tried (among others)

    echo $purchlog_notes->notes;

    would you have any idea?

    Reply
    • Hannes

      Hi Pete,
      Try this code:

      global $wpdb;
      $sql = $wpdb->prepare('
      SELECT notes
      FROM '.WPSC_TABLE_PURCHASE_LOGS.'
      WHERE id=%d
      ',$item->id);
      echo $wpdb->get_var($sql);

      best regards, Hannes

      Reply
  2. steven

    Hello thanks for your post. This is what i need but i got an error
    Parse error: syntax error, unexpected T_RETURN, expecting ‘]’ in /homez.723/gabelbat/www/gabelpoles/wp-content/themes/theme1274/functions.php on line 80

    what i can do??

    Thanks

    Reply
    • Hannes

      Hi Steven, I assume you forgot a closing bracket, but I can’t see line 80 of your functions.php 🙂
      You can send me the file and I’ll have a look.
      Best regards, Hannes

      Reply
  3. Edward

    Hi,

    Recently installed your WP Shop Styling pluggin with the paid extensions and I am very impressed. Thanks for producing this for people to use.

    I am now setting up my track and trace email but I want to be able to provide some extra information. Instead of just the tracking ID. I want to be able to provide both the courier company name, website, and an estimate of the delivery. (we use several different couriers.)

    Happy to enter this information manually next to the ‘Tracking ID’ on the sales log. Unfortunately, I’m not comfortable hard coding this myself, does the above functionality come in a plugin the we can purchase?

    Thanks,

    Ed

    Reply
    • hannes

      Hi Ed,
      this feature doesn’t exist yet. But I can add the fields you need to the purchase logs table and add placeholders to the tracking email.
      I’ll send you an offer to your email address.

      Reply
  4. Jan Andersen

    Hi

    I tried this as this functionality is exactly what I want – I think, but when I inserted the code at the end of themes/point/functions.php things just stopped working. Am I overlooking something (I’m not a developer)

    We need to be able to put invoice number on the invoices – not just reusing the order numbers in system. We use your web styling wp plugin and the invoice and transactions modules

    Reply
    • hannes

      Hey Jan,
      I see two possible that could have happened:
      1. There was a character encoding error in my code above. If you find > in your code replace it with >.
      2. The function getInvoiceNumber actually doesn’t exist. This is just an example.

      Do you use any custom invoice number yet? How do you calculate it?

      Reply
      • Jan Andersen

        Hi Hannes
        I didn’t see your reply until now. Actually I just want to be able to manually insert invoice number into sales log dashboard as I do with Tracking ID.
        I seem to remember that I somewhere saw regarding your plugin a selection on wether you want ordernumber, manual or invoicenumber as invoice number. At that time I didn’t know which one to pick, so I picked order number but I should have picked manual which should enable me to enter invoice numbers manually

        I do not calculate invoice numbers as we are small business and some invoices are made from computer and some will hopefully be automatically generated from website plugin

        Reply

Leave a Reply