-
Notifications
You must be signed in to change notification settings - Fork 252
Expand file tree
/
Copy pathcommerce_log.module
More file actions
44 lines (41 loc) · 1.25 KB
/
commerce_log.module
File metadata and controls
44 lines (41 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* @file
* Provides activity logs for Commerce entities.
*/
/**
* Implements hook_preprocess_HOOK() for commerce_order.
*/
function commerce_log_preprocess_commerce_order(&$variables) {
/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $variables['elements']['#commerce_order'];
$variables['order']['activity'] = [
'#type' => 'view',
'#name' => 'commerce_activity',
'#display_id' => 'default',
'#arguments' => [$order->id(), 'commerce_order'],
'#embed' => TRUE,
'#title' => t('Order activity'),
];
}
/**
* Implements hook_preprocess_HOOK() for commerce_product_form.
*/
function commerce_log_preprocess_commerce_product_form(&$variables) {
/** @var \Drupal\commerce_product\Entity\ProductInterface $product */
if ($product = \Drupal::service('current_route_match')->getParameter('commerce_product')) {
$variables['form']['actions']['activity'] = [
'#weight' => 100,
'title' => [
'#markup' => '<h3>' . t('Product activity') . '</h3>',
],
'log' => [
'#type' => 'view',
'#name' => 'commerce_activity',
'#display_id' => 'default',
'#arguments' => [$product->id(), 'commerce_product'],
'#weight' => 100,
],
];
}
}