-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPurchase.php
More file actions
109 lines (92 loc) · 2.27 KB
/
Purchase.php
File metadata and controls
109 lines (92 loc) · 2.27 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
namespace AlexWestergaard\PhpGa4\Event;
use AlexWestergaard\PhpGa4\Helper\EventHelper;
use AlexWestergaard\PhpGa4\Facade;
class Purchase extends EventHelper implements Facade\Group\PurchaseFacade
{
protected null|string $currency;
protected null|string $transaction_id;
protected null|int|float $value;
protected null|string $affiliation;
protected null|string $coupon;
protected null|int|float $shipping;
protected null|int|float $tax;
protected array $items = [];
public function getName(): string
{
return 'purchase';
}
public function getParams(): array
{
return [
'currency',
'transaction_id',
'value',
'affiliation',
'coupon',
'shipping',
'tax',
'items',
];
}
public function getRequiredParams(): array
{
$return = [];
if (
isset($this->currency) && !isset($this->value)
|| !isset($this->currency) && isset($this->value)
) {
$return = [
'currency',
'value'
];
}
$return[] = 'transaction_id';
$return[] = 'items';
return $return;
}
public function setCurrency(null|string $iso)
{
$this->currency = $iso;
return $this;
}
public function setTransactionId(null|string $id)
{
$this->transaction_id = $id;
return $this;
}
public function setValue(null|int|float $val)
{
$this->value = $val;
return $this;
}
public function setAffiliation(null|string $affiliation)
{
$this->affiliation = $affiliation;
return $this;
}
public function setCoupon(null|string $code)
{
$this->coupon = $code;
return $this;
}
public function setShipping(null|int|float $cost)
{
$this->shipping = $cost;
return $this;
}
public function setTax(null|int|float $tax)
{
$this->tax = $tax;
return $this;
}
public function addItem(Facade\Type\ItemType $item)
{
$this->items[] = $item->toArray();
return $this;
}
public function resetItems()
{
$this->items = [];
}
}