function hook_commerce_google_analytics_item_alter in Commerce Google Analytics 8
Alter single item array data for Ecommerce Tracking.
Parameters
array $item: An item array for Ecommerce Tracking to be altered.
\Drupal\commerce_order\Entity\OrderItemInterface $order_item: The order item.
array $context: An array with the following keys:
- transaction: transaction array.
- order: The order.
See also
\Drupal\commerce_google_analytics\EventSubscriber\SendOrderAnalyticsSubscriber::buildGaPushParams()
1 invocation of hook_commerce_google_analytics_item_alter()
- SendOrderAnalyticsSubscriber::buildGaPushParams in src/
EventSubscriber/ SendOrderAnalyticsSubscriber.php - Builds the Ecommerce Tracking data array needed by GA Push API for a given order.
File
- ./
commerce_google_analytics.api.php, line 46 - Hooks provided by the Commerce Google Analytics module.
Code
function hook_commerce_google_analytics_item_alter(array &$item, \Drupal\commerce_order\Entity\OrderItemInterface $order_item, array $context) {
$item['name'] = $order_item
->getTitle();
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $context['order'];
$item['order_id'] = $order
->getOrderNumber();
}