Customizing purchase log email in WP-Ecommerce

There is an useful filter/hook you could use. I used this hook to increase space between columns and showing Subtotal and Shipping cost aligned to the right and aligning parallel it with the product cost, as shown in the figure below.

wp-ecommerce-purchase-log-customization

Following the code i placed in my themes/themename/function.php file.

[php]
function apsc_get_purchase_log_html_table( $output, $headings, $rows ) {
ob_start();
$td_widths = array(40,15,15,30);
$i=0;
?></pre>
$align ):
$style = "width:".$td_widths[$i]."%"; if($i==0) { $style .= ";text-align:left;"; } if($i==3) { $style .= ";text-align:right;"; } if($i==1 OR $i==2) { $style .= ";text-align:center;"; } ?>
<table class="wpsc-purchase-log-transaction-results" width="70%"><!–?php if ( ! empty( $headings ) ): ?–>
<thead><!–?php foreach ( $headings as $heading =–><!–?php $i++; endforeach; ?–></thead>
<!–?php endif; ?–>
<tbody><!–?php foreach ( $rows as $row ): $i=0; ?–>
<tr><!–?php foreach ( $row as $col ): $style = "width:".$td_widths[$i]."%"; if($i==0) { $style .= ";text-align:left;"; } if($i==3) { $style .= ";text-align:right;"; } if($i==1 OR $i==2) { $style .= ";text-align:center;"; } ?–>
<td></td>
<!–?php $i++; endforeach; ?–></tr>
<!–?php endforeach; ?–></tbody>
</table>
<pre> <!–?php <br ?–> $output = ob_get_clean();
return $output;
}
add_filter(‘wpsc_get_purchase_log_html_table’, ‘apsc_get_purchase_log_html_table’,10,3);
[/php]

Remember you will need to specify the fourth argument of the filter function so it passes all $output, $headings and $rows to your filter function. Here’s is a brief introduction of each argument.

  • $output – This is the table which the “wpsc_get_purchase_log_html_table” function of purchase log helper (wpsc-includes/purchase-log-helpers.php) prepares for you. You could modify this output but better method is to create your own output using $headings and $rows data.
  • $headings – Contains table headings which you could use to create your table headings (s). It normally has four values i.e. Name, Price, Quantity and Item Total.
  • $rows – This contains list of products in a form of an array which you use to create rows of the log table.

I have set width of each column to 40, 15, 15 and 30 percent respectively. Also i set the text-align property to left and right for first and last columns and center of second and third fcolumn so they look better aligned,in the table. Additionally  if you wanted the width of wrapping table set you can do that by editing the Message Body textarea value in Customer Purchase Receipt under the Admin tab in your Store settings.

Leave a Reply