PluginProbe
PayPlug for WooCommerce (Official) / 2.6.4
PayPlug for WooCommerce (Official) v2.6.4
3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 All 101 releases
payplug / src / Front / PayplugOney / Country / OneyBase.php

OneyBase.php in PayPlug for WooCommerce (Official) 2.6.4, at src/Front/PayplugOney/Country/OneyBase.php

255 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Payplug\PayplugWoocommerce\Front\PayplugOney\Country;
4 use Payplug\PayplugWoocommerce\PayplugWoocommerceHelper;
5 use function is_cart;
6 use function WC;
7
8 // Exit if accessed directly
9 if (!defined('ABSPATH')) {
10 exit;
11 }
12
13 Abstract Class OneyBase implements InterfaceOney
14 {
15 /**
16 * @var string
17 */
18 private $icon = 'oney-3x4x';
19
20 /**
21 * @var bool
22 */
23 private $disable = false;
24
25 /**
26 * @var int
27 */
28 private $min_amount = 0;
29
30 /**
31 * @var int
32 */
33 private $max_amount = 0;
34
35 /**
36 * @var int
37 */
38 private $total_products = 0;
39
40 /**
41 * @var int
42 */
43 private $total_price = 0;
44
45 /**
46 * @var string
47 */
48 private $simulatedClass = '';
49
50 /**
51 * @var string
52 */
53 private $oney_type="with_fees";
54
55 /**
56 * @var array
57 */
58 private $payplugOptions = [];
59
60 /**
61 * @var int
62 */
63 private $max_default_amount = 3000;
64
65 /**
66 * @var int
67 */
68 private $min_default_amount = 100;
69
70 public function __construct()
71 {
72 $this->payplugOptions = PayplugWoocommerceHelper::getOneySettings();
73 $max = ( !empty($this->payplugOptions['oney_thresholds_max']) && (int) $this->payplugOptions['oney_thresholds_max'] <= $this->max_default_amount ) ? $this->payplugOptions['oney_thresholds_max'] : $this->max_default_amount;
74 $min = ( !empty($this->payplugOptions['oney_thresholds_min']) && (int) $this->payplugOptions['oney_thresholds_min'] >= $this->min_default_amount) ? $this->payplugOptions['oney_thresholds_min'] : $this->min_default_amount;
75
76 $this->set_max_amount( $max );
77 $this->set_min_amount( $min );
78 }
79
80 /**
81 * SUM totalproducts that are in the cart
82 */
83 public function handleTotalProducts()
84 {
85 $this->addTotalProducts(1);
86 if(is_cart()) {
87 $this->resetTotalProducts();
88 foreach(WC()->cart->cart_contents as $product) {
89 $this->addTotalProducts($product['quantity']);
90 }
91 }
92 }
93
94 /**
95 * Setter
96 * @param $amount
97 */
98 public function set_min_amount($amount)
99 {
100 $this->min_amount = (int) $amount;
101 }
102
103 /**
104 * Setter
105 * @param $amount
106 */
107 public function set_max_amount($amount)
108 {
109 $this->max_amount = (int) $amount;
110 }
111
112 /**
113 * @return int
114 */
115 public function get_min_amount()
116 {
117 return $this->min_amount;
118 }
119
120 /**
121 * @return int
122 */
123 public function get_max_amount()
124 {
125 return $this->max_amount;
126 }
127
128 /**
129 * @return string
130 */
131 public function getIcon()
132 {
133 return $this->icon;
134 }
135
136 /**
137 * @param string $icon
138 */
139 public function setIcon($icon)
140 {
141 $this->icon = $icon;
142 }
143
144 /**
145 * @return bool
146 */
147 public function isDisable()
148 {
149 if($this->disable){
150 return "disabled";
151 }
152
153 return '';
154 }
155
156 /**
157 * @param bool $disable
158 */
159 public function setDisable($disable)
160 {
161 $this->disable = $disable;
162 }
163
164 /**
165 * @param $qty
166 * @return void
167 */
168 public function addTotalProducts($qty)
169 {
170 $this->total_products += $qty;
171 }
172
173 /**
174 * @set total_products to 0
175 */
176 public function resetTotalProducts()
177 {
178 $this->total_products = 0;
179 }
180
181 /**
182 * @return int
183 */
184 public function getTotalProducts()
185 {
186 return $this->total_products;
187 }
188
189 /**
190 * @return int
191 */
192 public function getTotalPrice()
193 {
194 return $this->total_price;
195 }
196
197 /**
198 * @param int $total_price
199 */
200 public function setTotalPrice($total_price)
201 {
202 $this->total_price = $total_price;
203 }
204
205 /**
206 * @return string
207 */
208 public function getSimulatedClass()
209 {
210 return $this->simulatedClass;
211 }
212
213 /**
214 * @param string $simulatedClass
215 */
216 public function setSimulatedClass($simulatedClass)
217 {
218 $this->simulatedClass = $simulatedClass;
219 }
220
221 /**
222 * @return string
223 */
224 public function getOneyType()
225 {
226 return $this->oney_type;
227 }
228
229 /**
230 * @param string $oney_type
231 */
232 public function setOneyType($oney_type)
233 {
234 $this->oney_type = $oney_type;
235 }
236
237 /**
238 * @return array
239 */
240 public function getPayplugOptions()
241 {
242 return $this->payplugOptions;
243 }
244
245 /**
246 * @param array $payplugOptions
247 */
248 public function setPayplugOptions($payplugOptions)
249 {
250 $this->payplugOptions = $payplugOptions;
251 }
252
253
254 }
255