getshopped
06
Oct
2011
In getshopped
hack
php
WordPress
WordPress 3.0
WordPress Development
WordPress Plugins
wp e-commerce
By Andy
GetShopped – Add order without shipping column to sales view
On 06, Oct 2011 | One Comment | In getshopped, hack, php, WordPress, WordPress 3.0, WordPress Development, WordPress Plugins, wp e-commerce | By Andy
The sales view in the wp-ecommerce (GetShopped) is great but it will show you the total price of an order rather than the price without shipping, the shipping, and the total.
To introduce this functionality you do have to hack the plugin files, but there is not another way as I can not see any hooks I could make use of. If I have missed one, please do let me know!
Here is what you need to do-
Open ‘plugins/wp e-commerce/wpsc-admin/display-sales-logs.php’, go to around line 75 and find this-
if(!isset($_REQUEST['purchaselog_id'])){
$columns = array(
'cb' => '<input type="checkbox" />',
'purchid' => __( 'Order ID', 'wpsc' ),
'date' => __( 'Date / Time', 'wpsc' ),
'name' => '',
'amount' => __( 'Amount', 'wpsc' ),
'details' => __( 'Details', 'wpsc' ),
'status' => __( 'Status', 'wpsc' ),
'delete' => __( 'Delete', 'wpsc' ),
'track' => __( 'Tracking ID', 'wpsc' )
);
Change it to this-
if(!isset($_REQUEST['purchaselog_id'])){
$columns = array(
'cb' => '<input type="checkbox" />',
'purchid' => __( 'Order ID', 'wpsc' ),
'date' => __( 'Date / Time', 'wpsc' ),
'name' => '',
'pricewoshipping' => __( 'Price w/o Shipping', 'wpsc' ),
'shipping' => __( 'Shipping', 'wpsc' ),
'amount' => __( 'Total', 'wpsc' ),
'details' => __( 'Details', 'wpsc' ),
'status' => __( 'Status', 'wpsc' ),
'delete' => __( 'Delete', 'wpsc' ),
'track' => __( 'Tracking ID', 'wpsc' )
);
I have added in two new columns and also changed the Amount column name to Total. Then go to around line 452. You’re looking for the function called get_purchaselogs_content(). You will see a while statement that starts like this-
while(wpsc_have_purch_items()) : wpsc_the_purch_item();
?>
<tr>
<th class="check-column" scope="row"><input type='checkbox' name='purchlogids[]' class='editcheckbox' value='<?php echo wpsc_the_purch_item_id(); ?>' /></th>
<td><?php echo wpsc_the_purch_item_id(); ?></td><!-- purchase ID -->
<td><?php echo wpsc_the_purch_item_date(); ?></td> <!--Date -->
<td><?php echo wpsc_the_purch_item_name(); ?></td> <!--Name/email -->
After the Name/email <td> is where we will put our new column data.
First, we have to calculate the price without shipping. Do that like this-
<?php
$purch_item_price = wpsc_the_purch_item_price();
$price_wo_shipping = $purch_item_price - (float)preg_replace('/[^0-9.]/', '', wpsc_display_purchlog_shipping());
?>
Then you can add the table cell to display it-
<td><?php echo wpsc_currency_display( $price_wo_shipping ); ?></td><!-- Price w/o shipping -->
Then add the next custom column-
<td><?php echo wpsc_display_purchlog_shipping(); ?></td><!-- Shipping -->
And finally update the amount column- (you have to do this one because calling wpsc_the_purch_item_price() multiple times will add to your total. Which is not good.)
<td><?php echo wpsc_currency_display( $purch_item_price ); ?></td><!-- Amount -->
And we’re done! Nice and simple and now you/your clients can have a more informative first view of their sales.
Submit a Comment










Comments