Skip navigation
Help

hook_ucga_item_alter

6 hooks.php hook_ucga_item_alter(&$item, $product, $trans, $order)
7 uc_googleanalytics.api.php hook_ucga_item_alter(&$item, $product, $trans, $order)

Allows modules to alter items passed to the e-commerce tracking code.

The UC Google Analytics module constructs function calls that work through the Google Analytics JS API to report purchased items for e-commerce tracking purposes. The module builds the argument list for each product on an order and uses this hook to give other modules a chance to alter what gets reported to Google Analytics. Additional arguments passed to implementations of this hook are provided for context.

Parameters

$item: An array of arguments being passed to Google Analytics representing an item on the order, including order_id, sku, name, category, price, and qty.

$product: The product object as found in the $order object.

$trans: The array of arguments that were passed to Google Analytics to represent the transaction.

$order: The order object being reported to Google Analytics.

Return value

Nothing should be returned. Hook implementations should receive the $item array by reference and alter it directly.

Related topics

1 invocation of hook_ucga_item_alter()

File

ubercart/uc_googleanalytics/uc_googleanalytics.api.php, line 69
Hooks provided by the Google Analytics for Ubercart module.

Code

function hook_ucga_item_alter(&$item, $product, $trans, $order) {
  // Example implementation: always set the category to "UBERCART".
  $item['category'] = 'UBERCART';
}