PluginProbe
PayPlug for WooCommerce (Official) / 2.8.2
PayPlug for WooCommerce (Official) v2.8.2
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.8.2, at src/Front/PayplugOney/Country/OneyBase.php

274 lines 4.2 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 /**
71 * @var array
72 */
73 private $variations = [];
74
75 public function __construct()
76 {
77 $this->payplugOptions = PayplugWoocommerceHelper::get_payplug_options();
78 $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;
79 $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;
80
81 $this->set_max_amount( $max );
82 $this->set_min_amount( $min );
83 }
84
85 /**
86 * SUM totalproducts that are in the cart
87 */
88 public function handleTotalProducts()
89 {
90 $this->addTotalProducts(1);
91 if(is_cart()) {
92 $this->resetTotalProducts();
93 foreach(WC()->cart->cart_contents as $product) {
94 $this->addTotalProducts($product['quantity']);
95 }
96 }
97 }
98
99 /**
100 * Setter
101 * @param $amount
102 */
103 public function set_min_amount($amount)
104 {
105 $this->min_amount = (int) $amount;
106 }
107
108 /**
109 * Setter
110 * @param $amount
111 */
112 public function set_max_amount($amount)
113 {
114 $this->max_amount = (int) $amount;
115 }
116
117 /**
118 * @return int
119 */
120 public function get_min_amount()
121 {
122 return $this->min_amount;
123 }
124
125 /**
126 * @return int
127 */
128 public function get_max_amount()
129 {
130 return $this->max_amount;
131 }
132
133 /**
134 * @return string
135 */
136 public function getIcon()
137 {
138 return $this->icon;
139 }
140
141 /**
142 * @param string $icon
143 */
144 public function setIcon($icon)
145 {
146 $this->icon = $icon;
147 }
148
149 /**
150 * @return bool
151 */
152 public function isDisable()
153 {
154 if($this->disable){
155 return "disabled";
156 }
157
158 return '';
159 }
160
161 /**
162 * @param bool $disable
163 */
164 public function setDisable($disable)
165 {
166 $this->disable = $disable;
167 }
168
169 /**
170 * @param $qty
171 * @return void
172 */
173 public function addTotalProducts($qty)
174 {
175 $this->total_products += $qty;
176 }
177
178 /**
179 * @set total_products to 0
180 */
181 public function resetTotalProducts()
182 {
183 $this->total_products = 0;
184 }
185
186 /**
187 * @return int
188 */
189 public function getTotalProducts()
190 {
191 return $this->total_products;
192 }
193
194 /**
195 * @return int
196 */
197 public function getTotalPrice()
198 {
199 return $this->total_price;
200 }
201
202 /**
203 * @param int $total_price
204 */
205 public function setTotalPrice($total_price)
206 {
207 $this->total_price = $total_price;
208 }
209
210 /**
211 * @return string
212 */
213 public function getSimulatedClass()
214 {
215 return $this->simulatedClass;
216 }
217
218 /**
219 * @param string $simulatedClass
220 */
221 public function setSimulatedClass($simulatedClass)
222 {
223 $this->simulatedClass = $simulatedClass;
224 }
225
226 /**
227 * @return string
228 */
229 public function getOneyType()
230 {
231 return $this->oney_type;
232 }
233
234 /**
235 * @param string $oney_type
236 */
237 public function setOneyType($oney_type)
238 {
239 $this->oney_type = $oney_type;
240 }
241
242 /**
243 * @return array
244 */
245 public function getPayplugOptions()
246 {
247 return $this->payplugOptions;
248 }
249
250 /**
251 * @param array $payplugOptions
252 */
253 public function setPayplugOptions($payplugOptions)
254 {
255 $this->payplugOptions = $payplugOptions;
256 }
257
258 /**
259 * @return array
260 */
261 public function getVariations(){
262 return $this->variations;
263 }
264
265 /**
266 * @return array
267 */
268 public function setVariations($variations){
269 $this->variations[$variations['variation_id']] = (float) $variations["display_price"];
270 }
271
272
273 }
274