PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.5
GiveWP – Donation Plugin and Fundraising Platform v4.15.5
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / Framework / FieldsAPI / Amount.php

Amount.php in GiveWP – Donation Plugin and Fundraising Platform 4.15.5, at src/Framework/FieldsAPI/Amount.php

117 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Give\Framework\FieldsAPI;
6
7 use Give\Framework\FieldsAPI\Concerns\HasLabel;
8
9 class Amount extends Field
10 {
11 use HasLabel;
12
13 const TYPE = 'amount';
14
15 /**
16 * @var array ['label' => string, 'value' => int, 'checked' => bool]
17 */
18 protected $levels = [];
19 /**
20 * @var string
21 */
22 protected $customAmountText;
23
24 /**
25 * @var bool
26 */
27 protected $allowCustomAmount = false;
28 /**
29 * @var bool
30 */
31 protected $allowLevels = false;
32
33 /**
34 * @var float|int
35 */
36 protected $fixedAmountValue;
37
38 /**
39 * Set the preset donation levels. Provide level amounts in minor units.
40 *
41 * @since 3.12.0 Changed to receive an array as a parameter.
42 * @since 3.0.0
43 */
44 public function levels(array ...$levels): self
45 {
46 $this->levels = $levels;
47
48 return $this;
49 }
50
51 /**
52 * @since 3.0.0
53 */
54 public function getLevels(): array
55 {
56 return $this->levels;
57 }
58
59 /**
60 * @since 3.0.0
61 */
62 public function allowCustomAmount($allow = true): self
63 {
64 $this->allowCustomAmount = $allow;
65
66 return $this;
67 }
68
69 /**
70 * @since 3.0.0
71 */
72 public function allowLevels($allow = true): self
73 {
74 $this->allowLevels = $allow;
75
76 return $this;
77 }
78
79 /**
80 * @since 3.0.0
81 */
82 public function customAmountAllowed(): bool
83 {
84 return $this->allowCustomAmount;
85 }
86
87 /**
88 * @since 3.0.0
89 */
90 public function customAmountText(string $customAmountText): Amount
91 {
92 $this->customAmountText = $customAmountText;
93
94 return $this;
95 }
96
97 /**
98 * @since 3.0.0
99 *
100 * @param float|int $amount
101 */
102 public function fixedAmountValue($amount): Amount
103 {
104 $this->fixedAmountValue = $amount;
105
106 return $this;
107 }
108
109 /**
110 * @since 3.0.0
111 */
112 public function getFixedAmountValue()
113 {
114 return $this->fixedAmountValue;
115 }
116 }
117