wpsc_transaction_result_cart_item

Located in: wpsc-transaction_results_functions.php

Functions that call this hook: transaction_results()
Arguments Accepted: $array – Array containing (int)purchase_id, (object)cart_item and (object)purchase_log
Version Introduced: 3.8

Description: The action wpsc_transaction_result_cart_item is triggered on the Transaction Results page and is used to add functionality to the ordering process.

This hook is an action which means that it primarily acts as an event trigger, instead of a content filter. A Plugin can use this hook to alter the ordering process.

Use Case:
[php]<?php add_action(‘wpsc_transaction_result_cart_item’, ‘your_function’); ?>[/php]

[php]/**
* @param $array Array containing (int)purchase_id, (object)cart_item and (object)purchase_log
* @return string
*/
function your_function( $array ) {
$content = ‘<p>This is Purchase #: ‘ . $array[‘purchase_id’] . ‘</p>’;
echo $content;
}
?>[/php]

Code in context:
[php firstline=”132″ highlight=”142″]
$email = wpsc_get_buyers_email($purchase_log[‘id’]);
$previous_download_ids = array( );
$product_list = $product_list_html = $report_product_list = ”;

$cart = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CART_CONTENTS . "` WHERE `purchaseid` = ‘{$purchase_log[‘id’]}’" , ARRAY_A );
if ( ($cart != null) && ($errorcode == 0) ) {
$total_shipping = ”;
foreach ( $cart as $row ) {
$link = array( );
$wpdb->update(WPSC_TABLE_DOWNLOAD_STATUS, array(‘active’ => ‘1’), array(‘cartid’ => $row[‘id’], ‘purchid’=>$purchase_log[‘id’]) );
do_action( ‘wpsc_transaction_result_cart_item’, array( "purchase_id" => $purchase_log[‘id’], "cart_item" => $row, "purchase_log" => $purchase_log ) );

if ( $is_transaction ) {

$download_data = $wpdb->get_results( "SELECT *
FROM `" . WPSC_TABLE_DOWNLOAD_STATUS . "`
WHERE `active`=’1′
AND `purchid`=’" . $purchase_log[‘id’] . "’
AND `cartid` = ‘" . $row[‘id’] . "’", ARRAY_A );
[/php]