wpsc_purchase_log_notification_product_table_args

Located in: purchase-log-notification.class.php

Functions that call this hook: get_table_args()

Arguments Accepted: $args, $this

Version Introduced: 3.8.9

Description: Filter the array containing default arguments to generate the product list table used in purchase notifications.

Code in context:

[php firstline=”65″ highlight=”116″]

private function get_table_args() {

$log_id = $this->purchase_log->get( ‘id’ );

$log_data = $this->purchase_log->get_data();

$rows = array();

$headings = array(

_x( ‘Name’ , ‘purchase log notification table heading’, ‘wpsc’ ) => ‘left’,

_x( ‘Price’ , ‘purchase log notification table heading’, ‘wpsc’ ) => ‘right’,

_x( ‘Quantity’ , ‘purchase log notification table heading’, ‘wpsc’ ) => ‘right’,

_x( ‘Item Total’ , ‘purchase log notification table heading’, ‘wpsc’ ) => ‘right’,

);

$has_additional_details = false;

$additional_details = array();

foreach( $this->purchase_log->get_cart_contents() as $item ) {

$cart_item_array = array(

‘purchase_id’ => $log_id,

‘cart_item’ => (array) $item,

‘purchase_log’ => $log_data,

);

// legacy code, which Gary honestly doesn’t fully understand because it just doesn’t make sense

// prior to 3.8.9, these actions are called on each product item. Don’t really know what they do.

do_action( ‘wpsc_transaction_result_cart_item’, $cart_item_array );

do_action( ‘wpsc_confirm_checkout’, $log_id );

// then there’s also this annoying apply_filters call, which is apparently not the best example

// of how to use it, but we have to preserve them anyways

$additional_content = apply_filters( ‘wpsc_transaction_result_content’, array( "purchase_id" => $log_id, "cart_item" => $item, "purchase_log" => $log_data ) );

if ( ! is_string( $additional_content ) )

$additional_content = ”;

else

$has_additional_details = true;

$additional_details[] = $additional_content;

$item_total = $item->quantity * $item->price;

$item_total = wpsc_currency_display( $item_total , array( ‘display_as_html’ => false ) );

$item_price = wpsc_currency_display( $item->price, array( ‘display_as_html’ => false ) );

$rows[] = array( $item->name, $item_price, $item->quantity, $item_total );

}

// Preserve the ‘wpsc_transaction_result_content’ filter for backward compat

if ( $has_additional_details ) {

$headings[] = __( ‘Additional Details’, ‘wpsc’ );

foreach ( $rows as $index => $row ) {

$rows[] = $additional_details[$index];

}

}

$table_args = array( ‘headings’ => $headings, ‘rows’ => $rows );

return apply_filters( ‘wpsc_purchase_log_notification_product_table_args’, $table_args, $this );

}

[/php]