-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapi.api.php
More file actions
86 lines (77 loc) · 2.73 KB
/
Copy pathcapi.api.php
File metadata and controls
86 lines (77 loc) · 2.73 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* @file
* Hooks specific to the Meta Conversions API module.
*/
declare(strict_types=1);
use Drupal\commerce_order\Entity\OrderItemInterface;
use Drupal\commerce_product\Entity\ProductVariationInterface;
use FacebookAds\Object\ServerSide\CustomData;
use FacebookAds\Object\ServerSide\Event;
use FacebookAds\Object\ServerSide\UserData;
/**
* Alters the user data object for the "ViewContent" event.
*
* @param \FacebookAds\Object\ServerSide\UserData $user_data
* The user data.
* @param \Drupal\commerce_product\Entity\ProductVariationInterface $product_variation
* The product variation.
*/
function hook_capi_view_content_user_data_alter(UserData $user_data, ProductVariationInterface $product_variation): void {
$user_data->setFirstName('Goran');
}
/**
* Alters the custom data object for the "ViewContent" event.
*
* @param \FacebookAds\Object\ServerSide\CustomData $custom_data
* The custom data.
* @param \Drupal\commerce_product\Entity\ProductVariationInterface $product_variation
* The product variation.
*/
function hook_capi_view_content_custom_data_alter(CustomData $custom_data, ProductVariationInterface $product_variation): void {
$custom_data->setContentName('My product 1');
}
/**
* Alters the event data for the "ViewContent" event.
*
* @param \FacebookAds\Object\ServerSide\Event $event
* The event.
* @param \Drupal\commerce_product\Entity\ProductVariationInterface $product_variation
* The product variation.
*/
function hook_capi_view_content_event_alter(Event $event, ProductVariationInterface $product_variation): void {
$event->setEventId('Test 123');
}
/**
* Alters the user data object for the "AddToCart" event.
*
* @param \FacebookAds\Object\ServerSide\UserData $user_data
* The user data.
* @param \Drupal\commerce_order\Entity\OrderItemInterface $order_item
* The order item.
*/
function hook_capi_add_to_cart_user_data_alter(UserData $user_data, OrderItemInterface $order_item): void {
$user_data->setPhone('555-666');
}
/**
* Alters the custom data object for the "AddToCart" event.
*
* @param \FacebookAds\Object\ServerSide\CustomData $custom_data
* The custom data.
* @param \Drupal\commerce_order\Entity\OrderItemInterface $order_item
* The order item.
*/
function hook_capi_add_to_cart_custom_data_alter(CustomData $custom_data, OrderItemInterface $order_item): void {
$custom_data->setContentType('my_type');
}
/**
* Alters the event data for the "AddToCart" event.
*
* @param \FacebookAds\Object\ServerSide\Event $event
* The event.
* @param \Drupal\commerce_order\Entity\OrderItemInterface $order_item
* The order item.
*/
function hook_capi_add_to_cart_event_alter(Event $event, OrderItemInterface $order_item): void {
$event->setEventId('Test 789');
}